m_tyhurst2002 Posted August 19, 2007 Share Posted August 19, 2007 Hello! I have a form at: http://invent-designs.com/ If you don't fill in the fields it posts an error to the right of the text field that you have not entered. When everything is entered it sends the form to my email and at the very top of the page it posts "Thanks for your interest in our services Mark Tyhurst! We will reply within 24-48 hours. Click here to go back". My question is, does anyone know how can I make that message appear right above the form instead of at the very top of the page? I would appreciate any help. Here is my code: <?php if (isset($_POST['submit'])) { $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $confirmemail = $_POST['confirmemail']; $projecttype = $_POST['projecttype']; $projectdetail = $_POST['projectdetail']; if ( !empty($firstname) && !empty($firstname) && !empty($email) && !empty($confirmemail) && !empty($projecttype) && !empty($projectdetail)) { if(isset($_POST['submit'])) { $to = "mark@invent-designs.com"; $subject = "Submission from www.invent-designs.com"; $firstname_field = $_POST['firstname']; $lastname_field = $_POST['lastname']; $email_field = $_POST['email']; $projecttype_field = $_POST['projecttype']; $projectdetail_field = $_POST['projectdetail']; $body = "From:\n First Name: $firstname_field\n Last Name: $lastname_field\n E-Mail: $email_field\n Project Type: $projecttype_field\n Project Details: $projectdetail_field"; echo '<span class="style6"><div align="center"><br>Thanks for your interest in our services '; echo $_POST['firstname']." ".$_POST['lastname']."! We will reply within 24-48 hours. "; echo '<a href="">Click here to go back</a></b></div></span>'; mail($to, $subject, $body, "From:$email_field"); } else { echo "blarg!"; } } else { $error = true; } } ?> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- .style2 {font-size: 10px} .style4 {font-family: Arial, Helvetica, sans-serif; font-size: 10px; } .style6 {font-family: Arial, Helvetica, sans-serif; font-size: 14px; } body { background-color: #A40000; margin-left: 0px; margin-top: 0px; } a:link { color: #000000; text-decoration: underline; } a:visited { text-decoration: underline; color: #666666; } a:hover { text-decoration: none; color: #666666; } a:active { text-decoration: underline; color: #000000; } --> </style> </head> <body> <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <table width="680" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <th scope="col"><img src="splash.gif"><br> <br></th> </tr> <tr> <th scope="row"><span class="style6">Fill out the from below and we can email you a quote based on the <br> description of your project below...<br> </span></th> </tr> </table> <table width="680" border="0" align="center" cellpadding="0" cellspacing="0"> <tr align="left" valign="top"> <th width="80" scope="row"><div align="left" class="style4">First Name </div></th> <th width="600" scope="row"> <div align="left"> <input name="firstname" type="text" class="style2" id="firstname" value="<?php echo $firstname; ?>" size="37"> <span class="style4"> <?php if ( $error==true && empty($firstname) ) { echo 'Error! Please enter a first name.<br>'; } ?> </span></div></th> </tr> <tr align="left" valign="top"> <th scope="row"><div align="left" class="style4">Last Name </div></th> <th scope="row"><div align="left" class="style2"> <input name="lastname" type="text" class="style2" id="lastname" value="<?php echo $lastname; ?>" size="37"> <span class="style4"> <?php if ( $error==true && empty($lastname) ) { echo 'Error! Please enter a last name.<br>'; } ?> </span></div></th> </tr> <tr align="left" valign="top"> <th scope="row"><div align="left" class="style4">Email </div></th> <th scope="row"><div align="left" class="style2"> <input name="email" type="text" class="style2" id="email" value="<?php echo $email; ?>" size="37"> <span class="style4"> <?php if ( $error==true && empty($email) ) { echo 'Error! Please enter a valid email address.<br>'; } ?> </span></div></th> </tr> <tr align="left" valign="top"> <th scope="row"><div align="left" class="style4">Confirm Email </div></th> <th scope="row"><div align="left" class="style2"> <input name="confirmemail" type="text" class="style2" id="confirmemail" value="<?php echo $confirmemail; ?>" size="37"> <span class="style4"> <?php if ( $error==true && empty($confirmemail) ) { echo 'Error! Please re- enter a valid email address.<br>'; } ?> </span></div></th> </tr> <tr align="left" valign="top"> <th scope="row"><div align="left" class="style4">Project Type </div></th> <th scope="row"><div align="left" class="style2"> <select name="projecttype" id="projecttype" class="style2"> <option value="0" <?php if (empty($yearofbirth)) echo "selected"; ?>>- Select -</option> <option value="Logo Creation">Logo Creation</option> <option value="Flash Intro/Design">Flash Intro/Design</option> <option value="Website Creation">Website Creation</option> <option value="Website Re-Design">Website Re-Design</option> <option value="Print Design (flyer, business card, ect.)">Print Design (flyer, business card, ect.)</option> </select> <span class="style4"> <?php if ( $error==true && empty($projecttype) ) { echo 'Error! Please select project type.<br>'; } ?> </span></div></th> </tr> <tr align="left" valign="top"> <th scope="row"><div align="left" class="style4">Project Details </div></th> <th valign="top" scope="row"><div align="left" class="style2"> <textarea name="projectdetail" cols="45" class="style2" id="projectdetail"><?php echo $projectdetail; ?></textarea> <span class="style4"> <?php if ( $error==true && empty($projectdetail) ) { echo 'Error! Please enter complete details of your project.<br>'; } ?> </span></div></th> </tr> <tr> <th colspan="2" scope="row"> <div align="left"> <input type="submit" name="submit" value="Submit"> </table> </form> </body> </html> Thanks guys... Quote Link to comment https://forums.phpfreaks.com/topic/65690-solved-help-with-php-code/ Share on other sites More sharing options...
MadTechie Posted August 19, 2007 Share Posted August 19, 2007 quick update <?php if (isset($_POST['submit'])) { $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $confirmemail = $_POST['confirmemail']; $projecttype = $_POST['projecttype']; $projectdetail = $_POST['projectdetail']; if ( !empty($firstname) && !empty($firstname) && !empty($email) && !empty($confirmemail) && !empty($projecttype) && !empty($projectdetail)) { if(isset($_POST['submit'])) { $to = "mark@invent-designs.com"; $subject = "Submission from www.invent-designs.com"; $firstname_field = $_POST['firstname']; $lastname_field = $_POST['lastname']; $email_field = $_POST['email']; $projecttype_field = $_POST['projecttype']; $projectdetail_field = $_POST['projectdetail']; $body = "From:\n First Name: $firstname_field\n Last Name: $lastname_field\n E-Mail: $email_field\n Project Type: $projecttype_field\n Project Details: $projectdetail_field"; } else { echo "blarg!"; } } else { $error = true; } } ?> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- .style2 {font-size: 10px} .style4 {font-family: Arial, Helvetica, sans-serif; font-size: 10px; } .style6 {font-family: Arial, Helvetica, sans-serif; font-size: 14px; } body { background-color: #A40000; margin-left: 0px; margin-top: 0px; } a:link { color: #000000; text-decoration: underline; } a:visited { text-decoration: underline; color: #666666; } a:hover { text-decoration: none; color: #666666; } a:active { text-decoration: underline; color: #000000; } --> </style> </head> <body> <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <table width="680" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <th scope="col"><img src="splash.gif"> </th> </tr> <tr> <th scope="row"><span class="style6">Fill out the from below and we can email you a quote based on the description of your project below... </span></th> </tr> </table> <table width="680" border="0" align="center" cellpadding="0" cellspacing="0"> <tr align="left" valign="top"> <th width="80" scope="row"><div align="left" class="style4">First Name </div></th> <th width="600" scope="row"> <div align="left"> <input name="firstname" type="text" class="style2" id="firstname" value="<?php echo $firstname; ?>" size="37"> <span class="style4"> <?php if ( $error==true && empty($firstname) ) { echo 'Error! Please enter a first name. '; } ?> </span></div></th> </tr> <tr align="left" valign="top"> <th scope="row"><div align="left" class="style4">Last Name </div></th> <th scope="row"><div align="left" class="style2"> <input name="lastname" type="text" class="style2" id="lastname" value="<?php echo $lastname; ?>" size="37"> <span class="style4"> <?php if ( $error==true && empty($lastname) ) { echo 'Error! Please enter a last name. '; } ?> </span></div></th> </tr> <tr align="left" valign="top"> <th scope="row"><div align="left" class="style4">Email </div></th> <th scope="row"><div align="left" class="style2"> <input name="email" type="text" class="style2" id="email" value="<?php echo $email; ?>" size="37"> <span class="style4"> <?php if ( $error==true && empty($email) ) { echo 'Error! Please enter a valid email address. '; } ?> </span></div></th> </tr> <tr align="left" valign="top"> <th scope="row"><div align="left" class="style4">Confirm Email </div></th> <th scope="row"><div align="left" class="style2"> <input name="confirmemail" type="text" class="style2" id="confirmemail" value="<?php echo $confirmemail; ?>" size="37"> <span class="style4"> <?php if ( $error==true && empty($confirmemail) ) { echo 'Error! Please re- enter a valid email address. '; } ?> </span></div></th> </tr> <tr align="left" valign="top"> <th scope="row"><div align="left" class="style4">Project Type </div></th> <th scope="row"><div align="left" class="style2"> <select name="projecttype" id="projecttype" class="style2"> <option value="0" <?php if (empty($yearofbirth)) echo "selected"; ?>>- Select -</option> <option value="Logo Creation">Logo Creation</option> <option value="Flash Intro/Design">Flash Intro/Design</option> <option value="Website Creation">Website Creation</option> <option value="Website Re-Design">Website Re-Design</option> <option value="Print Design (flyer, business card, ect.)">Print Design (flyer, business card, ect.)</option> </select> <span class="style4"> <?php if ( $error==true && empty($projecttype) ) { echo 'Error! Please select project type. '; } ?> </span></div></th> </tr> <tr align="left" valign="top"> <th scope="row"><div align="left" class="style4">Project Details </div></th> <th valign="top" scope="row"><div align="left" class="style2"> <textarea name="projectdetail" cols="45" class="style2" id="projectdetail"><?php echo $projectdetail; ?></textarea> <span class="style4"> <?php if ( $error==true && empty($projectdetail) ) { echo 'Error! Please enter complete details of your project. '; } ?> </span></div></th> </tr> <tr> <th colspan="2" scope="row"> <div align="left"> <input type="submit" name="submit" value="Submit"> </table> </form> <?php if(isset($_POST['submit'])) { echo '<span class="style6"><div align="center"> Thanks for your interest in our services '; echo $_POST['firstname']." ".$_POST['lastname']."! We will reply within 24-48 hours. "; echo '<a href="">Click here to go back[/url]</div></span>'; } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/65690-solved-help-with-php-code/#findComment-328078 Share on other sites More sharing options...
m_tyhurst2002 Posted August 19, 2007 Author Share Posted August 19, 2007 This didn't seem to work. If you did not fill out the form and tried to submit it it wouls post the error of the field and allso the message at the bottom. The message is where I want it now but comes up before the for is submitted. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/65690-solved-help-with-php-code/#findComment-328114 Share on other sites More sharing options...
MadTechie Posted August 19, 2007 Share Posted August 19, 2007 OK done <?php $Checked = false; if (isset($_POST['submit'])) { $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $confirmemail = $_POST['confirmemail']; $projecttype = $_POST['projecttype']; $projectdetail = $_POST['projectdetail']; if ( !empty($firstname) && !empty($firstname) && !empty($email) && !empty($confirmemail) && !empty($projecttype) && !empty($projectdetail)) { if(isset($_POST['submit'])) { $to = "mark@invent-designs.com"; $subject = "Submission from www.invent-designs.com"; $firstname_field = $_POST['firstname']; $lastname_field = $_POST['lastname']; $email_field = $_POST['email']; $projecttype_field = $_POST['projecttype']; $projectdetail_field = $_POST['projectdetail']; $body = "From:\n First Name: $firstname_field\n Last Name: $lastname_field\n E-Mail: $email_field\n Project Type: $projecttype_field\n Project Details: $projectdetail_field"; $Checked = true;//Checked mail($to, $subject, $body, "From:$email_field"); } else { echo "blarg!"; } } else { $error = true; } } ?> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- .style2 {font-size: 10px} .style4 {font-family: Arial, Helvetica, sans-serif; font-size: 10px; } .style6 {font-family: Arial, Helvetica, sans-serif; font-size: 14px; } body { background-color: #A40000; margin-left: 0px; margin-top: 0px; } a:link { color: #000000; text-decoration: underline; } a:visited { text-decoration: underline; color: #666666; } a:hover { text-decoration: none; color: #666666; } a:active { text-decoration: underline; color: #000000; } --> </style> </head> <body> <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <table width="680" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <th scope="col"><img src="splash.gif"><br> <br></th> </tr> <tr> <th scope="row"><span class="style6">Fill out the from below and we can email you a quote based on the <br> description of your project below...<br> </span></th> </tr> </table> <table width="680" border="0" align="center" cellpadding="0" cellspacing="0"> <tr align="left" valign="top"> <th width="80" scope="row"><div align="left" class="style4">First Name </div></th> <th width="600" scope="row"> <div align="left"> <input name="firstname" type="text" class="style2" id="firstname" value="<?php echo $firstname; ?>" size="37"> <span class="style4"> <?php if ( $error==true && empty($firstname) ) { echo 'Error! Please enter a first name.<br>'; } ?> </span></div></th> </tr> <tr align="left" valign="top"> <th scope="row"><div align="left" class="style4">Last Name </div></th> <th scope="row"><div align="left" class="style2"> <input name="lastname" type="text" class="style2" id="lastname" value="<?php echo $lastname; ?>" size="37"> <span class="style4"> <?php if ( $error==true && empty($lastname) ) { echo 'Error! Please enter a last name.<br>'; } ?> </span></div></th> </tr> <tr align="left" valign="top"> <th scope="row"><div align="left" class="style4">Email </div></th> <th scope="row"><div align="left" class="style2"> <input name="email" type="text" class="style2" id="email" value="<?php echo $email; ?>" size="37"> <span class="style4"> <?php if ( $error==true && empty($email) ) { echo 'Error! Please enter a valid email address.<br>'; } ?> </span></div></th> </tr> <tr align="left" valign="top"> <th scope="row"><div align="left" class="style4">Confirm Email </div></th> <th scope="row"><div align="left" class="style2"> <input name="confirmemail" type="text" class="style2" id="confirmemail" value="<?php echo $confirmemail; ?>" size="37"> <span class="style4"> <?php if ( $error==true && empty($confirmemail) ) { echo 'Error! Please re- enter a valid email address.<br>'; } ?> </span></div></th> </tr> <tr align="left" valign="top"> <th scope="row"><div align="left" class="style4">Project Type </div></th> <th scope="row"><div align="left" class="style2"> <select name="projecttype" id="projecttype" class="style2"> <option value="0" <?php if (empty($yearofbirth)) echo "selected"; ?>>- Select -</option> <option value="Logo Creation">Logo Creation</option> <option value="Flash Intro/Design">Flash Intro/Design</option> <option value="Website Creation">Website Creation</option> <option value="Website Re-Design">Website Re-Design</option> <option value="Print Design (flyer, business card, ect.)">Print Design (flyer, business card, ect.)</option> </select> <span class="style4"> <?php if ( $error==true && empty($projecttype) ) { echo 'Error! Please select project type.<br>'; } ?> </span></div></th> </tr> <tr align="left" valign="top"> <th scope="row"><div align="left" class="style4">Project Details </div></th> <th valign="top" scope="row"><div align="left" class="style2"> <textarea name="projectdetail" cols="45" class="style2" id="projectdetail"><?php echo $projectdetail; ?></textarea> <span class="style4"> <?php if ( $error==true && empty($projectdetail) ) { echo 'Error! Please enter complete details of your project.<br>'; } ?> </span></div></th> </tr> <tr> <th colspan="2" scope="row"> <div align="left"> <input type="submit" name="submit" value="Submit"> </table> </form> <?php if($Checked) { echo '<span class="style6"><div align="center"><br>Thanks for your interest in our services '; echo $_POST['firstname']." ".$_POST['lastname']."! We will reply within 24-48 hours. "; echo '<a href="">Click here to go back</a></b></div></span>'; } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/65690-solved-help-with-php-code/#findComment-328117 Share on other sites More sharing options...
m_tyhurst2002 Posted August 19, 2007 Author Share Posted August 19, 2007 Thanks soooo much! I do appreciate it!!! Quote Link to comment https://forums.phpfreaks.com/topic/65690-solved-help-with-php-code/#findComment-328190 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.