PHP - Simple Contact Form, Php N00b
so, I've been trying to build a contact form for about a week now. straight. no kidding.
I'm entirely new to php and basically know nothing more than i can assume based on other scripting/coding experience. I know there's probably answers to similar questions all over the place, but I've been trying literally hundreds of different pre-built forms guaranteed to work and solutions to others' problems, etc etc and not a single one has operated correctly for me. I can't really do anything with a "you should try this/that approach" answer, nor can I be assumed to know anything about php; I pretty much just need someone to fix whatever the problem is and paste it back to me as this is the only thing keeping me from launching the site. this is what prints when trying to submit with the dropdown on the default value: Quote Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in D:\Hosting\5810110\html\contact\contact.php on line 32 There was an err0r processing your request. Please notify god@neurot1k.com & include details of what you did [wrong]. this prints when any item other than the default is selected in the dropdown: Quote Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in D:\Hosting\5810110\html\contact\contact.php on line 32 Warning: mail() [function.mail]: SMTP server response: 554 The message was rejected because it contains prohibited virus or spam content in D:\Hosting\5810110\html\contact\contact.php on line 33 There was an err0r processing your request. Please notify god@neurot1k.com & include details of what you did [wrong]. http://email.about.com/cs/standards/a/smtp_error_code_2.htm specifically states to ignore both these errors, yet http://cr.yp.to/docs/smtplf.html specifically states that it's a fault of mine. here's the html: Code: [Select] <div id="formHolder"> <form method="post" action="contact.php"> <table class="contactTable" align="center"> <tr> <td> Subject: </td> <td> <select name="sendto"> <option value="bs from N1K.com">General Inquiry</option> <option value="JOB OFFER">Design Contract</option> <option value="PURCHASE ORDER">Purchase Order/Offer</option> </select> </td> </tr> <tr> <td><font color=red>*</font>Name:</td> <td><input size=25 name="Name"></td> </tr> <tr> <td><font color=red>*</font>Email:</td> <td><input size=25 name="Email"></td> </tr> <tr> <td>Company:</td> <td><input size=25 name="Company"></td> </tr> <tr> <td>Phone:</td> <td><input size=25 name="Phone"></td> </tr> <tr> <td>Subscribe to<br> mailing list: </td> <td><input type="radio" name="list" value="No"> Pf, nothx.<br> <input type="radio" name="list" value="Yes" checked> H3X Y34!<br> </td> </tr> <tr> <td colspan=2>Message:</td> </tr> <tr> <td colspan=2 align=center> <textarea name="Message" rows=5 cols=35></textarea> </td> </tr> <tr> <td colspan=2 align=center> <input type=submit name="send" value="Submit"> </td> </tr> </table> </form> </div><!-- END formHolder --> and here's the php: <?php $to = "god@neurot1k.com" ; $from = $_REQUEST['Email'] ; $name = $_REQUEST['Name'] ; $headers = "From: $from"; $subject = $_REQUEST['sendto'] ; $fields = array(); $fields{"Name"} = "Name"; $fields{"Company"} = "Company"; $fields{"Email"} = "Email"; $fields{"Phone"} = "Phone"; $fields{"list"} = "Mailing List"; $fields{"Message"} = "Message"; $body = "I have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } $headers2 = "From: god@neurot1k.com"; $subject2 = "autoconfirm from neurot1k.com"; $autoreply = "Thanks for the contact, I'll get back to you as soon as possible, usually within 48 hours. If you have any more questions, please try me on AIM: ycleptCrux"; if($from == '') { print "You have not entered an email, please go back and try again"; } else { if($name == '') { print "You have not entered a name, please go back and try again"; } else { $send = mail($to, $subject, $body, $headers); $send2 = mail($from, $subject2, $autoreply, $headers2); if($send) { print "Thanks, I'll get back to you as soon as possible."; } else { print "There was an err0r processing your request. Please notify god@neurot1k.com & include details of what you did [wrong]."; } } } ?> the form was copy/pasted from http://php.about.com/od/phpapplications/ss/form_mail.htm and then respective variables were changed (email address, dropdown fields, etc). I didn't think it'd be SUCH a problem to copy/paste a pre-written block of code from About.com... HUGE thanks in advance to anyone willing to helo. Similar TutorialsHi, Today I have taken my first step towards familiarisation with php. I have created a simple form form a tutorial I read. The mail.php file is this: Code: [Select] <?php $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $dropdown = $_POST['dropdown']; $formcontent=" From: $firstname \n Surname: $lastname \n Email: $email \n Dropdown: $dropdown"; $recipient = "fathernugen@googlemail.com"; $subject = "Newsletter Sign Up"; $mailheader = "From: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); echo "You have been added to our newsletter subscription list!" . " -" . "<a href='newsletter.php' style='margin:0 auto; top: 100px; text-decoration:none;color:#ff0099;'> Return to Sitting Spiritually</a>"; ?> My problem is that users are redirected to a blank page with 'thank you return to sitting spiritually'. I would like to use a custom thank you page with a url like; www.sittingspiritually.co.uk/thankyou.php so the look of the site is not completely ruined by my php inadequacies. Is there a small piece of code i can add to the mail.php file so i can use a custom page for the success??? I hope some one can help, thanks in advance. Hello, I am trying to use this contact form that emails out. however it wants to be placed beside the file that uses it. However i would need a bunch of these files than for what i am trying to do. I want it to be set up like this. website root | | scripts | scriptfile right now its like this website root | | about | | contact | | script file here is the from data in my webpage <form action="FormToEmail.php" method="post"> <table border="0" style="background:#ececec" cellspacing="5"> <tr align="left"><td>Name</td><td><input type="text" size="30" name="name"></td></tr> <tr align="left"><td>Email address</td><td><input type="text" size="30" name="email"></td></tr> <tr align="left"><td valign="top">Comments</td><td><textarea name="comments" rows="6" cols="30"></textarea></td></tr> <tr align="left"><td> </td><td><input type="submit" value="Send"></td></tr> </table> </form> here is the script data <?php error_reporting(E_ALL ^ E_NOTICE); $my_email = "test@test.com.com"; $from_email = ""; /* Optional. Enter the continue link to offer the user after the form is sent. If you do not change this, your visitor will be given a continue link to your homepage. If you do change it, remove the "/" symbol below and replace with the name of the page to link to, eg: "mypage.htm" or "http://www.elsewhere.com/page.htm" */ $continue = "/"; /* Step 3: Save this file (FormToEmail.php) and upload it together with your webpage containing the form to your webspace. IMPORTANT - The file name is case sensitive! You must save it exactly as it is named above! THAT'S IT, FINISHED! You do not need to make any changes below this line. */ $errors = array(); // Remove $_COOKIE elements from $_REQUEST. if(count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}} // Validate email field. if(isset($_REQUEST['email']) && !empty($_REQUEST['email'])) { $_REQUEST['email'] = trim($_REQUEST['email']); if(substr_count($_REQUEST['email'],"@") != 1 || stristr($_REQUEST['email']," ") || stristr($_REQUEST['email'],"\\") || stristr($_REQUEST['email'],":")){$errors[] = "Email address is invalid";}else{$exploded_email = explode("@",$_REQUEST['email']);if(empty($exploded_email[0]) || strlen($exploded_email[0]) > 64 || empty($exploded_email[1])){$errors[] = "Email address is invalid";}else{if(substr_count($exploded_email[1],".") == 0){$errors[] = "Email address is invalid";}else{$exploded_domain = explode(".",$exploded_email[1]);if(in_array("",$exploded_domain)){$errors[] = "Email address is invalid";}else{foreach($exploded_domain as $value){if(strlen($value) > 63 || !preg_match('/^[a-z0-9-]+$/i',$value)){$errors[] = "Email address is invalid"; break;}}}}}} } // Check referrer is from same site. if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){$errors[] = "You must enable referrer logging to use the form";} // Check for a blank form. function recursive_array_check_blank($element_value) { global $set; if(!is_array($element_value)){if(!empty($element_value)){$set = 1;}} else { foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);} } } recursive_array_check_blank($_REQUEST); if(!$set){$errors[] = "You cannot send a blank form";} unset($set); // Display any errors and exit if errors exist. if(count($errors)){foreach($errors as $value){print "$value<br>";} exit;} if(!defined("PHP_EOL")){define("PHP_EOL", strtoupper(substr(PHP_OS,0,3) == "WIN") ? "\r\n" : "\n");} // Build message. function build_message($request_input){if(!isset($message_output)){$message_output ="";}if(!is_array($request_input)){$message_output = $request_input;}else{foreach($request_input as $key => $value){if(!empty($value)){if(!is_numeric($key)){$message_output .= str_replace("_"," ",ucfirst($key)).": ".build_message($value).PHP_EOL.PHP_EOL;}else{$message_output .= build_message($value).", ";}}}}return rtrim($message_output,", ");} $message = build_message($_REQUEST); $message = $message . PHP_EOL.PHP_EOL."-- ".PHP_EOL.""; $message = stripslashes($message); $subject = "Doctor Dave Question"; $subject = stripslashes($subject); if($from_email) { $headers = "From: " . $from_email; $headers .= PHP_EOL; $headers .= "Reply-To: " . $_REQUEST['email']; } else { $from_name = ""; if(isset($_REQUEST['name']) && !empty($_REQUEST['name'])){$from_name = stripslashes($_REQUEST['name']);} $headers = "From: {$from_name} <{$_REQUEST['email']}>"; } mail($my_email,$subject,$message,$headers); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Form To Email PHP script from FormToEmail.com</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#ffffff" text="#000000"> <div> <center> <b>Thank you <?php if(isset($_REQUEST['name'])){print stripslashes($_REQUEST['name']);} ?></b> <br>Your message has been sent <p><a href="<?php print $continue; ?>">Click here to continue</a></p> </center> </div> </body> </html> thank you. on a side note the text box wher ei entered this in is anoyying. it jumps and bounces every letter i type. Hello, I have just finished very simple contact form at http://stjohnsclaims.co.uk/test5/index-6.html and I am strugling to redirect the page to index.html, or any other URL when buttom "submit" is pressed. html file always reads contact.php file and then echo ("Your claim form was successfully sent!"); on blank background. How can I redirect it? I know this is very trivial question, but I have alrready spend many hours trying to fix it with no result. Thank you html body.... <div class="indent1"> <h2>Claim Form</h2> <form action="contact.php" method="get" id="form"><div class="container"> <div class="col-5"><h4>Your Details:</h4> <div class="h"><input name="name" type="text" class="input1" />Name:</div> <div class="h"><input name="surname"type="text" class="input1" />Surname:</div> <div class="h"><input name="tel"type="text" class="input1" />Tel:</div> <div class="h"><input name="email"type="text" class="input1" />Email Adress:</div> <div class="h"><input name="address"type="text" class="input1" />Address:</div> <div class="h"><input name="city"type="text" class="input1" />City:</div> <div class="h"><input name="postcode"type="text" class="input1" />Postcode:</div><p> <h4>Accident Details</h4> <div class="h"><input name="date"type="text" class="input1" />Date of Accident:</div> <div class="h"><input name="type"type="text" class="input1" />Accident Type:</div> </div> <div class="col-6">Accident details/Injuries sustained:</div> <div class="col-7"> <textarea name="message" class="textarea" rows="40" cols="30"></textarea> <div class="container1"> <div class="fright"> <a href="#" onclick="document.getElementById('form').reset()" class="link-1"><em><b>Clear</b></em></a> <div class="indent-2"> <a href="#" onclick="document.getElementById('form').submit()" class="link-1"><em><b>Submit</b></em></a></div> </div> </div> </div> </div></form> --------------------------------------------------------------- contact.php on the server <? $subject="from ".$_GET['name']; $headers= "From: ".$_GET['email']."\n"; $headers.='Content-type: text/html; charset=iso-8859-1'; mail("kc@kamil-cizek.com", $subject, " <html> <head> <title>Contact letter</title> </head> <body> <br> " . "name: " .$_GET['name']. "<br>" . "email: " .$_GET['surname']. "<br>" . "fax: " .$_GET['tel']. "<br>" . "age: " .$_GET['email']. "<br>" . "gender: " .$_GET['address']. "<br>" . "name: " .$_GET['city']. "<br>" . "email: " .$_GET['postcode']. "<p>" . "fax: " .$_GET['date']. "<br>" . "age: " .$_GET['type']. "<p>" . "message: <p>" .$_GET['message']." </body> </html>" , $headers); echo ("Your claim form was successfully sent!"); ?> I have used this same php contact form many times and never had this problem. I just checked it in online php code checker and comes up with no errors but when uploaded to the site and I got to test the form it goes to mysite.com/contact.php stuck on trailing code
\nReply-To: \"$name\" <$email>\nX-Mailer: chfeedback.php 2.03" ); header( "Location: $thankyouurl" ); exit ; ?>
It has me stumped I can't work it out.
The full code is:
<? /* CHFEEDBACK.PHP Feedback Form PHP Script Ver 2.03 */ $mailto = 'contact@gmail.com' ; $subject = "Contact Form" ; $formurl = "http://www.mysite.com/contact.html" ; $errorurl = "http://www.mysite.com/error.html" ; $thankyouurl = "http://www.mysite.com/thanks.html" ; $name = $_POST['name'] ; $email = $_POST['email'] ; $comments = $_POST['comments'] ; $http_referrer = getenv( "HTTP_REFERER" ); if (!isset($_POST['email'])) { header( "Location: $formurl" ); exit ; } if (empty($name) || empty($email) || empty($comments)) { header( "Location: $errorurl" ); exit ; } if (get_magic_quotes_gpc()) { $comments = stripslashes( $comments ); } $messageproper = "This message was sent from:\n" . "$http_referrer\n" . "------------------------- COMMENTS -------------------------\n\n" . $comments . "\n\n------------------------------------------------------------\n" ; mail($mailto, $subject, $messageproper, "From: \"$name\" <$email>\nReply-To: \"$name\" <$email>\nX-Mailer: chfeedback.php 2.03" ); header( "Location: $thankyouurl" ); exit ; ?>But when I look at the source code in browser I can see all of it is in red except for the last trailing bit which appears in black . Edited by bmbc, 07 June 2014 - 03:54 AM. Hi, I am having issues getting a simple contact form getting past the junk filter and into the inbox. Is there something wrong with my code? I have tried to set the email to 'not junk' in the 2 different email providers, but not change. Here is my code: Code: [Select] <?php $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $from = 'From: Contact Form'; $to = 'my_email@gmail.com'; $subject = 'Hello'; $human = $_POST['human']; $body = "From: $name\n E-Mail: $email\n Message:\n $message"; $headers .= "Content-type: text/plain; charset=utf-8\n"; $headers .= "From: website user<someone_from@mysite.com> \n"; if ($_POST['submit']) { if ($name != '' && $email != '') { if ($human == '10') { if (mail ($to, $subject, $body, $from)) { echo '<p>Your message has been sent!</p>'; } else { echo '<p>Something went wrong, go back and try again!</p>'; } } else if ($_POST['submit'] && $human != '4') { echo '<p>You answered the anti-spam question incorrectly!</p>'; } } else { echo '<p>You need to fill in all required fields!!</p>'; } } ?> Code: [Select] <form method="post" action="mail_.php"> <label>Name</label> <input name="name" placeholder="Type Here"> <label>Email</label> <input name="email" type="email" placeholder="Type Here"> <label>Message</label> <textarea name="message" placeholder="Type Here"></textarea> <label>*What is 7+3? (Anti-spam)</label> <input name="human" placeholder="Type Here"> <input id="submit" name="submit" type="submit" value="Submit"> </form> Any help is greatly appreciated. (php is a weakness)
Here is the HTML portion for the form:
<form action="send_form_email.php" id="contacts-form" method="post"> I apologize in advance, I know pretty much nothing about PHP - don't hate me, please! But I'm working on a form mailer, and it functions, but what I don't like is it leaves all the text fields, blank or not, in my email, which makes it difficult for my client to read, so theres a long list of txt field1: another text field: blah blah: all the way down the email - and I want it gone! haha. I've researched how to do this, but basically, I have no idea how to implement it into my code and don't have time right now to up and learn PHP. My code is as follows: Code: [Select] <?php //--------------------------Set these paramaters-------------------------- // Subject of email sent to you. $subject = 'PCI Tour/Excursion Request'; // Your email address. This is where the form information will be sent. $emailadd = 'MY EMAIL HERE'; // Where to redirect after form is processed. $url = 'FORWARDING URL'; // Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty. $req = '0'; // --------------------------Do not edit below this line-------------------------- $text = "Results from form:\n\n"; $space = ' '; $line = ' '; foreach ($_POST as $key => $value) { if ($req == '1') { if ($value == '') {echo "$key is empty";die;} } $j = strlen($key); if ($j >= 20) {echo "Name of form element $key cannot be longer than 20 characters";die;} $j = 20 - $j; for ($i = 1; $i <= $j; $i++) {$space .= ' ';} $value = str_replace('\n', "$line", $value); $conc = "{$key}:$space{$value}$line"; $text .= $conc; $space = ' '; } mail($emailadd, $subject, $text, 'From: '.$emailadd.''); echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'; ?> IT was a very simple copy-paste form, but I have no idea what on earth I'm doing. If anyone has any ideas I would GREATLY appriciate the help! Thanks! -Austin Hello, I have coded a contact form in PHP and I want to know, if according to you, it is secure! I am new in PHP, so I want some feedback from you. Moreover, I have also two problems based on the contact form. It is a bit complicated to explain, thus, I will break each of my problem one by one. FIRST:The first thing I want to know, is if my contact form secure according to you: The HTML with the PHP codes: Code: [Select] <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { //Assigning variables to elements $first = htmlentities($_POST['first']); $last = htmlentities($_POST['last']); $sub = htmlentities($_POST['subject']); $email = htmlentities($_POST['email']); $web = htmlentities($_POST['website']); $heard = htmlentities($_POST['heard']); $comment = htmlentities($_POST['message']); $cap = htmlentities($_POST['captcha']); //Declaring the email address with body content $to = 'alithebestofall2010@gmail.com'; $body ="First name: '$first' \n\n Last name: '$last' \n\n Subject: '$sub' \n\n Email: '$email' \n\n Website: '$web' \n\n Heard from us: '$heard' \n\n Comments: '$comment'"; //Validate the forms if (empty($first) || empty($last) || empty($sub) || empty($email) || empty($comment) || empty($cap)) { echo '<p class="error">Required fields must be filled!</p>'; header ('refresh= 3; url= index.php'); return false; } elseif (filter_var($first, FILTER_VALIDATE_INT) || filter_var($last, FILTER_VALIDATE_INT)) { echo '<p class="error">You cannot enter a number as either the first or last name!</p>'; return false; } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) { echo '<p class="error">Incorrect email address!</p>'; return false; } elseif (!($cap === '12')){ echo '<p class="error">Invalid captcha, try again!</p>'; return false; } else { mail ($to, $sub, $body); echo '<p class="success">Thank you for contacting us!</p>'; } } ?> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> <p>Your first name: <span class="required">*</span></p> <p><input type="text" name="first" size="40" placeholder="Ex: Paul"/></p> <p>Your last name: <span class="required">*</span></p> <p><input type="text" name="last" size="40" placeholder="Ex: Smith"/></p> <p>Subject: <span class="required">*</span></p> <p><input type="text" name="subject" size="40" placeholder="Ex: Contact"/></p> <p>Your email address: <span class="required">*</span></p> <p><input type="text" name="email" size="40" placeholder="Ex: example@xxx.com"/></p> <p>Website:</p> <p><input type="text" name="website" size="40" placeholder="Ex: http//:google.com"/></p> <p>Where you have heard us?: <span class="required">*</span></p> <p><select name="heard"> <option>Internet</option> <option>Newspapers</option> <option>Friends or relatives</option> <option>Others</option> </select></p> <p>Your message: <span class="required">*</span></p> <p><textarea cols="75" rows="20" name="message"></textarea></p> <p>Are you human? Sum this please: 5 + 7 = ?: <span class="required">*</span></p></p> <p><input type="text" name="captcha" size="10"/></p> <p><input type="submit" name="submit" value="Send" class="button"/> <input type="reset" value="Reset" class="button"/></p> </form> SECOND PROBLEM:If a user has made a mistake, he gets the error message so that he can correct! However, when a mistake in the form occurs, all the data the user has entered are disappeared! I want the data to keep appearing so that the user does not start over again to fill the form. THIRD: When the erro message is displayed to notify the user that he made a mistake when submitting the form, the message is displaying on the top of the page. I want it to appear below each respective field. How to do that? In JQuery it is simple, but in PHP, I am confusing! I have read around and can't seem to find the right coding for what I need on this forum and some other other forums. I have a contact form (as listed below) and I need 2 locations (Print Name and Title) fields to auto-populate on a separate form (can be a doc, pdf, etc. any form of document which is easiest) and this form can be totally back end and the individual using the form never is going to see the form. It's going on a contract form, that we would like to auto-populate. Also is there a simple attachment code so individuals can attach documents to the code? <p style: align="center"><form action="mailtest.php" method="POST"> <?php $ipi = getenv("REMOTE_ADDR"); $httprefi = getenv ("HTTP_REFERER"); $httpagenti = getenv ("HTTP_USER_AGENT"); ?> <input type="hidden" name="ip" value="<?php echo $ipi ?>" /> <input type="hidden" name="httpref" value="<?php echo $httprefi ?>" /> <input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" /> <div align="center"> <p class="style1">Name</p> <input type="text" name="name"> <p class="style1">Address</p> <input type="text" name="address"> <p class="style1">Email</p> <input type="text" name="email"> <p class="style1">Phone</p> <input type="text" name="phone"> <p class="style1">Debtor</p> <input type="text" name="debtor"> <p class="style1">Debtor Address</p> <input type="text" name="debtora"> <br /> <br /> <a href="authoforms.php" target="_blank" style="color:#ffcb00" vlink="#ffcb00">Click here to view Assignment Agreement and Contract Agreement</a> <p class="style1"><input type='checkbox' name='chk' value='I Have read and Agree to the terms.'> I have read and agree to the Assignment and Contract Agreement <br></p> <p class="style1">Print Name</p> <input type="text" name="pname"> <p class="style1">Title</p> <input type="text" name="title"> <p class="style1">I hear by agree that the information I have provided is true, accurate and the information I am submitting is <br /> not fraudulent. Please click the agree button that you adhere to Commercial Recovery Authority Inc.'s terms:</p> <select name="agree" size="1"> <option value="Agree">Agree</option> <option value="Disagree">Disagree</option> </select> <br /> <br /> <p class="style1">Employee ID:</p> <input type="text" name="employee"> <br /> <input type="submit" value="Send"><input type="reset" value="Clear"> </div> </form> </p> The mailtest php is this ?php $ip = $_POST['ip']; $httpref = $_POST['httpref']; $httpagent = $_POST['httpagent']; $name = $_POST['name']; $address = $_POST['address']; $email = $_POST['email']; $phone = $_POST['phone']; $debtor = $_POST['debtor']; $debtora = $_POST['debtora']; $value = $_POST['chk']; $pname = $_POST['pname']; $title = $_POST['title']; $agree = $_POST['agree']; $employee = $_POST['employee']; $formcontent=" From: $name \n Address: $address \n Email: $email \n Phone: $phone \n Debtor: $debtor \n Debtor's Address: $debtora \n 'Client' has read Assignment and Contract Agreement: $value \n Print Name: $pname \n Title: $title \n I hear by agree that the information I have provided is true, accurate and the information I am submitting is not fraudulent. Please click the agree button that you adhere to Commercial Recovery Authority Inc.'s terms: $agree \n \n Employee ID: $employee \n IP: $ip"; $recipient = "mail@crapower.com"; $subject = "Online Authorization Form 33.3%"; $mailheader = "From: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); echo "Thank You!" . " -" . "<a href='index.php' style='text-decoration:none;color:#ffcb00;'> Return Home</a>"; $ip = $_POST['visitoraddress'] ?> Hi all, firstly thank you in advance to anyone who replies to this thread. I'll be honest I'm a newbie when I comes to PHP and really am a long way to mastering it. If someone could have a look at my code and tell me where I'm going wrong here then it would be a great help.
The problem here is, when I click on the submit button it sends me to the PHP script page and doesn't actually send a email to the address.
Please Help and again, thank you in advance.
Below is the HTML,
<section> I made a form using http://www.phpform.org/ but I can't for the life of me write some php that successfully collects all the info and emails it to me. Would love to get some help to stop me pulling m hair out over it - it can't be 'that' complicated? I'd just put the form here for now http://trackcover.com/test/ Hi all, I am currenlty coding up PHP validation for a contact form and as I know barely any PHP i have been following tutorials and copying code. I have a series of checkboxes which emails out the various products that the user wants. It all works now except that it does not re-direct to a thank you page now and outputs this error at the top of the page. Warning: Invalid argument supplied for foreach() in /home2/xxxxxxxx/public_html/client/contact.php on line 17 Below is the code for the PHP and form, any help would be greatly appreciated. Thank you! Code: [Select] <?php if (isset($_POST['submit'])) { $myemail = 'my@email.com';//<-----Put Your email address here. $title = 'Quote'; $name = $_POST['name']; $company = $_POST['company']; $house = $_POST['house']; $street = $_POST['street']; $postcode = $_POST['postcode']; $daynum = $_POST['daynum']; $evenum = $_POST['evenum']; $email = $_POST['email']; $how = $_POST['how']; $information = $_POST['information']; foreach($_POST['product'] as $value) { $product_msg .= " - $value"; } $errors = array(); // set the errors array to empty, by default $fields = array(); // stores the field values $success_message = ""; // import the validation library require("validation.php"); $rules = array(); // stores the validation rules // standard form fields $rules[] = "required,name,Name is required."; $rules[] = "required,house,House number is required."; $rules[] = "required,street,Street is required."; $rules[] = "required,postcode,Post Code is required."; $rules[] = "required,daynum,Daytime Number is required."; $errors = validateFields($_POST, $rules); // if there were errors, re-populate the form fields if (!empty($errors)) { $fields = $_POST; } // no errors! redirect the user to the thankyou page (or whatever) else { // here you would either email the form contents to someone or store it in a database. // To redirect to a "thankyou" page, you'd just do this: // header("Location: thanks.php"); $to = $myemail; $email_subject = "Quote: $name"; $email_body = "You have received a new quote from $name. ". " Here are the details:\n \n Name: $name\n \n Company: $company\n \n House: $house\n \n Street: $street\n \n Postcode: $postcode\n \n Daytime Number: $daynum\n \n Evening Number: $evenum\n \n Email: $email\n \n Products: $product_msg\n \n Additional Information: $information\n \n How: $how"; $headers = "From: $title\n"; $headers .= "Reply-To: $email"; mail($to,$email_subject,$email_body,$headers); //redirect to the 'thank you' page header('Location: thank-you.html'); } } ?> <form action="<?=$_SERVER['PHP_SELF']?>" method="post" id="contact-form" class="cmxform"> <?php // if $errors is not empty, the form must have failed one or more validation // tests. Loop through each and display them on the page for the user if (!empty($errors)) { echo "<div class='phperror'>Please fix the following errors:\n<ul>"; foreach ($errors as $error) echo "<li>$error</li>\n"; echo "</ul></div>"; } if (!empty($message)) { echo "<div class='notify'>$success_message</div>"; } ?> <fieldset> <label for="name">Name:*</label> <label for="name" class="error">Please enter your name.</label> <input class="text" type="text" id="name" name="name" value="<?=$fields['name']?>"/> <label for="company">Company Name:</label> <input class="text" type="text" id="company" name="company"> <label for="house">House Number:*</label> <label for="house" class="error">Please enter your house number.</label> <input class="text" type="text" id="house" name="house" value="<?=$fields['house']?>"> <label for="street">Street Name:*</label> <label for="street" class="error">Please enter your street name.</label> <input class="text" type="text" id="street" name="street" value="<?=$fields['street']?>"> <label for="postcode">Post Code:*</label> <label for="postcode" class="error">Please enter your post code.</label> <input class="text" type="text" id="postcode" name="postcode" value="<?=$fields['postcode']?>"> <label for="daynum">Daytime Number:*</label> <label for="daynum" class="error">Please enter your number.</label> <input class="text" type="text" id="daynum" name="daynum" value="<?=$fields['daynum']?>"> <label for="evenum">Evening Number:</label> <input class="text" type="text" id="eve-num" name="evenum"> <label for="email">Email Address:</label> <input class="text" type="text" id="email" name="email"> </fieldset> <fieldset> <label>Cara Glass Product:</label> <label for="check[]" class="error">Please choose a product.</label> <div id="product"> <div class="radio-btn"> <label for="conservatory">Conservatory</label> <input type="checkbox" value="conservatory" id="conservatory" name="product[]" validate="required:true"/> </div><!--radio-btn--> <div class="radio-btn"> <label for="windows">Windows</label> <input type="checkbox" value="windows" name="product[]" /> </div><!--radio-btn--> <div class="radio-btn"> <label for="fascias">Fascias</label> <input type="checkbox" value="fascias" name="product[]" /> </div><!--radio-btn--> <div class="radio-btn"> <label for="doors">Doors</label> <input type="checkbox" value="doors" name="product[]" /> </div><!--radio-btn--> <div class="radio-btn"> <label for="rooftrim">Rooftrim</label> <input type="checkbox" value="rooftrim" name="product[]" /> </div><!--radio-btn--> </div><!--product--> <label for="information">Additional Information:</label> <textarea id="information" name="information"></textarea> </fieldset> <fieldset> <p>How Did You Hear About Us?</p> <div id="how"> <div class="radio-btn"> <label for="internet">Internet</label> <input type="radio" value="internet" id="internet" name="how"/> </div><!--radio-btn--> <div class="radio-btn"> <label for="letter">Marketing Letter</label> <input type="radio" value="letter" id="letter" name="how" /> </div><!--radio-btn--> <div class="radio-btn"> <label for="referral">Referral</label> <input type="radio" value="referral" id="referral" name="how" /> </div><!--radio-btn--> <div class="radio-btn"> <label for="advertising">Advertising</label> <input type="radio" value="advertising" id="advertising" name="how" /> </div><!--radio-btn--> <div class="radio-btn"> <label for="vans">Our Vans</label> <input type="radio" value="vans" id="vans" name="how" /> </div><!--radio-btn--> </div><!--how--> <p class="submit">Once we have received your details we will call you to arrange a convenient time</p> </fieldset> <input type="submit" name="submit" value="SUBMIT" /> </form> Hey, I have my contact form in my website working fine I'm just asking a simple question because I don't know so much about php and php syntax I have my html file calling this code below when i'm clicking on the submit button Just take a look at the last line when there is the 'echo' script I want it to go to this link, and instead it's just writing the link what is the right command/code that should i use? <? $subject="from ".$_GET['fName']; $headers= "From: ".$_GET['fEmail']."\n"; $headers.='Content-type: text/html; charset=UTF-8' . "\r\n"; mail("mymail@example.com", $subject, " <html> <head> <title> My Title </title> </head> <body> <br> ".$_GET['fName']. " <br> ".$_GET['fPhone']." <br> ".$_GET['fEmail']." <br><br> ".$_GET['pBody']." </body> </html>" , $headers); echo "http://avrikim123.co.cc/sent.html"; ?> Hello,
I need a contact form with fields:
Name:
Email:
Phone:
Message:
I have html contact form but when a visitor clicks on submit button then a pop up says thnq for contacting us and he need to be on the same page. the details has to get in mail to me.
Hey everyone, I have a really simple php contact form that I managed to mess up and can't for the life of me figure out what the problem is. It accepts the responses and will continue to the "success" page like it's supposed to, but it doesn't mail the data from the form fields when it does. I was hoping you'd be able to take a look and maybe find the error(s)... I know it's probably something really simple and stupid but I can't figure it out. Thanks in advance!! Code: [Select] <?php //----------------------------------------------------- //----------------------------------------------------- $address= "jm.horvatin@gmail.com"; //----------------------------------------------------- //----------------------------------------------------- $firstname = $_REQUEST["First Name: "]; $lastname = $_REQUEST["Last Name: "]; $phone = $_REQUEST["Phone Number: "]; $referred = $_REQUEST["I was referred by: "]; $address = $_REQUEST["Address: "]; $city = $_REQUEST["City: "]; $province = $_REQUEST["Province: "]; $postal = $_REQUEST["Postal Code: "]; $email = $_REQUEST["Email Address: "]; $mime_boundary = md5(time()); $headers = "From: $name <$email>\n"; $headers .= "Reply-To: $subject <$email>\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n"; $message = "--$mime_boundary\n\n"; $message .= "New Web Registration: \n\n\n"; $message .= "First Name: $firstname \n\n"; $message .= "Last Name: $lastname \n\n"; $message .= "Phone Number: $phone \n\n"; $message .= "I was referred by: $referred \n\n"; $message .= "Address: $address \n\n"; $message .= "City: $city \n\n"; $message .= "Province: $province \n\n"; $message .= "Postal Code: $postal \n\n"; $message .= "Email Address: $email \n\n"; $message .= "--$mime_boundary--\n\n"; $mail_sent = mail($address, $subject, $message, $headers); header("location:paypal.html"); ?> ?> Code: [Select] <form action="get_mail.php" method="POST" class="contactform"> <p>First Name <input name="firstname" type="text" / class="box" value="" size="35"> Last Name <input name="lastname" type="text" class="box" value="" size="40"/> <br> Phone <input name="phonenumber" type="text" value="" class="box"> I was referred by <input name="referred" type="text" class="box" value="" size="45"> <br> Address <input name="address" type="text" class="box" value="" size="35"> City <input name="city" type="text" class="box" value="" size="20"> Province <input name="province" type="text" class="box" value="" size="7"> Postal Code <input name="postal" type="text" class="box" value="" size="6"> Email Address <input name="email" type="text" class="box" value="" size="40"> <br> <br> Automatic month-to-month: This is a month-to-month program and is considered active and ongoing until cancelled as described in the Cancellation policy. CANCELLATION POLICY: ShapeIt! member must give notice of cancellation by Email to totalfitnessbc@gmail.com at least 5 business days from the above stated debit date. Even if you notify your instructor, you still are required to send and email to <a href="mailto:totalfitnessbc@gmail.com">totalfitnessbc@gmail.com</a> Save a record of this email to serve as your cancellation receipt. 30-day money back guarantee is contingent upon receiving an email of cancelation to totalfitnessbc@gmail.com within the first 30 days of signing this agreement.</p> <p><br> I certify that I have fully read and understand the terms of this Agreement and will comply with the contents herein. Prepay memberships are non-refundable after the 30 day money back guarantee period expires. <br> <br> <input type="submit" class="contactform" value="Proceed to Payment" target="_blank"> <br class="clear" /> </p> </form> A while ago I purchased a website template which included a contact form, and a PHP script to process the form. I cannot find the contact form so I'm trying to figure out how to code it on my own, or find a similar one to put in it's place. The PHP file is located he http://warp.nazwa.pl/dc/innovation/php/contact/sendMessage.php The form itself is on this page: http://warp.nazwa.pl/dc/innovation/contact.html Here is the code from the JScript file. Code: [Select] // alias to jQuery library, function noConflict release control of the $ variable // to whichever library first implemented it var $j = jQuery.noConflict(); // if true the send button is blocked var g_blockSendButton = false; /*************************************** SETUP CONTACT FORM ****************************************/ function setupInputControls() { // change border color wehen controls take focus $j(".commonInput, .commonTextarea, .contactInputHuman").focus( function() { $j(this).css("border", "1px solid #3399cc"); } ); // restore border color wehen controls lost focus $j(".commonInput, .commonTextarea, .contactInputHuman").blur( function() { $j(this).css("border", "1px solid #ccc"); $j(this).css("border-right", "1px solid #eee"); $j(this).css("border-bottom", "1px solid #eee"); } ); // when input name lost focus, validate the value $j("#inputName").blur( function() { if($j(this).val() != "") { $j("#contactNameErrorMsg").css("visibility", "hidden"); } else { $j(this).css("border", "1px solid #FF0000"); $j("#contactNameErrorMsg").html(" Please enter your name").css("visibility", "visible"); } } ); // when input email lost focus validate the value $j("#inputEmail").blur( function() { if($j(this).val() != "") { // create regular expression object var regExp = new RegExp(/^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9]([-a-z0-9_]?[a-z0-9])*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z]{2})|([1]?\d{1,2}|2[0-4]{1}\d{1}|25[0-5]{1})(\.([1]?\d{1,2}|2[0-4]{1}\d{1}|25[0-5]{1})){3})(:[0-9]{1,5})?$/i); // check email address, if result is null the email string dont match to pattern var resultExp = regExp.exec($j(this).val()); if(resultExp == null) { $j(this).css("border", "1px solid #FF0000"); $j("#contactEmailErrorMsg").html(" Sorry, but this email address is incorrect").css("visibility", "visible"); } else { $j("#contactEmailErrorMsg").css("visibility", "hidden"); } } else { $j(this).css("border", "1px solid #FF0000"); $j("#contactEmailErrorMsg").html(" Please enter your email address").css("visibility", "visible"); } } ); // when input subject lost focus validate the value $j("#inputSubject").blur( function() { if($j(this).val() != "") { $j("#contactSubjectErrorMsg").css("visibility", "hidden"); } else { $j(this).css("border", "1px solid #FF0000"); $j("#contactSubjectErrorMsg").html(" You forgot to specify a subject").css("visibility", "visible"); } } ); // when input message lost focus validate the value $j("#inputMessage").blur( function() { if($j(this).val() != "") { $j("#contactMessageErrorMsg").css("visibility", "hidden"); } else { $j(this).css("border", "1px solid #FF0000"); $j("#contactMessageErrorMsg").html(" Please enter your message").css("visibility", "visible"); } } ); // when input human lost focus validate the value $j("#inputHuman").blur( function() { if(parseInt($j(this).val(), 10) == 4) { $j("#contactHumanErrorMsg").css("visibility", "hidden"); } else { $j(this).css("border", "1px solid #FF0000"); $j("#contactHumanErrorMsg").html(" You really don't know?").css("visibility", "visible"); } } ); } // end of function setupInputControl function setupSendButton() { $j("#contactSendButton").click( function() { // prevent multiple send call by user if(true == g_blockSendButton) { return; } g_blockSendButton = true; // get all data from contact form and save it in local variables var inputName = $j("#inputName").val(); var inputEmail = $j("#inputEmail").val(); var inputSubject = $j("#inputSubject").val(); var inputMessage = $j("#inputMessage").val(); var inputHuman = $j("#inputHuman").val(); // create regular expression object var regExp = new RegExp(/^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9]([-a-z0-9_]?[a-z0-9])*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z]{2})|([1]?\d{1,2}|2[0-4]{1}\d{1}|25[0-5]{1})(\.([1]?\d{1,2}|2[0-4]{1}\d{1}|25[0-5]{1})){3})(:[0-9]{1,5})?$/i); // check email address, if result is null the email string dont match to pattern var resultExp = regExp.exec(inputEmail); // check user answer, resultHuman = true if ok, false if answer is bad var resultHuman = parseInt(inputHuman, 10) == 4; // check the error by logical sum var error = (resultHuman != true) || (resultExp == null) || (inputName == "") || (inputEmail == "") || (inputSubject == "") || (inputMessage == ""); // if there was an error we must display some informotion and mark // input cotrol with wrong data if(error) { $j("#contactNameErrorMsg").css("visibility", "hidden"); $j("#contactEmailErrorMsg").css("visibility", "hidden"); $j("#contactSubjectErrorMsg").css("visibility", "hidden"); $j("#contactMessageErrorMsg").css("visibility", "hidden"); $j("#contactHumanErrorMsg").css("visibility", "hidden"); $j("#contactErrorPanel").slideUp(300); // errors processing if(inputName == "") { $j("#inputName").css("border", "1px solid #FF0000"); $j("#contactNameErrorMsg").html(" Please enter your name").css("visibility", "visible"); } if(inputEmail == "") { $j("#inputEmail").css("border", "1px solid #FF0000"); $j("#contactEmailErrorMsg").html(" Please enter your email adress").css("visibility", "visible"); } else if(resultExp == null) { $j("#inputEmail").css("border", "1px solid #FF0000"); $j("#contactEmailErrorMsg").html(" Sorry, but this email address is incorrect").css("visibility", "visible"); } if(inputSubject == "") { $j("#inputSubject").css("border", "1px solid #FF0000"); $j("#contactSubjectErrorMsg").html(" You forgot to specify a subject").css("visibility", "visible"); } if(inputMessage == "") { $j("#inputMessage").css("border", "1px solid #FF0000"); $j("#contactMessageErrorMsg").html(" Please enter your message").css("visibility", "visible"); } if(resultHuman != true) { $j("#inputHuman").css("border", "1px solid #FF0000"); $j("#contactHumanErrorMsg").html(" You really don't know?").css("visibility", "visible"); } // unblock send button g_blockSendButton = false; } else // if no error, if all data is set correctly { // let's define function called after ajax successfull call function phpCallback(data) { // if success if(data == "ok") { $j("#contactErrorPanel").text(""); $j("#contactErrorPanel").css("background-color", "#ccFFcc"); $j("#contactErrorPanel").append("Your email was sent."); $j("#contactErrorPanel").css("border", "1px solid #339933"); $j("#contactErrorPanel").slideDown(300, function(){ g_blockSendButton = false;}); $j("#inputName").val(""); $j("#inputEmail").val(""); $j("#inputSubject").val(""); $j("#inputMessage").val(""); $j("#inputHuman").val(""); } else // if error/problem during email sending in php script { $j("#contactErrorPanel").text(""); $j("#contactErrorPanel").css("background-color", "#FFcccc"); $j("#contactErrorPanel").css("border", "1px solid #993333"); $j("#contactErrorPanel").append("There was an error sending your email."); $j("#contactErrorPanel").slideDown(300, function(){ g_blockSendButton = false;}); } } // end of function phpCallback // all data is correct so we can hide error/success panel $j("#contactErrorPanel").slideUp(300); // build data string for post call var data = "inputName="+inputName; data += "&"+"inputEmail="+inputEmail; data += "&"+"inputSubject="+inputSubject; data += "&"+"inputMessage="+inputMessage; // try to send email via php script executed by server $j.post("php/contact/sendMessage.php", data, phpCallback, "text"); // unblock send button } // end else all dara } ); } // end of function setupSendButton /*************************************** MAIN CODE - CALL THEN PAGE LOADED ****************************************/ // binding action to event onload page $j(document).ready( function() { // common.js setupGlobal(); setupCommunityButtons(); setupToolTipText(); setupSearchBox(); setupCufonFontReplacement(); setupSideBarMiniSlider(); setupMultiImageLightBox(); setupSidebarTabsPanel(); setupLoadingAsynchronousImages(); setupToolTipImagePreview(); setupTextLabelImagePreview(); // this file setupInputControls(); setupSendButton(); } ); Can anyone help me figure out how to do this by any chance? sir i need this contact form php code to make it work,
i make thi deign for my website but dont know what have to put in send.php
here i the code
<h4>Send a Message</h4> <div class="contact-form" method="post" action="send.php"> <form role="form"> <div class="form-group"> <label for="name">Name</label> <input type="text" name="name" placeholder="" id="name" class="form-control"> </div> <div class="form-group"> <label for="email">Email</label> <input type="text" name="email" placeholder="" id="email" class="form-control"> </div> <div class="form-group"> <label for="phone">Skype</label> <input type="text"name="subject" id="phone" class="form-control"> </div> <div class="form-group"> <label for="phone">Message</label> <textarea placeholder="" name="message" rows="5" class="form-control"></textarea> </div> <button class="btn btn-danger" type="submit">Submit</button> </form> Edited by soumikr, 22 December 2014 - 11:35 AM. Hello Guys ! I have an error in my contact.php. When I fill all the content and submit appears: "E-mail sent successfully". but when i check my e-mail there's nothing there... I'd like to know what is happening here's the code: Code: [Select] <?php session_start(); if(!$_POST) exit; /////////////////////////////////////////////////////////////////////////// // Simple Configuration Options // Enter the email address that you want to emails to be sent to. // Example $address = "joe.doe@yourdomain.com"; $address = "myemailhere@mail.com"; // Twitter Direct Message notification control. // Set $twitter_active to 0 to disable Twitter Notification $twitter_active = 0; $twitter_user = ""; $twitter_pass = ""; // END OF Simple Configuration Options /////////////////////////////////////////////////////////////////////////// // Only edit below this line if either instructed to do so by the author or have extensive PHP knowledge. // Please Note, we cannot support this file package if modifications have been made below this line. $name = $_POST['name']; $email = $_POST['email']; $subject = $_POST['subject']; $comments = $_POST['comments']; // Important Variables $error = ''; if(trim($name) == '') { $error .= '<li>Your name is required.</li>'; } if(trim($email) == '') { $error .= '<li>Your e-mail address is required.</li>'; } elseif(!isEmail($email)) { $error .= '<li>You have entered an invalid e-mail address.</li>'; } if(trim($subject) == '') { $error .= '<li>Please enter a subject.</li>'; } if(trim($comments) == '') { $error .= '<li>You must enter a message to send.</li>'; } if($error != '') { echo '<div class="error_message">Attention! Please correct the errors below and try again.'; echo '<ul class="error_messages">' . $error . '</ul>'; echo '</div>'; } else { if(get_magic_quotes_gpc()) { $comments = stripslashes($comments); } // Advanced Configuration Option. // i.e. The standard subject will appear as, "You've been contacted by John Doe." $e_subject = 'You\'ve been contacted by ' . $name . '.'; // Advanced Configuration Option. // You can change this if you feel that you need to. // Developers, you may wish to add more fields to the form, in which case you must be sure to add them here. $msg = "You have been contacted by $name with regards to $subject.\r\n\n"; $msg .= "$comments\r\n\n"; $msg .= "You can contact $name via email, $email.\r\n\n"; $msg .= "-------------------------------------------------------------------------------------------\r\n"; if($twitter_active == 1) { $twitter_msg = $name . " - " . $comments . ". You can contact " . $name . " via email, " . $email ." or via phone " . $phone . "."; twittermessage($twitter_user,$twitter_pass,$twitter_msg); } if(mail($address, $e_subject, $msg, "From: $email\r\nReturn-Path: $email\r\n")) { echo "<fieldset>"; echo "<div id='success_page'>"; echo "<h1>Email Sent Successfully.</h1>"; echo "<p>Thank you <strong>$name</strong>, your message has been submitted to us.</p>"; echo "</div>"; echo "</fieldset>"; } else { echo 'ERROR!'; // Dont Edit. } } function twittermessage($user,$pass,$comments) { // Twitter Direct Message CURL function, do not edit. $url = "http://twitter.com/direct_messages/new.xml"; $ch = curl_init(); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($ch, CURLOPT_USERPWD, "$user:$pass"); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,"user=$user&text=$comments"); $results = curl_exec ($ch); curl_close ($ch); } function isEmail($email) { // Email address verification, do not edit. return(preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i",$email)); } ?> hello All, Thank you EVERYONE for all of your help... it was much appreciated. I have created a form that does the following: (1) Connects to the database that created. (2) Inserts the users data into the database (3) Displays a thank you you page after a successful form submission (4) Send an e-mail to me with all the users details I NOW need to be able to send a Custom html page to the end users e-mail with all their data... a Confirmation e-mail for their reference. Is there some special PHP Code that can HANDLE such a task? If so please tell me how might be able to integrate this in my existing code. thanks mrjap1 Hi,
I recently bought a HTML template and it came with a contact form which work fines.
The only issue I have is that when the email arrives it only shows the persons first name, not their surname unless the name is kept as one e.g.. Adam-Smith
I can't see why this is and has been bugging me for the past couple of days!
Any ideas?
$email_to = "contact@website"; $name = $_POST["user-name"]; $email = $_POST["user-email"]; $message = $_POST["user-message"]; $text = "Name: $name Email: $email Message: $message"; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html; charset=utf-8" . "\r\n"; $headers .= "From: <$name>" . "\r\n"; mail($email_to, "Contact", $text, $headers); ?> Thanks |