PDA

View Full Version : PHP form question


robbiejh12
02-06-2005, 04:53 PM
Ok, I am new to php pretty much so I went, as a good boy does, to w3schools to learn. I was learning all about forms and the post action but I couldn't get it to work. Ok, thought I, well I'll start with their code and work from there. But, amazingly, when I used the w3schools php code from their website, it wouldn't carry the postdata to the next webpage. If it helps, I was running this all fully offline, both files on my desktop, and I tried it in both FF and IE, but neither worked. It did try to use the php file stated in the action code, but it didn't carry the postdata. Here are the codes, as taken directly from w3schools.

welcome.html:


<html>
<body>

<form action="welcome.php" method="POST">
Enter your name: <input type="text" name="name" />
Enter your age: <input type="text" name="age" />
<input type="submit" />
</form>

</body>
</html>

welcome.php:


<html>
<body>

Welcome <?php echo $_POST["name"]; ?>.<br />
You are <?php echo $_POST["age"]; ?> years old!

</body>
</html>


All help appreciated.
:confused: :(

Admin edit: Please use a more descriptive subject when posting a thread in the future.

cooleo100d
02-06-2005, 05:25 PM
Hi,

I don't think it has anything to do with your script. I think it is the configuration of your php.ini. Find your php.ini file, and look for settings on post data. Maybe someone on the forums will know. But I know it can be tricky when your trying to use php on your computer, offline. You may want to look at a preconfigured package like http://www.firepages.com.au/ which installs PHP, MySQL, and Apache for you.

Hope this helps,
~David

robbiejh12
02-06-2005, 06:24 PM
ok thanks i'll try that

Horus Kol
02-07-2005, 08:53 AM
$_POST should work out of the box, as it were... i don't think there is anything i php.ini to prevent it from doing so.


robbie - try and dump the globals array to see if the values are in there:


<?php
// in welcome.php

echo "<pre>";
print_r($GLOBALS);
echo "</pre>";

?>

Fou-Lu
02-07-2005, 09:34 AM
Everyone is also jumping to the conclusion that you have php running through either IIS or Apache as well, you'd be suprised the number of people that ask me why their script shows, and I ask them if they have it installed :P

Follow Horus' idea first, if your global dump has nothing, there is something wrong with your configurations for php.

Horus Kol
02-07-2005, 11:59 AM
well...

if php isn't actually installed, the output would be:


Welcome <?php echo $_POST["name"]; ?>.
You are <?php echo $_POST["age"]; ?> years old!

Mhtml
02-07-2005, 12:04 PM
You mentioned the files are located on your desktop, is the server configured to execute scripts there? Are you accessing it via http://localhost or just opening it with your browser?

Spookster
02-07-2005, 12:43 PM
Ok, I am new to php pretty much so I went, as a good boy does, to w3schools to learn. I was learning all about forms and the post action but I couldn't get it to work. Ok, thought I, well I'll start with their code and work from there. But, amazingly, when I used the w3schools php code from their website, it wouldn't carry the postdata to the next webpage. If it helps, I was running this all fully offline, both files on my desktop, and I tried it in both FF and IE, but neither worked. It did try to use the php file stated in the action code, but it didn't carry the postdata. Here are the codes, as taken directly from w3schools.

welcome.html:


<html>
<body>

<form action="welcome.php" method="POST">
Enter your name: <input type="text" name="name" />
Enter your age: <input type="text" name="age" />
<input type="submit" />
</form>

</body>
</html>

welcome.php:


<html>
<body>

Welcome <?php echo $_POST["name"]; ?>.<br />
You are <?php echo $_POST["age"]; ?> years old!

</body>
</html>


All help appreciated.
:confused: :(

Read http://www.codingforums.com/postguide.htm