Jump to content

Need help with form data.


Jack.Straw

Recommended Posts

Hello.  I'm learning PHP and can't figure out what i'm doing wrong here.  I'm trying to learn how to pass variables from a form to PHP, but none of things in the tutorials i've been working with are working as intended.  Can you tell me what i'm doing wrong?

[code]
<HTML>
<HEAD>
<TITLE>Learning</TITLE>
</HEAD>
<BODY>
<FORM ACTION="<?php echo $PHP_SELF;?>" METHOD="POST">
<INPUT TYPE="text" Name="item" size="20">
<INPUT TYPE="submit" NAME="submit" VALUE="Submit">
</FORM>

<?php
if ($submit == "submit")
  {
  echo("$item has been submitted");
  }
?>

</body>
</html>[/code]

Thanks in advance,
-Jack
Link to comment
https://forums.phpfreaks.com/topic/25952-need-help-with-form-data/
Share on other sites

Your code is relying on register globals being ON, your server/host probably has this OFF as it should be.
This means that you must assign each POST (or GET or whatever)

Example:
[code]

<?php

if (isset($_POST['submit']))
{
  echo "{$_POST['item']} has been submitted";
}

?>

[/code]

Archived

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

×
×
  • Create New...

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.