benanamen Posted October 23, 2015 Share Posted October 23, 2015 (edited) Your complicating a simple matter. Get rid of those nested tables! <?php error_reporting(-1); ini_set('display_errors', 1); if ($_POST) { $error['fname'] = empty($_POST['fname']) ? "<span class='error'>Please enter your last name.</span>" : ''; $error['lname'] = empty($_POST['lname']) ? "<span class='error'>Please enter your last name.</span>" : ''; } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <style type="text/css"> </style> <title>Untitled Document</title> </head> <body> <table id="contactForm" border cellspacing="20"> <form method="post"> <tr> <td class="question" >First Name:<br /> <input type="text" name="fname" size="15" value ="<?php echo !empty($_POST['fname']) ? $_POST['fname'] : '';?>" > <?php echo !empty($error['fname']) ? $error['fname'] : '';?> </td> <td class="question">Last Name<br /> <input type="text" name="lname" size="20"><?php echo !empty($error['lname']) ? $error['lname'] : '';?> </td> <td class="question">Organization's Name:<br /> <input type="text" name="orgName" size="15" maxlength="50"> </td> </tr> <tr> <td class="question">Street Address: <br /> <input type="text" name="address" size="15" maxlength="50"> </td> <td class="question">City: <br /> <input type="text" name="city" size="10" maxlength="25"> </td> <td class="question"> State: <br /> <select name = "state" value=""> <option value ="Please choose a state"> Please choose a state </option> <?php //states($state); ?> </select> </td> <td class="question">Zipcode:<br /> <input type="number" name="zipcode" size="5" maxlength="5"> </td> </tr> <tr> <td>Phone Number: <br />(including area code) <br /> <input type="text" name="phone" size="10" maxlength="10"> </td> <td>Fax Number: <br />(including area code) <br /> <input type="text" name="fax" size="10" maxlength="10"> </td> </tr> <tr> <td>Email:<br /> <input type="text" name="email" /> </td> <td>Confirm Email:<br /> <input type="text" name="ConfirmEmail" /> </td> </tr> <tr> <td>What would you like help with? </td> <td> <table id="projectOptions"> <tr span=2> <td><input type="checkbox" name="SocialMedia">Social Media </td> <td><input type="checkbox" name="WebContentManagement">Web Content Management </td> </tr> <tr> <td><input type="checkbox" name="MarketingMaterials">Marketing Material Creation </td> <td><input type="checkbox" name="SEO">SEO (Search Engine Optimization) </td> </tr> <tr> <td><input type="checkbox" name="VideoEditing"> Video Editing </td> <td><input type="checkbox" name="WebDesign">Web Design </td> </tr> </table> </td> <tr> <td>Overview about the project: </td> <td><textarea></textarea></td> </tr> <tr> <td>If you are not a robot, what year is it? </td> <td><input type="text" name="year" size="4" maxlength="4"> </tr> <tr> <td><input type="submit" name="submit" value="Contact Me!"> </td> <td><input type="reset"></td> </tr> </form> </table> </body> </html> Edited October 23, 2015 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/298756-sticky-form/page/2/#findComment-1524103 Share on other sites More sharing options...
mindapolis Posted October 23, 2015 Author Share Posted October 23, 2015 I was going to get rid of the tables after I resolve this problem. Quote Link to comment https://forums.phpfreaks.com/topic/298756-sticky-form/page/2/#findComment-1524104 Share on other sites More sharing options...
benanamen Posted October 23, 2015 Share Posted October 23, 2015 (edited) Forget my last post. Found an issue. Use this code. Problem solved. <?php error_reporting(-1); ini_set('display_errors', 1); if ($_POST) { $error = array(); if (empty($_POST['fname'])) { $error['fname'] = "<span class='error'>Please enter your first name.</span>"; } if (empty($_POST['lname'])) { $error['lname'] = "<span class='error'>Please enter your last name.</span>"; } if (!count($error)) { //Do something die("Do Something here"); } } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <style type="text/css"> </style> <title>Untitled Document</title> </head> <body> <table id="contactForm" border cellspacing="20"> <form method="post"> <tr> <td class="question" >First Name:<br /> <input type="text" name="fname" size="15" value ="<?php echo !empty($_POST['fname']) ? $_POST['fname'] : '';?>" > <?php echo !empty($error['fname']) ? $error['fname'] : '';?> </td> <td class="question">Last Name<br /> <input type="text" name="lname" size="20"><?php echo !empty($error['lname']) ? $error['lname'] : '';?> </td> <td class="question">Organization's Name:<br /> <input type="text" name="orgName" size="15" maxlength="50"> </td> </tr> <tr> <td class="question">Street Address: <br /> <input type="text" name="address" size="15" maxlength="50"> </td> <td class="question">City: <br /> <input type="text" name="city" size="10" maxlength="25"> </td> <td class="question"> State: <br /> <select name = "state" value=""> <option value ="Please choose a state"> Please choose a state </option> <?php //states($state); ?> </select> </td> <td class="question">Zipcode:<br /> <input type="number" name="zipcode" size="5" maxlength="5"> </td> </tr> <tr> <td>Phone Number: <br />(including area code) <br /> <input type="text" name="phone" size="10" maxlength="10"> </td> <td>Fax Number: <br />(including area code) <br /> <input type="text" name="fax" size="10" maxlength="10"> </td> </tr> <tr> <td>Email:<br /> <input type="text" name="email" /> </td> <td>Confirm Email:<br /> <input type="text" name="ConfirmEmail" /> </td> </tr> <tr> <td>What would you like help with? </td> <td> <table id="projectOptions"> <tr span=2> <td><input type="checkbox" name="SocialMedia">Social Media </td> <td><input type="checkbox" name="WebContentManagement">Web Content Management </td> </tr> <tr> <td><input type="checkbox" name="MarketingMaterials">Marketing Material Creation </td> <td><input type="checkbox" name="SEO">SEO (Search Engine Optimization) </td> </tr> <tr> <td><input type="checkbox" name="VideoEditing"> Video Editing </td> <td><input type="checkbox" name="WebDesign">Web Design </td> </tr> </table> </td> <tr> <td>Overview about the project: </td> <td><textarea></textarea></td> </tr> <tr> <td>If you are not a robot, what year is it? </td> <td><input type="text" name="year" size="4" maxlength="4"> </tr> <tr> <td><input type="submit" name="submit" value="Contact Me!"> </td> <td><input type="reset"></td> </tr> </form> </table> </body> </html> Edited October 23, 2015 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/298756-sticky-form/page/2/#findComment-1524107 Share on other sites More sharing options...
mindapolis Posted October 23, 2015 Author Share Posted October 23, 2015 Still no go. If I leave the fname field blank and click submit, no error appears saying they need to put their first name. Quote Link to comment https://forums.phpfreaks.com/topic/298756-sticky-form/page/2/#findComment-1524111 Share on other sites More sharing options...
benanamen Posted October 23, 2015 Share Posted October 23, 2015 (edited) It sure does. Look next to the firstname input box and the last name box if you leave that blank and make sure you are using the code I last posted. And make sure you are doing this on a webserver, not your desktop and that the filename ends with .php. Edited October 23, 2015 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/298756-sticky-form/page/2/#findComment-1524112 Share on other sites More sharing options...
mindapolis Posted October 23, 2015 Author Share Posted October 23, 2015 Yes it works now! I had to clear the cache. Thanks so much for the help! Quote Link to comment https://forums.phpfreaks.com/topic/298756-sticky-form/page/2/#findComment-1524135 Share on other sites More sharing options...
benanamen Posted October 23, 2015 Share Posted October 23, 2015 Don't use Internet Explorer for development. It caches everything. You will never be sure if you are looking at the current page. Quote Link to comment https://forums.phpfreaks.com/topic/298756-sticky-form/page/2/#findComment-1524136 Share on other sites More sharing options...
maxxd Posted October 23, 2015 Share Posted October 23, 2015 Don't use Internet Explorer. Just making the previous statement a bit more specific. Quote Link to comment https://forums.phpfreaks.com/topic/298756-sticky-form/page/2/#findComment-1524147 Share on other sites More sharing options...
benanamen Posted October 23, 2015 Share Posted October 23, 2015 (edited) LOL @maxxd Just making the previous statement a ALOT more specific. NEVER use Internet Explorer If I could uninstall it I would. Edited October 23, 2015 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/298756-sticky-form/page/2/#findComment-1524152 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.