Problem with form action...

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
pedrokas
Forum Commoner
Posts: 32
Joined: Thu Jan 15, 2004 10:53 am
Location: Lisboa, Portugal

Problem with form action...

Post 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...
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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
Last edited by JayBird on Thu Jan 15, 2004 11:11 am, edited 1 time in total.
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post 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]
User avatar
pedrokas
Forum Commoner
Posts: 32
Joined: Thu Jan 15, 2004 10:53 am
Location: Lisboa, Portugal

Thank you...

Post by pedrokas »

... and it was so simple....

tku..
Post Reply