Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

HTML form - PHP

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

HTML form - PHP

Postby php-punk » Wed Feb 05, 2003 11:56 am

right so far i have a HTML form (shown below)
How do i pass the variables of the form to another PHP page?

Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Straight to the point - Guest Book</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body text="#999999">
<?
<form Name="Add" action=\"add.php" method="post">
<p><b>Name</B></p>
<p><input name="name" type="text" Maxlength="25"></p>
<p><B>E-Mail</B></p>
<p><input name="email" type="text" maxlength="25"></p>
<P><b>Website</b>(if Available)</P>
<p><input name="website" type="text" maxlength"25"></p>
<p><b>Post For GuestBook</b></p>
  <p>
    <textarea name="post" cols="30" rows="5" wrap="PHYSICAL"></textarea>
  </p>
  <p>
    <input name="submit" type="submit" value="Submit">
  </p>
<input name="status" type="text">
</form>

</body>
</html>
php-punk
New php-forum User
New php-forum User
 
Posts: 60
Joined: Sun Feb 02, 2003 2:10 am
Location: Leeds, Uk

Postby Hurkle » Wed Feb 05, 2003 1:08 pm

Okay, you've got a basic html form setup, and you have described the 'action' and 'method' settings for the form.

If the action is "add.php", then, when this page is submitted, the web server will look for a script name 'add.php'.

Lets say you have such a script.

if you plase this code in it:

Code: Select all
echo "the entered name is:" ;

if(isset($HTTP_POST_VARS['name')

  {
      echo $HTTP_POST_VARS['name'] . "<BR>";

  }
else

  {
    echo "No name value was passed from the form.<BR>";
  }



you should see whatever was entered for the Name text box display.

Now , note a couple of things.. It's my understanding the using
$HTTP_POST_VARS['nameofformelement']
should just about always work. I use
$_POST['nameofthing'],
'cause it's shorter and works with my setup.
If 'register_globals' is set to on, you should be able to just refer to the name of the form element as if it were a variable.
i.e., if you had a form element name 'txt_user_name' on your form, then your script should be able to simply:

echo $txt_user_name;

I hope this helps

[/code]
Hurkle
New php-forum User
New php-forum User
 
Posts: 36
Joined: Tue Jan 07, 2003 8:45 am
Location: Minnesota, USA


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot], landi and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.