Jump to content


Photo

Value is always false/null when submitting a form


  • Please log in to reply
3 replies to this topic

#1 Kazlaaz

Kazlaaz
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 05 October 2006 - 07:33 AM

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.


<?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
?>


#2 Hi I Am Timbo

Hi I Am Timbo
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 05 October 2006 - 08:02 AM

I don't think submit values post.  You can see what is and what is not posting by doing
var_dump($_POST);
But I wouldn't expect it to post.  If you really need the value form_sub to post, put it in a hidden with whatever value you want.

#3 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 05 October 2006 - 08:19 AM

i dont understand what you mean is wrong.. i have entered info in the form and submitted and it works.. it prints the header..

#4 Kazlaaz

Kazlaaz
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 05 October 2006 - 03:19 PM

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:
<input name="submitted" type="hidden" value="true">
And changed the line 2 php code to:
if (isset($_POST['submitted']))

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users