www.webdeveloper.com
Results 1 to 7 of 7

Thread: Why won't my form post?

  1. #1
    Join Date
    Mar 2009
    Posts
    16

    Why won't my form post?

    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.

    HTML Code:
    	<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>

  2. #2
    Join Date
    Mar 2009
    Posts
    16

    Resolved

    I moved the <h3> block outside the form and it works. I didn't realize that was a no-no.

  3. #3
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    Quote Originally Posted by Donny Bahama View Post
    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:
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  4. #4
    Join Date
    Mar 2009
    Posts
    16
    Quote Originally Posted by Charles View Post
    It's not; something else must be going on there. A couple of other things that are a problem but not that problem:
    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"?

  5. #5
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    Because then the form would have a submit method and a submit property and sometimes that can confuse the browser.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  6. #6
    Join Date
    Jul 2007
    Location
    Wisconsin
    Posts
    468
    Code:
    <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:

    PHP Code:
    <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.

    PHP Code:
    <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.

  7. #7
    Join Date
    Mar 2009
    Posts
    16
    Cool! Thanks for that!

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles