test box submissions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
twb
Forum Commoner
Posts: 27
Joined: Thu Jan 06, 2005 4:39 pm

test box submissions

Post 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
twb
Forum Commoner
Posts: 27
Joined: Thu Jan 06, 2005 4:39 pm

text box submissions

Post 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
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post 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.
Post Reply