Page 1 of 1

Problem with form action...

Posted: Thu Jan 15, 2004 10:53 am
by pedrokas
Hi. ppl
taking first steps in php and i've a problem i can't resolve.
i'm trying to pass a var from a php page to another, ok in the manual this is very simple.

the initial page have the following code...

"infopessoal.php"

<html>
(...)
<form action= "ver.php" method="post">
nome:<input name="nomep" type="text">
<input type="submit">
</form>

so my "ver.php" page must test the varible, ok? and i've limited the code to the minimal ... only a echo (just for testing)...
<html>
(...)
<?
echo "hello $nomep";
?>

when i test it in server the response is:
hello PHP Notice: Undefined variable: nomep in c:\folder\ver.php on line 10.
however in the address bar the value passes... (.../ver.php?nomep=xpto).
I know this is a fooling question, but ill be really grateful for your help...

Posted: Thu Jan 15, 2004 10:56 am
by JayBird
This is because you don't have register_globals turned on (which is good!)

so, to retrieve the data do this

Code: Select all

<? 
echo "hello ".$_POST['nomep']; 
?>
Mark

Posted: Thu Jan 15, 2004 10:59 am
by kettle_drum
Well if the form has method=post then there shouldnt be any variable attached to the url and you need to reference the variable using $_POST[nomep]

Thank you...

Posted: Thu Jan 15, 2004 10:59 am
by pedrokas
... and it was so simple....

tku..