Jump to content

willH

New Members
  • Posts

    2
  • Joined

  • Last visited

willH's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello, In php i'm not much had knowledge of the, English also not very good, thank you for understanding. I have problems with this form, Can not preview the form. Appears link after sending. I need to so as to display Form. After sending completed form redirect to this page and vice versa. My script: <?php $titleErr = $nameErr = $emailErr = $commentErr = ""; $title = $name = $email = $comment = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["title"])) { $titleErr = "You must enter Title!"; } else { $title = test_input($_POST["title"]); } if (empty($_POST["name"])) { $nameErr = "Must enter the Name!"; } else { $name = test_input($_POST["name"]); if (!preg_match("/^[a-zA-Z ]*$/",$name)) { $nameErr = "Only letters and white space allowed"; } } if (empty($_POST["email"])) { $emailErr = "Must enter the name Email!"; } else { $email = test_input($_POST["email"]); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $emailErr = "Invalid email format"; } } if (empty($_POST["comment"])) { $commentErr = "Must enter the name comment"; } else { $comment = test_input($_POST["comment"]); if (!preg_match("/^[a-zA-Z ]*$/",$comment)) { $commentErr = "Only letters and white space allowed"; } } } // Check error messages, if none, then send email... if ($titleErr=="" AND $nameErr=="" AND $emailErr=="" AND $commentErr=="") { $to = "@..My email.."; $from = $_POST['email']; $title = $_POST['title']; $name = $_POST['name']; $subject = "Info from"; $subject2 = "Copy of your form submission"; $comment = $title . " " . $name . " " . "\n\n" . $_POST['comment']; $comment2 = "Here is a copy of your comment " . $name . "\n\n" . $_POST['comment']; $headers = "From:" . $from; $headers2 = "From:" . $to; mail($to,$subject,$comment,$headers); mail($from,$subject2,$comment2,$headers2); header("Location: http://..My web../thanks.html"); } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <HTML> <head> </head> <body> <form method="post" action=""> <fieldset> <legend>Write us what you need to know</legend> <center><span class="error" style="font:13px Arial"><big> * </big> required field.</span></center> <br> Title: <input type="text" name="title" size="5" value="<?php echo $title;?>"> <span class="error"><big> * </big><?php echo $titleErr;?></span><span id="example"> / Mr, Ms, ... / </span> <br><br> Name: <input type="text" name="name" size="30" value="<?php echo $name;?>"> <span class="error"><big> * </big> <?php echo $nameErr;?></span><span id="example"> / First Name and Last Name / </span> <br><br> E-mail: <input type="text" name="email" size="40" value="<?php echo $email;?>"> <span class="error"><big> * </big> <?php echo $emailErr;?></span> <br><br> Comment:<span class="error" style="position:relative; top:2px;"><big> * </big></span> <br><br> <textarea name="comment" rows="7" cols="55"> <?php echo $comment;?></textarea> <span class="error"><?php echo $commentErr;?></span> <br> <div id = "rocaptcha_placeholder" ></div> <script type = "text/javascript" src = "http://rocaptcha.com/api/js/?key=.....My key......" ></script> <script type = "text/javascript" > RoCaptcha . init ( "rocaptcha_placeholder" ); </script> <br> <input type="submit" name="submit" value="Submit" id="send"> </form> </body> </html> Díky všem za vaši pomoc!!! Will
  2. Hi, I am a beginner in php. I speak little english I got the the script on form to email but I have problems with him. Please help with that? 1. Form are uploaded but immediately sends unfilled on email. 2. Immediately after loaded and sent to the e-mail page appears thanking although has not been filled. Is perhaps a better to control of fulfillment of important data ? 3. How to do after sending the form redirection to the new webpage with the results: a) Form was sent - web page I have already made - the need to insert link to a php. b) Error + error list - web page I have already made - the need to insert link to a php. Thank you all in advance for your help with the addition of a script !!! I enclose a script: <?php $EmailFrom = "info@my mail.co.uk"; $EmailTo = "info@my mail.co.uk"; $Subject = "Info"; $Name = Trim(stripslashes($_POST['Name'])); $Email = Trim(stripslashes($_POST['Email'])); $Message = Trim(stripslashes($_POST['Message'])); $validationOK=true; if (!$validationOK) { echo "please check your details"; header("Location: http://my webpage/testform.php"); exit; } $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Message: "; $Body .= $Message; $Body .= "\n"; $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); if ($success){ print "<meta http-equiv=\"refresh\" content=\"1;URL=thanks.html\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"1;URL=thanks.html\">"; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title></title> </head> <body> <form action="testform.asp" method="post"> <div> <input name="_recipients" type="hidden" value="info@\\web-123win\winpackage23\my webpage.co.uk\www.my webpage.co.uk\web\content\fc\setup_script.cgi" /> <input name="_requiredFields" type="hidden" value="Name,Email,Message" /> <input name="_envars" type="hidden" value="HTTP_USER_AGENT,REMOTE_ADDR" /> <input name="_returnUrl" type="hidden" value="default.asp" /> <input name="_continueUrl" type="hidden" value="default.asp" /> </div> <table> <tr> <th align="left">Name:</th> <td><input name="Name" type="text" size="50" /></td> </tr> <tr> <th align="left">Email Address:</th> <td><input name="Email" type="text" size="50" /></td> </tr> <tr> <th align="left">Comments:</th> <td><input name="Message" type="text" size="50" /></td> </tr> <tr><td colspan="2"><b>To prevent spam, please enter the text from the following picture:</b></td></tr> </table> <div id = "rocaptcha_placeholder" ></div> <script type = "text/javascript" src = "http://rocaptcha.com/api/js/?key=my private key" ></script> <script type = "text/javascript" > RoCaptcha . init ( "rocaptcha_placeholder" ); </script> <p><input class="button" type="submit" value="Submit" /> <input class="button" type="reset" value="Clear" /></p> </form> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.