chomick Posted October 10, 2007 Share Posted October 10, 2007 Hello, I have a PHP contact script located at http://www.chrishomick.com/contact3.php The code is the following: <?php // Configuration Start \\ $YourEmail = "[email protected]"; // Configuration End \\ if($Submit) { if(empty($email) || empty($name) || empty($message)) { echo "You forgot to enter some required fields. Please go back and try again."; } elseif(!eregi('^([._a-z0-9-]+[._a-z0-9-]*)@(([a-z0-9-]+\.)*([a-z0-9-]+)(\.[a-z]{2,3})?)$', $email)) { echo "The e-mail is not valid. Please go back and try again."; } else { $Message = "$name has contacted you using your online form. The message is below.\n\n***************\n$message\n***************\n\nIP of sender: $_SERVER[REMOTE_ADDR]\nE-mail of sender: $email"; $headers = 'From: ' . $email . "\r\n" . 'Reply-To: ' . $email . "\r\n" . 'Subject: ' . $subject . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($YourEmail, $Subject, stripslashes($Message), $headers); echo "The form has been sent and you shall receive a reply shortly."; } } else { echo '<form name="cf" method="post" action=""> <table width="283" border="0" cellpadding="2" cellspacing="1" class="content"> <tr> <td width="2%" align="right" valign="middle"><strong><font color="#CCCCCC">*</font></strong></td> <td width="27%"><strong>Name:</strong></td> <td width="71%"><input name="name" type="text" size="30"></td> </tr> <tr> <td> </td> <td><strong>Phone:</strong></td> <td><input name="phone" type="text" size="20"></td> </tr> <tr> <td align="right" valign="middle"><strong><font color="#CCCCCC">*</font></strong></td> <td><strong>Email:</strong></td> <td><input name="email" type="text" size="30"></td> </tr> <tr> <td align="right" valign="middle"><strong><font color="#CCCCCC">*</font></strong></td> <td><strong>Subject:</strong></td> <td><input name="subject" type="text" size="30"></td> </tr> <tr> <td align="right" valign="middle"><strong><font color="#CCCCCC">*</font></strong></td> <td><strong>Message:</strong></td> <td><textarea name="message" cols="28" rows="10"></textarea></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Send Message"><input type="hidden" name="config" value="0"></td> </tr> </table> </form>'; } ?> When you click submit the following two messages appear on the site (which is exactly what I want!) 1) You forgot to enter some required fields. Please go back and try again. OR 2) The form has been sent and you shall receive a reply shortly. When these messages appear, the form instructions are still there-- Please use the following form to contact me. I will be in touch with you as soon as possible. Fields marked with an asterisk (*) are required. My question is, how do I remove this text when someone clicks the submit button? Link to comment https://forums.phpfreaks.com/topic/72599-solved-php-form-question-please-help/ Share on other sites More sharing options...
MadTechie Posted October 10, 2007 Share Posted October 10, 2007 why not just move the text to the same place as the form! //snip... else { echo '-->HERE<---<form name="cf" method="post" action=""> <table width="283" border="0" cellpadding="2" cellspacing="1" class="content"> //snip... Link to comment https://forums.phpfreaks.com/topic/72599-solved-php-form-question-please-help/#findComment-366106 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.