OK I'm new to the whole PHP scene so go easy on me. I'm trying to pass form variables but it will not work. I'm using Apache 2.0.43, and PHP 4.2.3 Here is my code
testform.html
<HTML><HEAD> <TITLE> Form Handling with PHP </TITLE> </HEAD>
<BODY BGCOLOR="#FFFFFF"> <center> <FORM METHOD=POST
ACTION="tellus.php"> <TABLE> <TR height="20"><TD
colspan="2"><FONT SIZE="-1" face="verdana">Below is a Sample
Form for our PHP tutorial</TD></TR> <TR height="50">
<td></td></TR> <TR><TD align="left"><FONT SIZE="-1"
face="verdana"> <b>Your Name <br>Your E-Mail
Address</b></td> <td><INPUT TYPE="text"
NAME="name"><br><INPUT TYPE="text" NAME="email"><p></TD>
</TR> <tr><td colspan="2"><center> <SELECT NAME="opinion">
<option value="is great">I like your site</option> <option
value="is OK">Your Site is OK</option> <option value="is
horrible">Your Site is horrible</option> </SELECT><p><INPUT
TYPE="submit" value="Tell us!"></td></tr>
</TABLE></FORM></BODY></HTML>
<body>
</body>
</html>
*************Here is my PHP code**************
tellus.php
<html>
<body><?
echo "<center><FONT SIZE=-1 face=verdana>"; echo "Greetings $name, thank you for filling out our";
echo "form.";
echo "</center><p><center><TABLE border=0 width=500";
echo "cellspacing=0 cellpadding=7>"; echo "<TR><TD><FONT SIZE=-1 face=verdana>"; echo "In the form, you stated that our site";
echo "$status. Thank you for your input."; echo "We will send you more information about our site";
echo "in an email to $email.";
echo "If you have any more comments, feel free to reply.";
echo "</FONT></TD></TR></TABLE></center>";
?>
</body>
</html>
any help would be greatly apreciated and thanks in advance
Having trouble passing variables on form submission
Moderator: General Moderators
I seem to be having problems passing values on also but with uploading files, wish my problem was as simple to solve as I think yours is.
register_globals being set to off is probably your problem, you should check out the changes for this in the php.manual, I started learning using php in my spare time a couple of months ago and I still get caught out by this. I find one of the problems is that most books and example that are available are written for register_globals to be on as default, which it no longer is with later versions.
Try putting:
$variable_from_form = $_POST[variable_from_form'];
for each of the form variables after the <?php in the tellus.php file, so the name variable would look like this:
$name = $_POST['name'];
The values should be passed on now, same goes if you are using GET only you can get the values as: $variable_name = $_GET['variable_name'];
See altered example of your tellus.php file below, the first opening <?php and closing ?> should be ignored:
register_globals being set to off is probably your problem, you should check out the changes for this in the php.manual, I started learning using php in my spare time a couple of months ago and I still get caught out by this. I find one of the problems is that most books and example that are available are written for register_globals to be on as default, which it no longer is with later versions.
Try putting:
$variable_from_form = $_POST[variable_from_form'];
for each of the form variables after the <?php in the tellus.php file, so the name variable would look like this:
$name = $_POST['name'];
The values should be passed on now, same goes if you are using GET only you can get the values as: $variable_name = $_GET['variable_name'];
See altered example of your tellus.php file below, the first opening <?php and closing ?> should be ignored:
Code: Select all
<?php
<html>
<body>
<?php
$name = $_POST['name'];
$email = $_POST['email'];
// Put the rest of the variables here.
echo "<center><FONT SIZE=-1 face=verdana>"; echo "Greetings $name, thank you for filling out our";
echo "form.";
echo "</center><p><center><TABLE border=0 width=500";
echo "cellspacing=0 cellpadding=7>"; echo "<TR><TD><FONT SIZE=-1 face=verdana>"; echo "In the form, you stated that our site";
echo "$status. Thank you for your input."; echo "We will send you more information about our site";
echo "in an email to $email.";
echo "If you have any more comments, feel free to reply.";
echo "</FONT></TD></TR></TABLE></center>";
?>
</body>
</html>
?>