barrowvian Posted June 4, 2010 Share Posted June 4, 2010 <?php // USER ENTERED VARIABLES $name_field = isset($_POST['name']) ? trim($_POST['name']) : ''; $email_field = isset($_POST['email']) ? trim($_POST['email']) : ''; $message = isset($_POST['message']) ? trim($_POST['message']) : ''; // USER ENTERED VALIDATION if (!preg_match("/^[a-zA-Z\-\s]{2,40}$/", $name_field)) $errorName_Field = true; if (!preg_match('/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/', $email_field)) $errorEmail = true; if (strlen($message) < 5 ) $errorMessage = true; if (strlen($message) > 250 ) $errorMessage1 = true; if (empty($_SESSION['6_letters_code'] ) || strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0) $errorCaptcha = true; // FORM FUNCTION function showForm($errorName_Field=false, $errorEmail=false, $errorMessage=false, $errorMessage1=false, $errorCaptcha=false){ if ($errorName_Field) $errorTextName_Field = "<font color=\"red\">Invalid Entry (A-Z only)</font>"; if ($errorEmail) $errorTextEmail = "<font color=\"red\">Invalid Entry</font>"; if ($errorMessage) $errorTextMessage = "<font color=\"red\">Message must be over 5 characters</font>"; if ($errorMessage1) $errorTextMessage1 = "<font color=\"red\">Message must be under 250 characters</font>"; if ($errorCaptcha) $errorTextCaptcha = "<font color=\"red\">Invalid Entry</font>"; echo '<FORM name="email" action="contact.php" method="post" >'; echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">'; //NAME echo '<tr> <td width="10%" align="left" valign="top">Name:</td> <td width="20%" align="left"><input type="text" name="name" size="38" /></td> <td width="70%" align="left">'; if ($errorName_Field) echo "$errorTextName_Field"; echo '</td>'; echo '</tr>'; //EMAIL echo '<tr> <td width="10%" align="left" valign="top">Email:</td> <td width="20%" align="left"><input type="text" name="email" size="38" /></td> <td width="70%" align="left">'; if ($errorEmail) echo "$errorTextEmail"; echo '</td>'; echo '</tr>'; //SUBJECT DROPDOWN echo '<tr> <td width="10%" align="left" valign="top">Subject:</td> <td width="20%" align="left"> <select size="1" name="drop_down"> <option>General Enquiries</option> <option>Sales Enquiries</option> <option>Press Enquiries</option> </select></td> <td width="70%" align="left"></td> </tr>'; //MESSAGE echo '<tr> <td width="10%" align="left" valign="top">Message:</td> <td width="20%"align="left"><textarea rows="5" name="message" cols="30"></textarea></td> <td width="70%" align="left">'; if ($errorMessage) echo "$errorTextMessage"; if ($errorMessage1) echo "$errorTextMessage1"; echo '</td>'; echo '</tr>'; //CAPTCHA echo '<tr>'; echo '<td width="10%" align="left" valign="top"></td>'; echo '<td width="20%" align="left"><img src="captcha_code_file.php?rand=' . rand() . '" id=\'captchaimg\' > <br />'; echo '<label for=\'message\'>Enter the code above here :</label><br />'; echo '<input id="6_letters_code" name="6_letters_code" type="text"><br />'; echo '<small>Can\'t read the image? click <a href=\'javascript: refreshCaptcha();\'>here</a> to refresh</small> </p></td>'; echo '<td width="70%" align="left">'; if ($errorCaptcha) echo "$errorTextCaptcha"; echo '</td>'; echo '</tr>'; // SUBMIT AND END OF FORM echo '<tr> <td width="10%" align="left" valign="top"></td> <td width="20%"align="left"><input type="submit" name="SubmitForm" value="Sumbit"></td> <td width="10%" align="left"></td> </tr>'; echo '<script language=\'JavaScript\' type=\'text/javascript\'> function refreshCaptcha() { var img = document.images[\'captchaimg\']; img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000; } </script>'; } if (!isset($_POST['SubmitForm'])) { showForm(); } else { session_start(); //Init error variables $errorName_Field = false; $errorEmail=false; $errorMessage=false; $errorMessage1=false; $errorCaptcha=false; $name_field = isset($_POST['name']) ? trim($_POST['name']) : ''; $email_field = isset($_POST['email']) ? trim($_POST['email']) : ''; $message = isset($_POST['message']) ? trim($_POST['message']) : ''; $dropdown = $_POST['drop_down']; if (!preg_match("/^[a-zA-Z\-\s]{2,40}$/", $name_field)) $errorName_Field = true; if (!preg_match('/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/', $email_field)) $errorEmail = true; if (strlen($message) < 5 ) $errorMessage = true; if (strlen($message) > 250 ) $errorMessage1 = true; if (empty($_SESSION['6_letters_code'] ) || strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0) $errorCaptcha = true; // Display the form again as there was an error if ($errorName_Field || $errorEmail || $errorMessage || $errorMessage1 || $errorCaptcha){ showForm($errorName_Field,$errorEmail,$errorMessage,$errorMessage1,$errorCaptcha); } else { //send the email to location based upon result of dropdown menu if($dropdown == "General Enquiries"){ $to = "ENTER EMAIL HERE"; $subject = "General Enquiry"; $body = "From:" . htmlspecialchars($name_field) . "\n E-Mail:" . htmlspecialchars($email_field) . "\n Message:" . htmlspecialchars($message); echo "Your email has been submitted,<strong> " . htmlspecialchars($name_field) . "</strong>. I aim to reply to all emails within 48 hours."; mail($to, $subject, $body); }elseif($dropdown == "Sales Enquiries"){ $to = "ENTER EMAIL HERE"; $subject = "Sales Enquiry"; $body = "From:" . htmlspecialchars($name_field) . "\n E-Mail:" . htmlspecialchars($email_field) . "\n Message:" . htmlspecialchars($message); echo "Your email has been submitted,<strong> " . htmlspecialchars($name_field) . "</strong>. I aim to reply to all emails within 48 hours."; mail($to, $subject, $body); }elseif($dropdown == "Press Enquiries"){ $to = "ENTER EMAIL HERE"; $subject = "Press Enquiry"; $body = "From:" . htmlspecialchars($name_field) . "\n E-Mail:" . htmlspecialchars($email_field) . "\n Message:" . htmlspecialchars($message); echo "Your email has been submitted,<strong> " . htmlspecialchars($name_field) . "</strong>. I aim to reply to all emails within 48 hours."; mail($to, $subject, $body); } } } ?> Right, I have this contact page that loops itself and displays the appropriate error messages. My problem isnt with the actual functionality of the contact form but with the footer. The footer is very simple and only includes <div id="footer"> <div class="container"> <div class="footer_column long"> <center>All rights reserved. I am not responsible for the content of external sites. <a href="contact.php">Terms and Conditions</a></center> </div> </div> </div> </body> </html> <?php mysql_close($connection); ?> When I include this footer it doesnt appear at the bottom of the page like it should, it does initially, but upon submission it appears half way up the screen. Quote Link to comment https://forums.phpfreaks.com/topic/203897-footer-moving-around/ 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.