How To Use Code - PLZ HELP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
lazy_yogi
Forum Contributor
Posts: 243
Joined: Fri Jan 24, 2003 3:27 am

Post by lazy_yogi »

I always use $name instead of $_POST['name'];


----------- main page-------------

Code: Select all

<html><body> 
<form action="action.php" method="post">
Your name: <input type="text" name="name"> 
Your age: <input type="text" name="age"> 
<input type="submit" name = sendit>  <--------  added a name to submit button
</form>
----------- action.php -------------

Code: Select all

<?
if ($sendit) &#123;
    print "Hi $name"; 
    print "You are $age years old.";
&#125;
?>

</body>
</html>
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

then you have an older version of php or register_globals enabled.
User avatar
lazy_yogi
Forum Contributor
Posts: 243
Joined: Fri Jan 24, 2003 3:27 am

Post by lazy_yogi »

I have php 4.1.1

so are you saying that I need to use $_POST['name'] in newer versions of php and just using $name won't work ?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Which webserver are you running?

Mac
Post Reply