Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hidden form field

Status
Not open for further replies.

kusarigama

Technical User
Apr 24, 2002
45
0
0
DE
Hi all,

is there a way to output hidden form fields on the first submit:
I need it to output error messages on the top of my script!


<form action=<?=$_SERVER['PHP_SELF'];?> method=post>

<input type=hidden name=collect value=<?=$_POST['collect']?>>

<?PHP
echo $_POST['collect'];
?>
<?
if(isset($_POST['submit']))
{
if($nomail == 1)
{
$_POST['collect'] = &quot;no mail sent&quot;;
}
}
?>

Thanx in advane
 
&quot;is there a way to output hidden form fields&quot; -> no, they are hidden. But you can un-hide them.
You question is not really clear to me. What exactly do you want to do ? Is that something like : there's a 1st post. If this post passes me a value for &quot;collect&quot;, fine, i go on. If not, i want to print an error ?
I think that if you can formulate your question very clearly, it'll be easier to answer for us, and you might even find yourself the answer.
 
OK :) i want to output the value of the &quot;hidden form field&quot;.
When I hit submit, the the value is put to the hidden form field. when I hit the submitbutton a second time the value of the hidden field is dispalyed. Is there a way to display the value on the first submit

Olli
 
i'm not sure php is the best way to go - you can keep it client side, using javascript, so there's no need to always submit the form to the server. But let's go with php :
&quot;Is there a way to display the value on the first submit&quot; :
<?php
if ($_POST['collect']) {echo $_POST['collect'] }
?>
<form action=<?=$_SERVER['PHP_SELF'];?> method=post>
<input type=hidden name=collect value=<?=$_POST['collect']?>>
</form>
wheter it's the 1st, the 2nd or the n-th submit, the value is displayed. if ($_POST['collect']) means : if the form was submitted and the value for collect was set ...
but i wonder why you use value=<?=$_POST['collect']?> in the hidden field ... how can this ever have any value ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top