forsakenmemory Posted July 19, 2007 Share Posted July 19, 2007 im building a contact form and the form works fine but i just want to tweak it alittle and i dont know quite how. insted of sending the user to a seperate error.htm page i would just like for the error message to appear on the same page this way the user wont lose the information theyve alreay written. ive commented what i what to do on the code.. <?php $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); $EmailTo = "admin@webdesigndigital.com"; $Subject = "Design Enquiry"; $Name = Trim(stripslashes($_POST['Name'])); $Tel = Trim(stripslashes($_POST['Tel'])); $Website = Trim(stripslashes($_POST['Website'])); $Subject = Trim(stripslashes($_POST['Subject'])); $Enquiry = Trim(stripslashes($_POST['Enquiry'])); $validationOK=true; if (Trim($EmailFrom)=="") $validationOK=false; if (Trim($Name)=="") $validationOK=false; if (Trim($Enquiry)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; <-- // I would like to be able to send this to a taget iframe on the exit; // same page if possible. its probably simple i just dont know what it is. ??? } $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Tel: "; $Body .= $Tel; $Body .= "\n"; $Body .= "Website: "; $Body .= $Website; $Body .= "\n"; $Body .= "Subject: "; $Body .= $Subject; $Body .= "\n"; $Body .= "Enquiry: "; $Body .= $Enquiry; $Body .= "\n"; $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?> thanks any help anyone can give is most welcomed thanks in advance. Quote Link to comment Share on other sites More sharing options...
forsakenmemory Posted July 19, 2007 Author Share Posted July 19, 2007 bump please help ??? its really important i get this done thank you anyone please Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 19, 2007 Share Posted July 19, 2007 First off your code is bloated, Whats up with all the trimming, anyway try this (what version of php you on cause you write your code to like php 3) <?php $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); $EmailTo = "admin@webdesigndigital.com"; $Subject = "Design Enquiry"; $Name = Trim(stripslashes($_POST['Name'])); $Tel = Trim(stripslashes($_POST['Tel'])); $Website = Trim(stripslashes($_POST['Website'])); $Subject = Trim(stripslashes($_POST['Subject'])); $Enquiry = Trim(stripslashes($_POST['Enquiry'])); $validationOK = "yes"; if(empty($EmailFrom) || empty($Name) || empty($Enquiry)){ $validationOK = "no"; } if ($validationOK != "yes") { echo "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; // I would like to be able to send this to a taget iframe on the // same page if possible. its probably simple i just dont know what it is. ??? } else{ $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Tel: "; $Body .= $Tel; $Body .= "\n"; $Body .= "Website: "; $Body .= $Website; $Body .= "\n"; $Body .= "Subject: "; $Body .= $Subject; $Body .= "\n"; $Body .= "Enquiry: "; $Body .= $Enquiry; $Body .= "\n"; if(mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">"; } else{ echo "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?> Quote Link to comment Share on other sites More sharing options...
forsakenmemory Posted July 20, 2007 Author Share Posted July 20, 2007 no sorry i think you misunderstood. i dont think i explained it very well i wrote some new code doing a different tutorial. in newer php. i need the error message to appear in an iframe on the contact.html page above the contact form. contact.php <?php $youremail = "admin@xxxxxxxxxxx.com"; $thankyou = "ok.htm"; ;if($email == ""){ ?> // send to target frame on contact.html page "Please Enter Your Email"<br/> <?php ;}elseif($name == ""){ ?> // send to target frame on contact.html page "Please Enter Your Name"<br/> <?php ;}elseif($message == ""){ ?> // send to target frame on contact.html page "Please Enter Your Message"<br/> <?php ;}else{ $msg = ereg_replace("\\\'", "'", $message); $msg = ereg_replace('\\\"', "\"", $msg); $message1 = "from: $name\nemail: $email\nmessage:\n$msg1"; mail($youremail, $subject, $msg, $tel, $name, "From: $email\r\nReply-to: $email\r\n"); ?> <meta http-equiv="refresh" content="0; url=<?echo $thankyou;?>""> <?php } ?> on this page the error message should appear contact.html <table align=center border="0" cellspacing="0" cellpadding="0" width="790" bgcolor="ffffff" bordercolorlight="#666666" bordercolordark="#808080"> <tr> <td width=220 valign=bottom> <blockquote> ERROR MESSAGE HERE ----------> <iframe width="215" height="40" src="" scrolling="no" name="errormsg"> </iframe> <form action="contact.php" method="post"> Name: <input type="text" name="name"><br/> Email addess: <input type="text" name="email"><br/> Tel: <input type="text" name="tel"><br/> Subject: <input type="text" name="subject"><br/> </blockquote> </td> <td width="1"> <img src="../images/greygrad.gif" width="1" height="240" alt="webdesign" border="0"><img src="../images/spacer.gif" width="25" height="50" alt="web design" border="0"></td> <td align=left valign=top> <iframe width="420" height="250" src="contact_info.html" scrolling="no" name="frame1"></iframe> </td> </tr> <tr> <td valign=top colspan=3> <blockquote> Enquiry:<br/> <textarea name="message" cols="60" rows="10"></textarea><br/><br/> <input type="submit" value="Submit"><br/> </form> </blockquote> </td> </tr> </table> thanks anyone who knows how to code this thank you. Quote Link to comment Share on other sites More sharing options...
socratesone Posted July 20, 2007 Share Posted July 20, 2007 You need to use javascript if you are going to set the src of the iframe the header on page load, but why? It's easier to put the logic around the iframe source itself: if ($validationOK != "yes") { $iframeSrc = "error.htm">"; }else{ $iframeSrc = "ok.htm\">"; } // and then in the iframe: ?> <iframe src="<?= $iframeSrc ?>"> Quote Link to comment Share on other sites More sharing options...
forsakenmemory Posted July 20, 2007 Author Share Posted July 20, 2007 could you give me an example in in the really early stages of learning this stuff! sorry Quote Link to comment Share on other sites More sharing options...
forsakenmemory Posted July 20, 2007 Author Share Posted July 20, 2007 You need to use javascript if you are going to set the src of the iframe the header on page load, but why? It's easier to put the logic around the iframe source itself: if ($validationOK != "yes") { $iframeSrc = "error.htm">"; }else{ $iframeSrc = "ok.htm\">"; } // and then in the iframe: ?> <iframe src="<?= $iframeSrc ?>"> ok i see what you mean there but you implimented it to the old code i cant figure how to work it into the new one! 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.