Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > PHP

Reply
 
LinkBack Thread Tools Display Modes
Old 08-11-2003, 01:56 AM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,503
sde is on a distinguished road
reading a web form for input variables

i want to read in all the field names of a form to an array in php.

example of page i want to read:
Code:
<form method=post action="somepage.html">

Name <input type=text name="realname"> <br>
Email <input type=text name="email"> <br>
Comments <text area name="comments"></textarea>
</form>
i would like to read this page and read the field names into an array
PHP Code:
<?
$field
[0]="name";
$field[1]="email";
$field[2]="comments";
?>
i will read the entire page into a variable, then i think this is the pattern i need to match

input=["]?[a-zA-Z_]+["]?\s

but i am not sure how i would bring all those matches into an array.
__________________
Mike
sde is offline   Reply With Quote
Old 08-12-2003, 12:53 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,720
redhead is on a distinguished road
what about the _POST[] array, they are all there, if you use method=post

_POST['name'] will be the input in the name field.

I could be wrong on this one, but I destinctly remember somethign about that.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 08-12-2003, 06:46 AM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,503
sde is on a distinguished road
the target page i am reading is on another web server.

can someone help me with a regular expression? i can move on with this project if i can just extract the url that the form submits to.

i need to match:

action=somepage.html
action="somepage.html"

theoretically, .. will this match it?\
Code:
\saction=[\"]?(.*)[\"][\s>]
it would have to match:
<space>action=(quotes or no quotes)(any url)(quotes or no quotes)(space or bracket)

i just made that expression as i was typing this post, so i'll go try it now.
__________________
Mike
sde is offline   Reply With Quote
Old 08-12-2003, 10:02 AM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,503
sde is on a distinguished road
Code:
preg_match("!\s+action=\"?(.*)\"?\s*.*>!iU",$contents,$matches)
__________________
Mike
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
EMERGENCY: Dynamic form processing DavH27 PHP 8 10-27-2004 07:52 PM
So What Is Web Design? sde Lounge 9 07-06-2003 02:32 AM


All times are GMT -8. The time now is 06:21 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting