PHP - Controlling Where Email Came From Php Form
Hello PHPFreaks,
I'm sorry about the vague topic title, but allow me to explain: I got a PHP form with some fields, and it sends the input data to me, and a copy to the person that submits it. Only the receiver of the email sees the email it came from as: example.com@webhost-mailserver.com, rather than just "example.com" or "info@example.com". Is there a way to control this, so people dont see the root host? Coding: // send email $headers = "From: \"$naam\" <$email>\n"; $subject = "Contactformulier Kartalin"; $from = "Kartalin.nl"; $message = " blabla their input etc. "; mail ("$youremail", $subject, $message, "From: $from\nContent-Type: text/html; charset=iso-8859-1"); If you need more of the code let me know, but as far as I can tell this seems to be the part where it can be changed (coming from a PHP-dummy ) Thanks in advance! Dave Similar TutorialsHello, I am working with a SMTP class to send an email. It's all working perfectly fine, but when the email is received (sent from the online form), and I open my email and click reply, there are two email addresses. The correct one (which I entered when I sent the email), and my ftp username for the site?? I've got three files that could effect this, but I was unable to locate any problems: mailer.php ( smtp send mail class) mail.php ( submission data: title, subject, etc. ) contact_form.php ( form for submission ) I am only including the file which I think is applicable (mail.php), but let me know if you would also like to see the mailer.php class. Current output: reply-to ftpusername@domainname.com, correct_from_email@fromemail.com mail.php: <?php set_time_limit(120); function sendHTMLmail($from, $to, $subject, $message) { $message = wordwrap($message, 70); // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= "From: $from\r\n"; // Mail it mail($to, $subject, $message, $headers); } function sendHTMLmail2($fromid, $to, $subject, $message) { echo $fromid; echo $to; echo $subject; echo $message; include_once("mailer.php"); $mail = new PHPMailer(); $mail->IsMail(); // SMTP servers $mail->Host = "localhost"; $mail->From = $fromid; $mail->FromName = $fromid; $mail->IsHTML(true); $mail->AddAddress($to, $to); $mail->Subject = $subject; $mail->Body = $message; $mail->AltBody = "Please enable HTML to read this"; $mail->Send(); exit; } function isValidEmail($email) { return eregi("^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3}$", $email); } class smtp_mail { var $host; var $port = 25; var $user; var $pass; var $debug = false; var $conn; var $result_str; var $charset = "utf-8"; var $in; var $from_r; //mail format 0=normal 1=html var $mailformat = 0; function smtp_mail($host, $port, $user, $pass, $debug = false) { $this->host = $host; $this->port = $port; $this->user = base64_encode($user); $this->pass = base64_encode($pass); $this->debug = $debug; $this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if ($this->socket) { $this->result_str = "Create socket:" . socket_strerror(socket_last_error()); $this->debug_show($this->result_str); } else { exit("Initialize Faild,Check your internet seting,please"); } $this->conn = socket_connect($this->socket, $this->host, $this->port); if ($this->conn) { $this->result_str = "Create SOCKET Connect:" . socket_strerror(socket_last_error()); $this->debug_show($this->result_str); } else { exit("Initialize Faild,Check your internet seting,please"); } $this->result_str = "Server answer:<font color=#cc0000>" . socket_read($this->socket, 1024) . "</font>"; $this->debug_show($this->result_str); } function debug_show($str) { if ($this->debug) { echo $str . "<p>\r\n"; } } function send($from, $to, $subject, $body) { if ($from == "" || $to == "") { exit("type mail address please"); } if ($subject == "") $sebject = "none title"; if ($body == "") $body = "none content"; $All = "From:$from;\r\n"; $All .= "To:$to;\r\n"; $All .= "Subject:$subject;\r\n"; if ($this->mailformat == 1) { $All .= "Content-Type:text/html;\r\n"; } else { $All .= "Content-Type:text/plain;\r\n"; } $All .= "Charset:" . $this->charset . ";\r\n\r\n"; $All .= " " . $body; $this->in = "EHLO HELO\r\n"; $this->docommand(); $this->in = "AUTH LOGIN\r\n"; $this->docommand(); $this->in = $this->user . "\r\n"; $this->docommand(); $this->in = $this->pass . "\r\n"; $this->docommand(); if (!eregi("235", $this->result_str)) { $this->result_str = "smtp auth faild"; $this->debug_show($this->result_str); return 0; } $this->in = "MAIL FROM: $from\r\n"; $this->docommand(); $this->in = "RCPT TO: $to\r\n"; $this->docommand(); $this->in = "DATA\r\n"; $this->docommand(); $this->in = $All . "\r\n.\r\n"; $this->docommand(); if (!eregi("250", $this->result_str)) { $this->result_str = "Send mail faild!"; $this->debug_show($this->result_str); return 0; } $this->in = "QUIT\r\n"; $this->docommand(); socket_close($this->socket); return 1; } function docommand() { socket_write($this->socket, $this->in, strlen($this->in)); $this->debug_show("Client command:" . $this->in); $this->result_str = "server answer:<font color=#cc0000>" . socket_read($this->socket, 1024) . "</font>"; $this->debug_show($this->result_str); } } ?> Hi the user fill details and then the email his sent to me the only problem is that the emails keeps going to my spam, can someone help me out please I looked already php website and email format looks the same. This is the link to my form. http://www.people.eurico.co.uk/ here my form script Code: [Select] <?php // Set email variables $email_to = 'xxxxx@xxxxxxx.co.uk'; $email_subject = 'Call back form'; // Set required fields $required_fields = array('fullname','email','telephone','comment'); // set error messages $error_messages = array( 'fullname' => 'Please enter a Name to proceed.', 'email' => 'Please enter a valid Email.', 'telephone' => 'Please telephone.', 'comment' => 'Please enter your Message to continue.' ); // Set form status $form_complete = FALSE; // configure validation array $validation = array(); // check form submittal if(!empty($_POST)) { // Sanitise POST array foreach($_POST as $key => $value) $_POST[$key] = remove_email_injection(trim($value)); // Loop into required fields and make sure they match our needs foreach($required_fields as $field) { // the field has been submitted? if(!array_key_exists($field, $_POST)) array_push($validation, $field); // check there is information in the field? if($_POST[$field] == '') array_push($validation, $field); // validate the email address supplied if($field == 'email') if(!validate_email_address($_POST[$field])) array_push($validation, $field); } // basic validation result if(count($validation) == 0) { // Prepare our content string $email_content = 'peoplesmartlearning.co.uk: ' . "\n\n"; // simple email content foreach($_POST as $key => $value) { if($key != 'submit') $email_content .= $key . ': ' . $value . "\n"; } // if validation passed ok then send the email mail($email_to, $email_subject, $email_content); // Update form switch $form_complete = TRUE; } } function validate_email_address($email = FALSE) { return (preg_match('/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i', $email))? TRUE : FALSE; } function remove_email_injection($field = FALSE) { return (str_ireplace(array("\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:"), '', $field)); } ?> The HTML Code: [Select] <div class="call_us_form"> <p class="title">WE'LL CALL YOU BACK</p> <?php if($form_complete === FALSE): ?> <form class="contact_form" id="fm-form" method="post" action="index.php" > <fieldset> <div class="fm-req"> <label for="fm-firstname">Name</label> <input type="text" id="fullname" class="detail" name="fullname" value="<?php echo isset($_POST['fullname'])? $_POST['fullname'] : ''; ?>" /> <?php if(in_array('fullname', $validation)): ?><script type="text/javascript">alert("Please enter a Name"); history.back();</script><?php endif; ?> </div> <div class="fm-req"> <label for="fm-firstname">Email</label> <input type="text" id="email" class="detail" name="email" value=" <?php echo isset($_POST['email'])? $_POST['email'] : ''; ?>" /> <?php if(in_array('email', $validation)): ?><script type="text/javascript">alert("Please enter a valid Email Address"); history.back();</script><?php endif; ?> </div> <div class="fm-req"> <label for="fm-firstname">Number</label> <input type="text" id="telephone" class="detail" name="telephone" value="<?php echo isset($_POST['telephone'])? $_POST['telephone'] : ''; ?>" /> <?php if(in_array('telephone', $validation)): ?><script type="text/javascript">alert("Please enter telephone number"); history.back();</script><?php endif; ?> </div> <div class="fm-req"> <label for="fm-lastname">Message</label> <textarea cols="40" rows="5" id="comment" name="comment" class="mess"><?php echo isset($_POST['comment'])? $_POST['comment'] : ''; ?></textarea> <?php if(in_array('comment', $validation)): ?><script type="text/javascript">alert("Please enter your message"); history.back();</script><?php endif; ?> </div> <input class="submit_button" type="submit" value="Call us" /> </fieldset> </form> <?php else: ?> <p>Thank you for your Message!</p> <p>We will get back to you as soon as we can</p> <script type="text/javascript"> setTimeout ('ourRedirect()', 5000) function ourRedirect () { location.href='index.php' } </script> <?php endif; ?> Hi all, What I am trying to achieve is, I thought quite simple! Basically, a user signs up and chooses a package, form is submitted, details added to the database, email sent to customer, then I want to direct them to a paypal payment screen, this is where I am having issues! Is their any way in php to submit a form without user interaction? Here is my code for the form process page Code: [Select] <?php include('config.php'); require('scripts/class.phpmailer.php'); $package = $_POST['select1']; $name = $_POST['name']; $email = $_POST['email']; $password = md5($_POST['password']); $domain = $_POST['domain']; $a_username = $_POST['a_username']; $a_password = $_POST['a_password']; $query=mysql_query("INSERT INTO orders (package, name, email, password, domain, a_username, a_password) VALUES ('$package', '$name', '$email', '$password', '$domain', '$a_username', '$a_password')"); if (!$query) { echo "fail<br>"; echo mysql_error(); } else { $id = mysql_insert_id(); $query1=mysql_query("INSERT INTO customers (id, name, email, password) values ('$id', '$name', '$email', '$password')"); if (!$query1) { echo "fail<br>"; echo mysql_error(); } if($package=="Reseller Hosting") { //email stuff here - all works - just cutting it to keep the code short if(!$mail->Send()) { echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } ?> <form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick-subscriptions"> <input type="hidden" name="business" value="subscription@jollyhosting.com"> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="item_name" value="Jolly Hosting Reseller Packages"> <input type="hidden" name="no_shipping" value="1"> <!--1st month --> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="a3" value="3.00"> <input type="hidden" name="p3" value="1"> <input type="hidden" name="t3" value="M"> <input type="hidden" name="src" value="1"> <input type="hidden" name="sra" value="1"> </form>'; <?php } //last } //end ?> i wanting users to be able to update there email address and check to see if the new email already exists. if the email is the same as current email ignore the check. i have no errors showing up but if I enter a email already in the db it still accepts the new email instead of bringing the back the error message. Code: [Select] // email enterd from form // $email=$_POST['email']; $queryuser=mysql_query("SELECT * FROM members WHERE inv='$ivn' ") or die (mysql_error()); while($info = mysql_fetch_array( $queryuser )) { $check=$info['email']; // gets current email // } if($check!=$email){ // if check not equal to $email check the new email address already exists// $queryuser=mysql_query("SELECT * FROM members WHERE email='$email' "); //$result=mysql_query($sql); $checkuser=mysql_num_rows($queryuser); if($checkuser != 0) { $error= "0"; header('LOCATION:../pages/myprofile.php?id='.$error.''); } } cheers As the topis says, I need help with an email form. You must have valid email address to go further, so lets say you write asdada as email, you won't be able to register the account, you must have asdada@hotmai.com or something like that. If anyone knows it would be awesome! I have a PHP app that I wrote that requires a new IP address each time that it is run. Currently I use Tor on my desktop and the Vidalia app to change the Tor identity each time I run the script but I want to automate this. Can anyone help with switching Tor identities with PHP? Essentially after my script runs I need to call a function that switches to a new Tor identity. I have the following code but it doesn't seem to work, and I am not sure why. I am running this from XAMPP on OSX, Tor is running locally (client not server)... in my Tor settings I have 127.0.0.1 and port 9051, set to "no password"... Code: [Select] <?php function tor_new_identity($tor_ip='127.0.0.1', $control_port='9051', $auth_code='') { $fp = fsockopen($tor_ip, $control_port, $errno, $errstr, 30); if (!$fp) { return false; //can't connect to the control port } fputs($fp, "AUTHENTICATE $auth_code\r\n"); $response = fread($fp, 1024); list($code, $text) = explode(' ', $response, 2); if ($code != '250') { return false; //authentication failed } //send the request to for new identity fputs($fp, "signal NEWNYM\r\n"); $response = fread($fp, 1024); list($code, $text) = explode(' ', $response, 2); if ($code != '250') { return false; //signal failed } fclose($fp); return true; } tor_new_identity(); ?> This may sound like an odd thought, but us beginners come up with weird ideas sometimes. I'm trying to solve a "three letters or less" search. Basically if the user enters 4 words or more, my script does a fulltext search. If they do 3 letters or less, it does a basic search. But how can I write the script so that it only searches for those matching letters that have either a space in front or at the end... or that start with the three letters searched. so, if they type in "elm" I want to get "chinese elm" I want to get "Elmendorf's onion" I don't want to get "engelman's spruce"... or at the very least have results with no space on either side be at the end of the results? right now, I'm just doing a basic search and a basic search that concatenates two fields: Code: [Select] $data = mysql_query("SELECT * FROM plantae WHERE common_name_english LIKE '%$item%'"); Code: [Select] $data = mysql_query("SELECT * FROM plantae WHERE CONCAT(taxonomic_genus,' ',scientific_name) LIKE '%$item%'"); Hi. how can I control a progress meter/bar to display errors when it failed to reach 100% or on getting to a point? thanks Hey! Normally I'm very good with researching my problems, but I just can't think of what to search for, what I am wanting to do is design a script that sends a command to a batch file that is already open and running (or something to that effect), does anyone know how this would be possible, all help would be appreciated! Thank you for your time Regards GreenFanta I'm trying to code my first php contact form from a tutorial I found and I have it working fine except Im not receiving the information from all the fields. Im having trouble adding the fields at the end of the code. Could somebody please help me out and tell me how to add the name and phone fields into the script. Many Thanks Shane. < ?php $name = $_REQUEST['name'] ; $email = $_REQUEST['email'] ; $phone = $_REQUEST['phone'] ; $message = $_REQUEST['message'] ; if (!isset($_REQUEST['email'])) { header( "Location: http://www.jlcustombikes.com" ); } elseif (empty($name) || empty($email) || empty($phone) || empty($message)) { header( "Expires: Mon, 20 Dec 1998 01:00:00 GMT" ); header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" ); header( "Cache-Control: no-cache, must-revalidate" ); header( "Pragma: no-cache" ); ?> <html> <head><title>Error</title></head> <body> <h1>Error</h1> <p> Oops, it appears you forgot to enter either your email address or your message. Please press the BACK button in your browser and try again. </p> </body> </html> <?php } else { mail( "shngarland@gmail.com", "Feedback Form Results", $message, "From: $email" ); header( "Location: http://www.jlcustomb....com/thanks.php" ); } ?> Hello there. I'm a designer and not really a coder, but I do my best. I'm trying to set up a mailer form that will collect email addresses for a newsletter and send them into my inbox in the body of a message. I've managed to create just that, but I need some other functionality that I haven't been able to accomplish. The work is for a non-profit site on Net Neutrality. http://internetyouneed.com/. You can see the form under the navigation menu. I sends the addresses to me just fine, but it also takes you to a blank page after. The form in nested inside a css div with an image background. I'd love two things: One, something that secures the form a bit so that only email addresses get sent and not random junk. I'd also like it if, instead of trying to go to another page after being clicked, it would stay on the same page and delete the form and changed the div's background image (say, a thank you image). Is this possible? Sorry, I'm so clueless, I was able to pull this off in Flash, but in HTML I'm baffled. This is my PHP script so far <?php mail("news@badmonkeystudios.com", $_POST['subject'], $_POST['body'], "From: PHPMailer\nReply-To:". $_POST['from']."\nX-Mailer: PHP/" . phpversion()); ?> And here is the form with the CSS div#signup { position:absolute; background: url(images/signup.gif) no-repeat; left: -144px; top: 440px; width: 227px; height: 137px; } div.link03 { position: absolute; top: 75px; left: 45px; width: 126px; height: 61px; } <div align="center" id="signup"><form action="mail.php" method="post"><br /><br /><input name="BODY" type="text" value="Enter Your Email" size="20" maxlength="60" /> <div class="link03"><input type="image" name="submit" src="images/spacer.gif" width=125 height=59 border="0" /></div></form></div> Hi, My contact form is not sending all content. Specifically, the dates for 'birthday' and 'anniversary' is not coming through correctly. The day works fine, but the month and year is not working. This is the code I am using above head <?php //If the form is submitted if(isset($_POST['submit'])) { //Check to make sure that the name field is not empty if(trim($_POST['contactname']) == '') { $hasError = true; } else { $name = trim($_POST['contactname']); } //Check to make sure sure that a valid email address is submitted if(trim($_POST['email']) == '') { $hasError = true; } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) { $hasError = true; } else { $email = trim($_POST['email']); } //Check to make sure that the subject field is not empty if(trim($_POST['birthday']) == '') { $hasError = true; } else { $birthday = trim($_POST['']); } //Check to make sure comments were entered if(trim($_POST['anniversary']) == '') { $hasError = true; } else { $anniversary = trim($_POST['anniversary']); } //If there is no error, send the email if(!isset($hasError)) { $emailTo = 'info@mywebsite.co.uk'; //Put your own email address here $body = "Name: $name \n\nEmail: $email \n\nBirthday: $birthday \n\nAnniversary: $anniversary"; $headers = 'From: http://www.mywebsite.co.uk <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; mail($emailTo, $subject, $body, $headers); $emailSent = true; } } ?> This is what I am using in the body <?php if(isset($hasError)) { //If errors are found ?> <p class="error">Please check if you've filled all the fields with valid information. Thank you.</p> <?php } ?> <?php if(isset($emailSent) && $emailSent == true) { //If email is sent ?> <p><strong>Email Successfully Sent!</strong></p> <p>Thank you <strong><?php echo $name;?></strong> for using my contacting mywebsiteco.uk Your email was successfully sent. We will be in touch with you soon.</p> <?php } ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" id="contactform"> <div> <label for="name"><strong>Name:</strong></label> <input type="text" size="50" name="contactname" id="contactname" value="" class="required" /> </div> <div> <label for="email"><strong>Email:</strong></label> <input type="text" size="50" name="email" id="email" value="" class="required email" /> </div> <div> <p><label for="birthday"><strong>Birthday:</strong></label> <select name="birthday" id="birthday"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select name="b_month" id="b_month"> <option value="1">January</option> <option value="2">February</option> <option value="3">March</option> <option value="4">April</option> <option value="5">May</option> <option value="6">June</option> <option value="7">July</option> <option value="8">August</option> <option value="9">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select> </p> </div> <div> <label for="anniversary"><strong>Anniversary:</strong></label> <select name="anniversary" id="anniversary"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select name="anni_month" id="anni_month"> <option value="1">January</option> <option value="2">February</option> <option value="3">March</option> <option value="4">April</option> <option value="5">May</option> <option value="6">June</option> <option value="7">July</option> <option value="8">August</option> <option value="9">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select> <select name="anni_year" id="anni_year"> <option value="1979">1979</option> <option value="1980">1980</option> <option value="1981">1981</option> <option value="1982">1982</option> <option value="1983">1983</option> <option value="1984">1984</option> <option value="1985">1985</option> <option value="1986">1986</option> <option value="1987">1987</option> <option value="1988">1988</option> <option value="1989">1989</option> <option value="1990">1990</option> <option value="1991">1991</option> <option value="1992">1992</option> <option value="1993">1993</option> <option value="1994">1994</option> <option value="1995">1995</option> <option value="1996">1996</option> <option value="1997">1997</option> <option value="1998">1998</option> <option value="1999">1999</option> <option value="2000">2000</option> <option value="2001">2001</option> <option value="2002">2002</option> <option value="2003">2003</option> <option value="2004">2004</option> <option value="2005">2005</option> <option value="2006">2006</option> <option value="2007">2007</option> <option value="2008">2008</option> <option value="2009">2009</option> </select> </div> <input type="submit" value="Send Message" name="submit" link="#"/> </form> Please help. Thanks Hello I've got this form that keeps messing up.
You can get to the link he http://alexis-apparel.host56.com/
Attached below are all the files. I must have this done by the end of the month please help
Attached Files
index.html 7.69KB
1 downloads
html_form_send.php 4.37KB
1 downloads
upload_file.php 879bytes
0 downloads Hi everyone! I just setup a PHP Email form on my site, but everytime I submit the form with the data, nothing reaches my email! View the webpage at http://www.anywhereccw.com/regis.html . Also, can someone help me make sure all of the data inputted is captured in the email? And both regis.html & FormToEmail.php are in the same root directory! THANKS! Mike First I am not a developer. I am just trying to reverse engineer the existing php form. This is the test page that I have setup. http://www.absenteehomeowners.com/arrival/index-test.php Currently the form emails the form information to a specific email address. I am trying to add the function of where if the user provides an email address then the information is also sent to the user. Here are the pages that I think are involved. I can get "Name" etc to show on the email but not the value. eg: Name: What I need is Name: Joe Smith Here is the code: <?php if($_POST["submit"]) { $recipient="my@email.address"; $subject="Form to email message"; $sender=$cemail; $mailBody="Customers Business Name: $cbname\n $cname=Customers Name: $cname\n $caddress=Customers Address: $caddress\n $csuburb=Customers Suburb: $csuburb\n $ccity=Customers City: $ccity\n $cphone=Customers Phone Number: $cphone\n $cemail=Customers Email: $cemail\n\n $sbname=Senders Business Name: $sbname\n $sname=Senders Name: $sname\n $saddress=Senders Address: $saddress\n $ssuburb=Senders Suburb: $ssuburb\n $scity=Senders City: $scity\n $sphone=Senders Phone Number: $sphone\n\n $rbname=Receivers Business Name: $rbname\n $rname=Receivers Name: $rname\n $raddress=Receivers Address: $raddress\n $rsuburb=Receivers Suburb: $rsuburb\n $rcity=Receivers City: $rcity\n $rphone=Receivers Phone Number: $rphone\n\n $item=Item: $item\n $length=Length: $length\n $width=Width: $width\n $height=height: \n\n $message=Additional Information: "$message; mail($recipient, $subject, $mailBody, "From: $sender <$cemail>"); header('Location: thanks.php'); } ?> Here is the form <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Contact form to email</title> </head> <body> <form method="post" action="action.php"> <label>Customers Business Name:</label> <input name="cbname"><br> <label>Customers Name:</label> <input name="cname"><br> <label>Cusotmers Address:</label> <input name="caddress"><br> <label>Customers Suburb:</label> <input name="csuburb"><br> <label>Customers City:</label> <input name="ccity"><br> <label>Customers Phone Number:</label> <input name="cphone"><br> <label>Customers Email:</label> <input name="cemail"><br> <label>Senders Business Name:</label> <input name="sbname"><br> <label>Senders Name:</label> <input name="sname"><br> <label>Senders Address:</label> <input name="saddress"><br> <label>Senders Suburb:</label> <input name="ssuburb"><br> <label>Senders City:</label> <input name="scity"><br> <label>Senders Phone Number:</label> <input name="sphone"><br> <label>Receivers Business Name:</label> <input name="rbname"><br> <label>Receivers Name:</label> <input name="rname"><br> <label>Receivers Address:</label> <input name="raddress"><br> <label>Receivers Suburb:</label> <input name="rsuburb"><br> <label>Receivers City:</label> <input name="rcity"><br> <label>Receivers Phone Number:</label> <input name="rphone"><br> <label>Item:</label> <input name="item"><br> <label>Length in cm:</label> <input name="length"><br> <label>Width in cm:</label> <input name="width"><br> <label>Height in cm:</label> <input name="hight"><br> <label>Weight in kg:</label> <input name="weight"><br> <label>Additional Information:</label> <textarea rows="5" cols="20" name="info"></textarea> <input type="submit" name="submit"> </form> </body> </html> Thanks for any help for can give. To PHPBuilder Forumgoers, My PHP email form is not sending to the address I specified, and I think it's because I added in an if-else statement to check for input of a valid email address. I've put the HTML and PHP scripts online and filled the live form out with several valid email addresses, with no success. I tried changing the recipient's email, too, with no success. Am I missing a glaring error in my code, or maybe things are just not in the right order? Any help would be SUPER appreciated. Thank you so much. The code (in external PHP file "order.php") : <?php $to = "myemailwashere@website.com"; $subject = "Custom Order Message"; $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; $from = $_REQUEST['name']; $budget = $_REQUEST['budget']; $colors[] = $_REQUEST['colors[]']; $headers = "From: $email"; $sent = mail($to, $from, $subject, $message, $budget, $headers) ; if( !eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*". "@([a-z0-9]+([\.-][a-z0-9]+))*$",$email)) { header( 'Location: order/invalidemail.html' ) ; }else{ header( 'Location: order/messagesent.html' ) ; } if($sent) {print "Your custom order query was sent successfully."; } else {print "An error occured while sending your custom order query. Please try again."; } ?> Ok I have two separate issues. The first is that I want to format the email so that the titles of the form areas are bolded (i.e., Name: Title:, etc...) the second issue is that I don't want the email to contain the blank fields (I.e. witness 2 etc.. if left empty) any help is appreciated here is my code Code: [Select] <p class="style2"><span class="style5"><strong>Incident / Unusual Occurrence Report</strong></span><br> Danville Area Community College<br><br> REPORT FORM</p> <table width="481" height="657" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td rowspan="2" valign="top" bgcolor="#FFFFFF" style="width: 481px"> <p align="center"class="style3"><font size="-1" face="Arial, Helvetica, sans-serif" align="left"> <?php $problems = array(); $showform = 0; $errorMessage = ""; function validate($field, $value) { // || $field == "id" || $field == "phone" || $field == "course" || $field == "instructor" /*if ($field == "name" || $field == "email" || $field == "computers" || $field == "info") {*/ if ($value == "") { return 0; } else { return 1; } /*}*/ /*if ($field == "system" || $field == "browser" || $field == "issue" || $field == "multiple") { if ($value == "----" || $value == "") { return 0; } else { return 1; } }*/ } if($_POST) { //'id','phone','course','instructor', $fields = array('name','title', 'date', 'time', 'building', 'room', 'location', 'person', 'title1', 'phone1', 'explanation', 'security', 'police', 'witness', 'acttaken', 'followact'); $x = 0 - 1; foreach($fields as $field) { if(isset($_POST[$field])) { $validation = validate($field, $_POST[$field]); if ($validation == 1) { $x++; $info[$x] = $_POST[$field]; } else { $problems[$field] = 1; $showform = 1; } } else { $problems[$field] = 1; $showform = 1; } } } else { $showform = 1; } if(count($problems) < 1 && $_POST) { // DO THE MAILING HERE $fields = array('title', 'name','date', 'time', 'building', 'room', 'location', 'title1','person', 'phone1', 'title2', 'person2', 'phone2','title3','person3', 'phone3','title4','person4', 'phone4', 'type1', 'type2', 'type3', 'type4', 'type5', 'type6', 'type7', 'type8', 'type9', 'explanation', 'security', 'police', 'witness','wtitle1', 'wperson', 'wphone1', 'wtitle2', 'wperson2', 'wphone2','wtitle3','wperson3', 'wphone3', 'acttaken', 'followact'); $to = "ampeck@earthlink.net"; $to2 = "aabdelzaher@dacc.edu"; $subject = "Incident / Unusual Occurrence Report"; $headers = "From: noreply@dacc.edu\r\n" . "X-Mailer: php"; $greet = "The following was submitted on " . date("F j, Y, g:i a") . "\n\n"; $body = $greet ; $cn = 1; foreach($fields as $efield) { if(isset($_POST[$efield])) { if($efield == "type1" || $efield == "type2" || $efield == "type3" || $efield == "type4" || $efield == "type5" || $efield == "type6" || $efield == "type7" || $efield == "type8" || $efield == "type9" ) { $body.= "Type of Occurrence:" . $_POST[$efield] . "\n\n"; $cn++; } elseif($efield == "title") { $body.= "Name of Person Filing Report: " . $_POST[$efield] . " "; } elseif($efield == "name") { $body.= " " . $_POST[$efield] . "\n________________________________________\n\n"; } elseif($efield == "date") { $body.= "Date of Occurrence: " . $_POST[$efield] . " \t "; } elseif ($efield == "time") { $body.= "Time: " . $_POST[$efield] . "\n________________________________________\n\n"; } elseif ($efield == "building") { $body.= "Building: " . $_POST[$efield] . " \t\t "; } elseif ($efield == "room") { $body.= "Room: " . $_POST[$efield] . "\n\n"; } elseif ($efield == "location") { $body.= "Description of Location: " . $_POST[$efield] . "\t\r\n________________________________________\n\n"; } elseif ($efield == "title1") { $body.= "First Person involved: " . $_POST[$efield] . " "; } elseif ($efield == "person") { $body.= " \t" . $_POST[$efield] . "\n"; } elseif ($efield == "phone1") { $body.= "Phone : " . $_POST[$efield] . "\n________________________________________\n\n"; }elseif ($efield == "title2") { $body.= "Second Person involved: " . $_POST[$efield] . " "; } elseif ($efield == "person2") { $body.= " " . $_POST[$efield] . "\n"; } elseif ($efield == "phone2") { $body.= "Phone : " . $_POST[$efield] . "\n________________________________________\n\n"; } elseif ($efield == "title3") { $body.= "Third Person involved: " . $_POST[$efield] . " "; } elseif ($efield == "person3") { $body.= " " . $_POST[$efield] . "\n"; } elseif ($efield == "phone3") { $body.= "Phone: " . $_POST[$efield] . "\n________________________________________\n\n"; } elseif ($efield == "title4") { $body.= "Fourth Person Involved: " . $_POST[$efield] . " "; } elseif ($efield == "person4") { $body.= " " . $_POST[$efield] . " \n"; } elseif ($efield == "phone4") { $body.= "Phone: " . $_POST[$efield] . "\n________________________________________\n\n"; } elseif ($efield == "explanation") { $body.= "Detailed Explanation: " . $_POST[$efield] . "\t\r\n________________________________________\n\n"; } elseif ($efield == "security") { $body.= "Security called: " . $_POST[$efield] . "\n\n"; } elseif ($efield == "police") { $body.= "Police called: " . $_POST[$efield] . "\n\n"; } elseif ($efield == "witness") { $body.= "Were there witnesses: " . $_POST[$efield] . "\n________________________________________\n\n"; } elseif($efield == "wtitle1") { $body.= "Witness: " . $_POST[$efield] . " "; } elseif ($efield == "wperson") { $body.= " \t" . $_POST[$efield] . "\n"; } elseif ($efield == "wphone1") { $body.= "Phone : " . $_POST[$efield] . "\n________________________________________\n\n"; }elseif ($efield == "wtitle2") { $body.= "Second witness: " . $_POST[$efield] . " "; } elseif ($efield == "wperson2") { $body.= " " . $_POST[$efield] . "\n"; } elseif ($efield == "wphone2") { $body.= "Phone : " . $_POST[$efield] . "\n________________________________________\n\n"; } elseif ($efield == "wtitle3") { $body.= "Third witness: " . $_POST[$efield] . " "; } elseif ($efield == "wperson3") { $body.= " " . $_POST[$efield] . "\n"; } elseif ($efield == "wphone3") { $body.= "Phone: " . $_POST[$efield] . "\n________________________________________\n\n"; } elseif ($efield == "acttaken") { $body.= "Immediate Action Taken: " . $_POST[$efield] . "\t\r\n________________________________________\n\n"; } elseif ($efield == "followact") { $body.= "What Follow-up Action will be taken: " . $_POST[$efield] . "\t\r\n________________________________________\n\n"; } } } mail($to, $subject, $body, $headers); mail($to2, $subject, $body, $headers); ?> <p class="style1">Your report has been submitted.<br><br></p> <?php } if($showform == 1) { ?> <?php if(count($problems) > 0) { ?> <p><strong><font color="red">PLEASE CORRECT ANY FIELDS WITH A RED * BY THEM</font></strong></p> <?php } ?> <form action="" method="post"> <fieldset> <legend> <span lang="en-us">Incident Report</span> </legend> <div class="style6"> <div class="style7"> <br> <table style="width: 100%"> <tr> <td style="width: 248px" class="style1"><font size="-1" face="Arial, Helvetica, sans-serif" align="left"> <label class="formtext" for="name">Name(s): <?php if(isset($problems['name'])) {?><font color="red">*</font><?php } ?></label><br> <input class="inputstyle" type="text" name="name" value="<?php if(isset($_POST['name'])){ print($_POST['name']); }?>" style=" width: 288px"></font></td> <td style="width: 148px" class="style1"><font size="-1" face="Arial, Helvetica, sans-serif" align="left"> <label class="formtext" for="title">Title: <?php if(isset($problems['title'])) {?><font color="red">*</font><?php } ?></label><br> <input class="style6" type="text" name="title" value="<?php if(isset($_POST['title'])){ print($_POST['title']); }?>" style=" width: 132px"></font></td> </tr> </table><p></p> <table > <tr> <td style="width: 132px"><font size="-1" face="Arial, Helvetica, sans-serif" align="left"> <label class="formtext" for="date">Date of Occurrence: <?php if(isset($problems['date'])) {?><font color="red">*</font><?php } ?></label><br> <input class="inputstyle" type="text" name="date" value="<?php if(isset($_POST['date'])){ print($_POST['date']); }?>" style=" width: 118px"></font></td> <td style="width: 170px"><font size="-1" face="Arial, Helvetica, sans-serif" align="left"> <label class="formtext" for="time">Time of Occurrence: <?php if(isset($problems['time'])) {?><font color="red">*</font><?php } ?></label><br> <input class="inputstyle" type="text" name="time" value="<?php if(isset($_POST['time'])){ print($_POST['time']); }?>" style=" width: 88px"></font></td> <td style="width: 111px"><font size="-1" face="Arial, Helvetica, sans-serif" align="left"> <label class="formtext" for="building">Building: <?php if(isset($problems['building'])) {?><font color="red">*</font><?php } ?></label><br> <input class="inputstyle" type="text" name="building" value="<?php if(isset($_POST['building'])){ print($_POST['building']); }?>" style=" width: 110px"></font></td> <td style="width:100px"><font size="-1" face="Arial, Helvetica, sans-serif" align="left"> <label class="formtext" for="room">Room: <?php if(isset($problems['room'])) {?><font color="red">*</font><?php } ?></label><br> <input class="inputstyle" type="text" name="room" value="<?php if(isset($_POST['room'])){ print($_POST['room']); }?>" style=" width: 60px"></font></td> </tr> </table> <table style="width: 100%; height: 72px;"> <tr> <td class="style1"><font size="-1" face="Arial, Helvetica, sans-serif" align="left"> <label class="formtext" for="location">Location Description: <?php if(isset($problems['location'])) {?><font color="red">*</font><?php } ?></label><br> <textarea name="location" style=" width: 383px; height: 115px;" ></textarea></font><br></td> </tr> </table> <br> <p class="style5">Person (s) involved in incident</p> <table > <tr> <td style="width: 200px"><font size="-1" face="Arial, Helvetica, sans-serif" align="left"> <span lang="en-us"> <label class="formtext" for="person">Name:<?php if(isset($problems['person'])) {?><font color="red">*</font><?php } ?></label></span><br> <input class="inputstyle" type="text" name="person" value="<?php if(isset($_POST['person'])){ print($_POST['person']); }?>" style="width: 249px"></font></td> <td style="width: 114px"><label class="formtext" for="title1"> <span lang="en-us">Title</span>:</label><br> <font size="-1" face="Arial, Helvetica, sans-serif" align="left"> <input class="inputstyle" type="text" name="title1" value="<?php if(isset($_POST['title1'])){ print($_POST['title1']); }?>" style=" width: 100px"></font></td> <td style="width: 104px"><label class="formtext" for="phone1"> <span lang="en-us">Phone</span>:</label><br> <input class="inputstyle" type="text" name="phone1" value="<?php if(isset($_POST['phone1'])){ print($_POST['phone1']); }?>" style="width: 75px"></td> </tr> <tr> <td style="width: 224px"><font size="-1" face="Arial, Helvetica, sans-serif" align="left"> <input type="text" name="person2" value="<?php if(isset($_POST['person2'])){ print($_POST['person2']); }?>" style="width: 249px" style="width: 249px"></font></td> <td style="width: 114px"> <input class="inputstyle" type="text" name="title2" value="<?php if(isset($_POST['title2'])){ print($_POST['title2']); }?>" style="width: 100px"></td> <td style="width: 104px"> <input class="inputstyle" type="text" name="phone2" value="<?php if(isset($_POST['phone3'])){ print($_POST['phone3']); }?>" style="width: 75px"></td></tr> <tr> <td style="width: 224px; height: 26px;"><font size="-1" face="Arial, Helvetica, sans-serif" align="left"> <input class="inputstyle" type="text" name="person3" value="<?php if(isset($_POST['person3'])){ print($_POST['person3']); }?>" style="width: 252px"></font></td> <td style="width: 114px; height: 26px;"> <input class="inputstyle" type="text" name="title3" value="<?php if(isset($_POST['title3'])){ print($_POST['title3']); }?>" style=" width: 100px"></td> <td style="width: 104px"> <input class="inputstyle" type="text" name="phone3" value="<?php if(isset($_POST['phone3'])){ print($_POST['phone3']); }?>" style=" width: 75px"></td></tr> <tr> <td style="width: 224px"> <input class="inputstyle" type="text" name="person4" value="<?php if(isset($_POST['person4'])){ print($_POST['person4']); }?>" style=" width: 252px"></td> <td style="width: 114px; height: 26px;"> <input class="inputstyle" type="text" name="title4" value="<?php if(isset($_POST['title4'])){ print($_POST['title4']); }?>" style=" width: 100px"></td> <td style="width: 104px"> <input class="inputstyle" type="text" name="phone4" value="<?php if(isset($_POST['phone4'])){ print($_POST['phone4']); }?>" style=" width: 75px"></td></tr> </table><fieldset> <legend> Please Select at least one: </legend> <p class="style5">Type of Alleged Occurrence:</p> <font size="-1" face="Arial, Helvetica, sans-serif" align="left"> <table style="width: 100%"> <tr> <td style="width: 33%; height: 57px;"><input class="inputstyle" type="checkbox" name="type1" value="Disgruntled Action"><label class="formtext" for="type1">Disgruntled Action</label><br></td> <td style="width: 33%; height: 57px;"> <input class="inputstyle" type="checkbox" name="type2" value="Obscene Language"><label class="formtext" for="type2">Obscene Language</label><br></td> <td style="width: 33%; height: 57px;"><input class="inputstyle" type="checkbox" name="type3" value="Verbal Threats"><label class="formtext" for="type3">Verbal Threats</label><br></td> </tr> <tr> <td style="width: 33%; height: 57px;"><input class="inputstyle" type="checkbox" name="type4" value="Physical Threats"><label class="formtext" for="type4">Physical Threats<br></label><br></td> <td style="width: 33%; height: 57px;"><input class="inputstyle" type="checkbox" name="type5" value="Inappropriate Physical Behavior"><label class="formtext" for="type5">Inappropriate Physical <span lang="en-us"> </span>Behavior</label><br></td> <td style="width: 33%; height: 57px;"><input class="inputstyle" type="checkbox" name="type6" value="Written Threat"><label class="formtext" for="type6">Written Threat<br></label></td> </tr> <tr> <td style="width: 33%; height: 57px;"><input class="inputstyle" type="checkbox" name="type7" value="Sexual Offense"><label class="formtext" for="type7">Sexual Offense<br></label></td> <td style="width: 33%; height: 57px;"><input class="inputstyle" type="checkbox" name="type8" value="Robbery or Other Crime"><label class="formtext" for="type8">Robbery or Other <span lang="en-us"> <br> </span>Crimes</label><br></td> <td style="width: 33%; height: 57px;" class="style6"><input class="inputstyle" type="checkbox" name="type9" value="Other"><label class="formtext" for="type9">Other</label><br> <br> </td></div> </tr> </table><p></p> </font><table style="width: 100%; height: 72px;"> <tr> <td class="style1"><font size="-1" face="Arial, Helvetica, sans-serif" align="left"> <label class="formtext" for="explanation">Detailed Explanation: <?php if(isset($problems['explanation'])) {?><font color="red">*</font><?php } ?></label><br> <textarea name="explanation" style=" width: 450px; height: 220px;" ></textarea></font><br></td> </tr> </table> </fieldset><br><br> <br> <fieldset> <legend> Actions Taken: </legend> <div class="style7"> <br> <label class="formtext" for="security"><?php if(isset($problems['security'])) {?><font color="red">*</font><?php } ?>Was Security Notified:</label> <select name="security" class="dropdownstyle"> <option value="">--Choose one--</option> <option value="Yes">Yes</option> <option value="No">No</option></select><br><br> <label class="formtext" for="police"><?php if(isset($problems['police'])) {?><font color="red">*</font><?php } ?>Were Police Notified:</label> <select name="police" class="dropdownstyle"> <option value="">--Choose one--</option> <option value="Yes">Yes</option> <option value="No">No</option></select><br><br> <label class="formtext" for="witness"><?php if(isset($problems['witness'])) {?><font color="red">*</font><?php } ?>Were there Witnesses?<br> (if yes, list names of witnesses):<span lang="en-us"> </span></label> <select name="witness" class="dropdownstyle"> <option value="">--Choose one--</option> <option value="Yes">Yes</option> <option value="No">No</option></select><br> <p class="style5">Witnesses to the Incident:</p> <table > <tr> <td style="width: 200px"><font size="-1" face="Arial, Helvetica, sans-serif" align="left"> <span lang="en-us"> <label class="formtext" for="wperson">Name:</label></span><br> <input class="inputstyle" type="text" name="wperson" value="<?php if(isset($_POST['wperson'])){ print($_POST['wperson']); }?>" style="width: 249px"></font></td> <td style="width: 114px"><label class="formtext" for="wtitle1"> <span lang="en-us">Title</span>:</label><br> <font size="-1" face="Arial, Helvetica, sans-serif" align="left"> <input class="inputstyle" type="text" name="wtitle1" value="<?php if(isset($_POST['wtitle1'])){ print($_POST['wtitle1']); }?>" style=" width: 100px"></font></td> <td style="width: 104px"><label class="formtext" for="wphone1"> <span lang="en-us">Phone</span>:</label><br> <input class="inputstyle" type="text" name="wphone1" value="<?php if(isset($_POST['wphone1'])){ print($_POST['wphone1']); }?>" style="width: 75px"></td> </tr> <tr> <td style="width: 224px"><font size="-1" face="Arial, Helvetica, sans-serif" align="left"> <input type="text" name="wperson2" value="<?php if(isset($_POST['wperson2'])){ print($_POST['wperson2']); }?>" style="width: 249px; width : 249px"></font></td> <td style="width: 114px"> <input class="inputstyle" type="text" name="wtitle2" value="<?php if(isset($_POST['wtitle2'])){ print($_POST['wtitle2']); }?>" style="width: 100px"></td> <td style="width: 104px"> <input class="inputstyle" type="text" name="wphone2" value="<?php if(isset($_POST['wphone3'])){ print($_POST['wphone3']); }?>" style="width: 75px"></td></tr> <tr> <td style="width: 224px; height: 26px;"><font size="-1" face="Arial, Helvetica, sans-serif" align="left"> <input class="inputstyle" type="text" name="wperson3" value="<?php if(isset($_POST['wperson3'])){ print($_POST['wperson3']); }?>" style="width: 252px"></font></td> <td style="width: 114px; height: 26px;"> <input class="inputstyle" type="text" name="wtitle3" value="<?php if(isset($_POST['wtitle3'])){ print($_POST['wtitle3']); }?>" style=" width: 100px"></td> <td style="width: 104px"> <input class="inputstyle" type="text" name="wphone3" value="<?php if(isset($_POST['wphone3'])){ print($_POST['wphone3']); }?>" style=" width: 75px"></td></tr> </table></div></fieldset> <br><br><table style="width: 100%; height: 72px;"> <tr> <td class="style1"><font size="-1" face="Arial, Helvetica, sans-serif" align="left"> <label class="formtext" for="acttaken">Immediate Action Taken: <?php if(isset($problems['acttaken'])) {?><font color="red">*</font><?php } ?></label><br> <textarea name="acttaken" style=" width: 450px; height: 220px;" ></textarea></font><br></td> </tr> </table> <br><br> <table style="width: 100%; height: 72px;"> <tr> <td class="style1"><font size="-1" face="Arial, Helvetica, sans-serif" align="left"> <label class="formtext" for="followact">Follow-up Action Taken: <?php if(isset($problems['followact'])) {?><font color="red">*</font><?php } ?></label><br> <textarea name="followact" style=" width: 450px; height: 220px;" ></textarea></font><br></td> </tr> </table> Hi, Im sort of new to PHP. I currently have this code Code: [Select] if(!empty($myrow['email'])){ echo "<a href=\"mailto: ".$myrow['email']."\">".$myrow['email']; echo "</a><br>";}Which just displays a email from the database and when clicked opens Outlook or some other email program. What i'm trying to do is hide the email and in its place put a link like "Contact" or a simple form that would send a email from my website to that email address. Does any one know any links to tutorials or at least a name for a script that would allow me to do this? Cheers! |