Jump to content

Value is always false/null when submitting a form


Kazlaaz

Recommended Posts

I'm having trouble getting my if(isset($_POST['form_sub'])) to validate true when submitting a form, where the form name is 'form_sub'. The value always seems to validate as false or NULL. I've tried using a hidden input field also. Basically when I hit submit or enter, with information typed in the first field or all the fields, the result is never true, so it just loops back around to the beginning.

I am using PHP5, Firefox and IE browers. Not sure what other information would be useful.

Any help would be appreciated, thank you.


[code]<?php
if (isset($_POST['form_sub']))
{
echo 'Testing Submit:<br>';
echo 'header: '.$_POST['header'].'<br>';

exit;
}
?>

<?php
if (isset($_GET['add']))
{
?>
<form name="FormName" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table width="500"  border="0" cellspacing="1" bgcolor="#000000">
  <tr bgcolor="#FFFFFF">
    <td width="150">News Header </td>
    <td><input name="header" type="text" /></td>
    </tr>
  <tr bgcolor="#FFFFFF">
    <td>News Headline </td>
    <td><input name="headline" type="text" /></td>
    </tr>
  <tr bgcolor="#FFFFFF">
    <td>News</td>
    <td><textarea name="news"></textarea></td>
    </tr>
  <tr bgcolor="#FFFFFF">
    <td>&nbsp;</td>
    <td><input name="featured" type="checkbox" value="1" />
      Featured
      <input name="active" type="checkbox" value="1" />
      Active </td>
    </tr>
  <tr bgcolor="#FFFFFF">
    <td>&nbsp;</td>
    <td align="right">
    <input name="form_sub" type="submit" value="Submit" /></td>
    </tr>
</table>

</form>
<?php
}
else
{
?>
<a href="<?php $_SERVER['PHP_SELF']; ?>?add=1">Add news item</a>
<?php
} // end main if
?>[/code]
Link to comment
Share on other sites

It seems my settings are wrong somewhere then, it definately does not work for me.

When I use var_dump($_POST); I get this before i submit, and after: array(0)

Then I tried to add a hidden field:
[code]<input name="submitted" type="hidden" value="true">[/code]
And changed the line 2 php code to:
[code]if (isset($_POST['submitted']))[/code]

Still nothing.

When I var_dump($_POST); that I get the same thing before and after the submit button is pushed: array(0)

EDIT: Seems to be my server settings, tried a different server and it works fine. Thanks everyone. Now to figure out what's wrong with my server.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.