HNX Posted December 8, 2007 Share Posted December 8, 2007 ok theres oi problem with my contact us form here is the link to it: http://www.phpfreaks.com/forums/index.php/topic,171104.0.html what i want to do is that instead of it going to a blank page after i fill all the information and press submit but instead i want it to just load in the web page and tell me the same message : "your message has been received" thanks, HNX Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted December 8, 2007 Share Posted December 8, 2007 Try This: <?php $msg="Please Fill In Form Fields Below"; // Initialize Variable if(isset($_POST["Submit"])) { $name = stripslashes($_POST['$name']); $email = stripslashes($_POST['$email']); $subject = stripslashes($_POST['$subject']); $text = stripslashes($_POST['$text']); // simple validation if ($name == NULL) { $msg="Enter Your Name"; exit; } else if ($email == NULL) // you also may want to use a regex validation { $msg="Enter Valid Email Address"; exit; } else if ($subject == NULL) { $msg="Enter Subject"; exit; } else if ($text == NULL) { $msg="Enter Comments/Text"; exit; } else { $msg="Thank you for your interest, your e-mail was sent."; } $name = stripslashes($name); $email = stripslashes($email); $subject = stripslashes($subject); $text = stripslashes($text); mail(' myemail@hotmail.com',$subject,$text,"From: $name <$email>"); echo "$msg<br><br>\n"; } ?> <form method="post" name="form1" id="form1"> <table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr> <td width="16%"><span class="style108">Subject</span></td> <td width="2%"><span class="style104">:</span></td> <td width="82%"><input name="subject" type="text" id="subject" size="50" /></td> </tr> <tr> <td><span class="style108">Message</span></td> <td><span class="style104">:</span></td> <td><textarea name="detail" cols="50" rows="4" id="detail"></textarea></td> </tr> <tr> <td><span class="style108">Name</span></td> <td><span class="style104">:</span></td> <td><input name="name" type="text" id="name" size="50" /></td> </tr> <tr> <td><span class="style108">Email</span></td> <td><span class="style104">:</span></td> <td><input name="customer_mail" type="text" id="customer_mail" size="50" /></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" /></td> </tr> </table> </form> PS: You really should not double post. Quote Link to comment Share on other sites More sharing options...
HNX Posted December 9, 2007 Author Share Posted December 9, 2007 alright sry Loll but yo guys where is Joey aka phpsensei ????????? Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted December 9, 2007 Share Posted December 9, 2007 I did not test my first code - it was flawed - try this out instead - I think it will do the trick for you: <?php @$subject = stripslashes($_POST['subject']); @$detail = stripslashes($_POST['detail']); @$name = stripslashes($_POST['name']); @$customer_mail = stripslashes($_POST['customer_mail']); function theForm() { echo '<form method="post" name="form1" id="form1"> <table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr> <td width="16%"><span class="style108">Subject</span></td> <td width="2%"><span class="style104">:</span></td> <td width="82%"><input name="subject" type="text" id="subject" size="50" value="'. $_POST['subject'] .'" /></td> </tr> <tr> <td><span class="style108">Message</span></td> <td><span class="style104">:</span></td> <td><textarea name="detail" cols="50" rows="4" id="detail">'. $_POST['detail'] .'</textarea></td> </tr> <tr> <td><span class="style108">Name</span></td> <td><span class="style104">:</span></td> <td><input name="name" type="text" id="name" size="50" value="'. $_POST['name'] .'"/></td> </tr> <tr> <td><span class="style108">Email</span></td> <td><span class="style104">:</span></td> <td><input name="customer_mail" type="text" id="customer_mail" size="50" value="'. $_POST['customer_mail'] .'" /></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="submit"> <input type="reset"></td> </tr> </table> </form>'; } if (isset($_POST['submit'])){ if (strlen($subject) == 0 ) { echo "<span style=\"color:red\">Enter Subject</span><br><br>"; theForm(); exit; } if (strlen($detail) == 0 ) { echo "<span style=\"color:red\">Enter Comments/Text</span><br><br>"; theForm(); exit; } if (strlen($name) == 0 ) { echo "<span style=\"color:red\">Enter Your Name</span><br><br>"; theForm(); exit; } if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $customer_mail)) { echo "<span style=\"color:red\">Enter Valid Email Address</span><br><br>"; theForm(); exit; } if (strlen($customer_mail) == 0 ) { echo "<span style=\"color:red\">Enter Valid Email Address</span><br><br>"; theForm(); exit; } echo "<span style=\"color:red\">Email Received</span><br><br>"; $name="$name"; $email="$email"; $subject="$subject"; $text="$text"; mail('myemail@hotmail.com',$subject,$text,"From: $name <$email>"); } ?> <form method="post" name="form1" id="form1"> <table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr> <td width="16%"><span class="style108">Subject</span></td> <td width="2%"><span class="style104">:</span></td> <td width="82%"><input name="subject" type="text" id="subject" size="50" /></td> </tr> <tr> <td><span class="style108">Message</span></td> <td><span class="style104">:</span></td> <td><textarea name="detail" cols="50" rows="4" id="detail"></textarea></td> </tr> <tr> <td><span class="style108">Name</span></td> <td><span class="style104">:</span></td> <td><input name="name" type="text" id="name" size="50" /></td> </tr> <tr> <td><span class="style108">Email</span></td> <td><span class="style104">:</span></td> <td><input name="customer_mail" type="text" id="customer_mail" size="50" /></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="submit"> <input type="reset"></td> </tr> </table> </form> Quote Link to comment Share on other sites More sharing options...
HNX Posted December 9, 2007 Author Share Posted December 9, 2007 ok so you saw my form codings and php file right?? ok so u want me to replace my php file "send_mail.php" by the codings u gave me????? Quote Link to comment Share on other sites More sharing options...
HNX Posted December 10, 2007 Author Share Posted December 10, 2007 yo man what is the problem with u guys and there u come askin not to repost!! so u want me to replace this file with other i have???? Quote Link to comment 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.