Click to See Complete Forum and Search --> : Why won't my form post?


Donny Bahama
08-23-2009, 03:01 PM
This form won't post and I can't figure out why. Can anyone spot the problem? The page this code is on is ndainvite.php, so it's posting to itself. I thought maybe it was a processing issue, so I pointed the form action at another page. It just doesn't post.

<div style="width:550px; margin:0 auto;>
<form action="ndainvite.php" method="post">
<h3 style="text-align:center;">Send NDA Invitation</h3>
<label>Day: </label><input TYPE="text" NAME="day" value="<?=date('d');?>" SIZE="2" /> &nbsp; &nbsp;
<label>Month: </label><input TYPE="text" NAME="month" value="<?=date('m');?>" SIZE="2" /> &nbsp; &nbsp;
<label>Year: </label><input TYPE="text" NAME="year" value="<?=date('Y');?>" SIZE="2" /><br /><br />
<label>First name: </label><input TYPE="text" NAME="first" SIZE="20" /> &nbsp;
<label>Last name: </label><input TYPE="text" NAME="last" SIZE="30" /><br /><br />
<label>Distinction: </label><input TYPE="text" NAME="descrip" SIZE="90" /><br /><br />
<label>E-ddress: </label><input TYPE="text" NAME="email" SIZE="60" /><br /><br />
<label>User Authorizations: </label><br />
<input type="checkbox" name="AuthCO" value="" /> View Conceptual Overview<br>
<input type="checkbox" name="AuthRM" value="" /> View Roadmap<br>
<input type="checkbox" name="AuthES" value="" /> View Executive Summary<br>
<input type="checkbox" name="AuthBP" value="" /> View Business Plan<br>
<input type="checkbox" name="AuthTD" value="" /> View Technology Detail<br><br>
<input type="hidden" name="proc" value="1">
<input TYPE="submit" NAME="Submit" VALUE="Send Invitation" style="margin-left:120px;" /></p>
</form>
</div>

Donny Bahama
08-23-2009, 03:20 PM
I moved the <h3> block outside the form and it works. I didn't realize that was a no-no.

Charles
08-23-2009, 03:40 PM
I didn't realize that was a no-no.It's not; something else must be going on there. A couple of other things that are a problem but not that problem: You are mixing HTML and XHTML. Remove those trailing "/" characters. It's a bad idea to name the submit button "submit". You are misusing the LABEL element. You have two options see http://www.w3.org/TR/REC-html40/interact/forms.html#edef-LABEL .

Donny Bahama
08-23-2009, 03:45 PM
It's not; something else must be going on there. A couple of other things that are a problem but not that problem: You are mixing HTML and XHTML. Remove those trailing "/" characters. It's a bad idea to name the submit button "submit". You are misusing the LABEL element. You have two options see http://www.w3.org/TR/REC-html40/interact/forms.html#edef-LABEL .I tried removing the XHTML trailing slashes; I also eliminated all but one input until the form was uber simple. Nothing worked until I moved that H3 block. Then everything was fine. Thanks for the pointer on the label tags. Why is it bad to name the Submit button "Submit"?

Charles
08-23-2009, 05:03 PM
Because then the form would have a submit method and a submit property and sometimes that can confuse the browser.

OctoberWind
08-24-2009, 12:11 AM
<div style="width:550px; margin:0 auto;>


You're missing the closing quotation mark on the inline style.

Also, if you are sending a form back to itself using php, I would suggest these two changes to your coding habbits:

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

No matter what page this form is on, it'll send back to itself. What happens when you move and/or rename this file, and forget to change the form?

don't rely on the php short tags <?= ?> as some servers might have those turned off by default, and then you code won't process, and you could end up exposing your code to the unwanted eye. Use the full php tags. <?php ?> it's not that much more effort to type the two additional character.

For debugging purposes, I like to use this at the top (or bottom) of my pages, when testing form or session transfers.

<pre>
<?php print_r($_POST); ?>
</pre>

This allows you to see exactly what is getting passed through, so it's easier to see what and where things are failing.

Donny Bahama
08-24-2009, 12:22 AM
Cool! Thanks for that!