Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

new to php unable to send value from html to php 2

Status
Not open for further replies.

kzn

MIS
Jan 28, 2005
209
GB
Hi I am new to php.
I have created a form.html page
<html>
<head>
<title>Form</title>
</head>

<body>
<form action="HandleForm.php" method="post">
First Name <input type="text" name="FirstName" size="20"><br>
Last Name <input type="text" name="LastName" size="40"><br>
E-Mail Address <input type="text" name="Email" size="60"><br>
Comments <textarea name="Comments" rows="5" cols="40"></textarea><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>


I have also created a results page called Handleform.php

<html>
<head>
<title>HandleForm.php</title>
</head>
<?php
print "your first name is $FirstName, <br>\n";
print "your last name is $LastName <br>\n";
print "your email address is $Email, <br>\n";
print "what you had to was:<br>\n
$Comments<br>\n";
?>
<body>

</body>
</html>

According to the book I should fill in the form and then it will return what I have typed in, but it does not. Strange thing though if I use the get command it will display it in the address bar. Please can someone help me.

Thanks in advance

 
The problem is the variables are not showing on the handleform.php. I only get
your first name is,
your last name is,
your email address is,
what you had to say was:

Can anyone tell me why this information is not displaying?

Thanks
 
You obviously have not read the FAQ.
Print out the phpinfo() and check the setting for register_globals. It is probably set to OFF (and that's good so). Start using the superglobal arrays $_POST, $_GET etc.

And please read the FAQ. For your convenience:
1.1. Form Data Missing (the dreaded, ubiquitous register_globals problem)

A lot of users report that data from submitted HTML forms does not appear in their scripts. In fact, this is probably the problem most commonly reported in the forum.

For example, after submitting the following HTML form:


Code:
      <html>
         <body>
            <form method="post" action="[URL unfurl="true"]http://somedomain.com/somescript.php">[/URL]
               <input type="text" name="thedata">
               <input type="submit">
            </form>
         </body>
      </html>

when the script somecript.php runs, the variable $thedata has no value.

This is because the runtime configuration directive "register_globals" has been set to "off". This is the default setting for PHP, and has been the default setting since PHP version 4.2.0. As this page describes, it is considered best to leave it set to off.

Whether or not "register_globals" set to off, the data from the form will be available in PHP's superglobal variables ( -- in the case of the above HTML, as $_POST['thedata'].
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top