View Full Version : PHP not passing variables from form
squirellplaying
08-09-2004, 03:58 AM
I'm just learning php so please bear with me. I'm trying to pass variables from a form onto a new page. http://141.157.79.107:1910/emulator/testphp.html is the page I created using the codes from http://webmonkey.wired.com/webmonkey/01/48/index2a_page6.html?tw=programming. I copied and pasted them, and changed a few words so the parents don't get angery. But I followed the guide! It's so simple. This is not the only page I can't get to work. Also this (http://141.157.79.107:1910/ptemplate.html) page. That page is a little longer but it's the same thing. I know php is installed on my server because of this (http://141.157.79.107:1910/php.php) and this. (http://troop1910.homelinux.com:1910/php.php)
Spookster
08-09-2004, 04:13 AM
Can't help at all without seeing any code.
hemebond
08-09-2004, 04:17 AM
Your form has its action attribute set to 'post' instead of the URL you want to submit to.
squirellplaying
08-09-2004, 04:32 AM
Woops. I forgot you can't view source with php.
form page:
<html>
<head>
<title>My Form</title>
</head>
<body>
<form action="words.php" method=post>
My name is:
<br> <input type="text" name="YourName">
<p> My favorite word is:
<br> <input type="text" name="FavoriteWord">
<p>
<input type="submit" name="submit" value="Enter My Data!">
</form>
</body>
</html>
words.php:
<html>
<head>
<title>Word</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>
Hi <?php print $YourName; ?>
<p>
You like the word <b> <?php print $FavoriteWord; ?> !?! </b>
</body>
</html>
hemebond I'm not sure what your talking about. The tutorial said that post would pass the values on transparently why get would pass the values in the url. I changed it to get and it still doesn't work.
don't rely that register_globals=on --> it shouldn't be and from 4.1 on, it isn't by default.
so always specify the collection your variable is in, like
$_POST['YourName']
By the way, variablenames in php are casesensitive so you better use only lowercases to avoid mistakes?
squirellplaying
08-09-2004, 08:05 AM
Thank you very much.
I have a system for naming variables so that if one doesn't follow it, it stands out to me.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.