Page 1 of 1

test box submissions

Posted: Sat Jan 29, 2005 1:48 pm
by twb
Hi
I have text box that excepts input and is suppose to echo a message if there is no data entered after the submit button is pressed.
I declared a action variable as follows:

Code: Select all

$action = isset($_POSTї'action']) ? $_POSTї'action'] : '';
//If action equal 'CHECK' then the user has submitted data for checking

Code: Select all

echo 'test2'; //this will echo 'test2'
if (strtoupper($action) == 'CHECK') {
echo 'test3'; //does not get called
if(empty($txt_name) or empty($txt_date) or empty($txt_time) or empty($txt_description)){
  	$msg .= (!empty($msg)) ? '<BR>': '';		
	echo $msg .= "Missing Required Fields"; &#125;//close if
&#125;//CLOSE IF
//in my html code I have a table row:

Code: Select all

<td width="50"><input type="hidden" name="action" id="action" value="CHECK"></td>
My objective is when the submit button is pressed it will echo the previous message"Missing Required fields"
I have this same code in a previous page and it works fine.
Thank you for any help that can be given
twb

text box submissions

Posted: Sat Jan 29, 2005 2:14 pm
by twb
I got it figured out, but not sure the reason...what I did was wrap the html code from the table in a form tag:

Code: Select all

<form name="form1" method="post" action="">
<td width="50"><input type="hidden" name="action" id="action" value="CHECK"></td>
</form>
</tr>
twb

Posted: Sat Jan 29, 2005 6:09 pm
by magicrobotmonkey
yes, an input of any type needs to be in a form to post or get. Note that you can have multiple forms on one page ond only the inputs in the form that was submitted will be posted.