Jump to content


Photo

what happened with forms and PHP???


  • This topic is locked This topic is locked
3 replies to this topic

#1 Viper76

Viper76
  • New Members
  • Pip
  • Newbie
  • 5 posts
  • LocationToledo Ohio

Posted 03 July 2006 - 10:36 PM

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-....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
Sean

#2 birdie

birdie
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts
  • LocationBirmingham UK

Posted 03 July 2006 - 10:39 PM

wow ice age  :D.

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

Notice the { }

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

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 03 July 2006 - 10:41 PM

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 www.php.net/register_globals

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

Ken

#4 Viper76

Viper76
  • New Members
  • Pip
  • Newbie
  • 5 posts
  • LocationToledo Ohio

Posted 04 July 2006 - 09:06 PM

thanks a lot for the help guys!  Works great now, and yes, thats new since my last coding project.  8)
Sean




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users