RE: Learning PHP - question about hidden form fields

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



iggep...

what are you trying to do with the following:
>>echo "<input type='hidden' name='preform_submitted' value='y'>";
>>echo "<input type='hidden' name='form_submitted'
value='$preform_submitted'>";

if i had to guess, i'm pretty sure you're trying to assign the val of
'preform_submitted' to 'form_submitted'... but i'm not sure why...

$preform_submitted will not have the val you think it does.. in fact, from
your sample, it's not defined... in your sample, when you call the form.php
using the POST method, the elements in the form are available via the $_POST
array...

so you could simply check for the val of $_POST['preform_submitted'] and
assign that to the hidden val..

in a similar manner, you could also check in your logic using the $_POST[]
val...

-bruce


-----Original Message-----
From: Iggep [mailto:iggep@xxxxxxxxxxxxxxx]
Sent: Wednesday, September 07, 2005 3:47 PM
To: php-general@xxxxxxxxxxxxx
Subject:  Learning PHP - question about hidden form fields


Hey all!  I sat down and started learning PHP today and ran into a bit of a
spot.  Hoped someone here could lead me in the right direction.  I created a
simple test form called form.php.  I thought I had this strait in my mind
when I created it, but obviously it didn't work.  All I want to do is create
a static value and pass it back to the page which then triggers a statement
for the user to read.

Problem I'm running into is that I can't seem to find a way to pass that
variable correctly with all this being on a single file.   I'd prefer to do
this in a single file if possible.

Any ideas?

<html>
<head>
	<title>Test Form</title>
</head>
<body>

<?php
if (defined('form_submitted'))	{
	echo "<p>Thank you for submitting your trouble ticket.  We have received
your
trouble ticket and will be in touch with you about it as soon as
possible.</p>";
	echo "<p>If you wish to submit another ticket, please use the form
below.</p>";
}

echo "<form action='form.php' method='post'>";
echo "<input type='hidden' name='preform_submitted' value='y'>";
echo "<input type='hidden' name='form_submitted'
value='$preform_submitted'>";
echo "<table>";
	echo "<tr><td>Last Name:</td><td><input name='lname'
type='text'></td></tr>";
	echo "<tr><td>First Name:</td><td><input name='fname'
type='text'></td></tr>";
	echo "<tr><td>Email Address:</td><td><input name='email_add'
type='text'></td></tr>";
	echo "<tr><td colspan=2>Trouble:</td></tr>";
	echo "<tr><td colspan=2><textarea name='explan'></textarea></td></tr>";
	echo "<tr><td><input type='submit'></td></tr>";
echo "</table>";
echo "</form>";
?>
</body>
</html>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux