Jump to content

Archived

This topic is now archived and is closed to further replies.

Viper76

what happened with forms and PHP???

Recommended Posts

I've been offline for about a year, took a break.  I am now back and building a website, but I find that a few things seemed to have changed.  Here is a small snip of code that does not work.  From what I see, form handling has changed.  Can someone fill me in?

<?PHP
IF ($B1)
echo "yes";
ELSE
echo "no";
?>

<form method="POST" action="http://www.the-home-decor-store.com/test.php">
<p><input type="submit" value="Submit" name="B1"></p>
</form>


This returns no every time.  Its VERY simple, and just by clicking the button, it should return yes.  I have found that nothing entered into a form is being passed to the PHP code on the next page.  I've tried with both the "post" and "get" methods of creating a form.  Someone please help!

Sean

Share this post


Link to post
Share on other sites
wow ice age  :D.

[code]
<?PHP
$B1 = $_POST['B1']; //var  =  a post var
IF ($B1)
{  // new add on since you last tryed?
  echo "yes";
}
ELSE
{
  echo "no";
}
?>
[/code]

Notice the { }

to get the var $B1, you need to specify where it comes from as shown above

Share this post


Link to post
Share on other sites
What you're seeing is the direct result of register_globals being disabled (good) instead of enabled (bad). Please read the section in the on-line PHP manual on [url=http://www.php.net/register_globals]www.php.net/register_globals[/url]

You should use $_POST['B1'] instead.

Ken

Share this post


Link to post
Share on other sites
thanks a lot for the help guys!  Works great now, and yes, thats new since my last coding project.  8)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.