Jump to content

sticky form


mindapolis

Recommended Posts

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 by benanamen
Link to comment
Share on other sites

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 by benanamen
Link to comment
Share on other sites

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 by benanamen
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.