energysuperstore09 Posted August 26, 2009 Share Posted August 26, 2009 I have a registration page where i want the info from the reg form to be emailed to me? Can anybody help? Quote Link to comment https://forums.phpfreaks.com/topic/171976-solved-how-can-i-send-info-from-form-to-my-email/ Share on other sites More sharing options...
ignace Posted August 26, 2009 Share Posted August 26, 2009 mail Quote Link to comment https://forums.phpfreaks.com/topic/171976-solved-how-can-i-send-info-from-form-to-my-email/#findComment-906803 Share on other sites More sharing options...
energysuperstore09 Posted August 26, 2009 Author Share Posted August 26, 2009 Where would that go in my code <?php function send_email($from, $to, $subject, $message){ $headers = "From: ".$from."\r\n"; $headers .= "Reply-To: ".$from."\r\n"; $headers .= "Return-Path: ".$from."\r\n"; $headers .= "Content-type: text/html\r\n"; if (mail($to,$subject,$message,$headers) ) { } else { } } $messageee = ""; $subject = "Someone has Registered for Distributor Login"; $messageee .= "<html><body>"; $messageee .= "<b>Please inform Daniel.<br></b>"; $messageee .= "<br>"; $messageee .= "<br>Daniel will send an email to user once account is activated.<br>"; $messageee .= "<br>If you need assistance with your login information please contact Daniel Garvin at danielg@fleco.com"; $messageee .= "<br><br>"; $messageee .= "<br>Regards, <br>Texas Fluorescents"; $messageee .= "</body></html>"; send_email("no-reply@texasfluorescents.com", "danielg@fleco.com", $subject , $messageee); ?> Quote Link to comment https://forums.phpfreaks.com/topic/171976-solved-how-can-i-send-info-from-form-to-my-email/#findComment-906805 Share on other sites More sharing options...
ignace Posted August 26, 2009 Share Posted August 26, 2009 You already have that in your code: mail($to,$subject,$message,$headers) Quote Link to comment https://forums.phpfreaks.com/topic/171976-solved-how-can-i-send-info-from-form-to-my-email/#findComment-906807 Share on other sites More sharing options...
energysuperstore09 Posted August 26, 2009 Author Share Posted August 26, 2009 What do I need to add if I want to get the info from the fields of the form? Quote Link to comment https://forums.phpfreaks.com/topic/171976-solved-how-can-i-send-info-from-form-to-my-email/#findComment-906813 Share on other sites More sharing options...
jamesxg1 Posted August 26, 2009 Share Posted August 26, 2009 Post your form processor i will have a look. James. Quote Link to comment https://forums.phpfreaks.com/topic/171976-solved-how-can-i-send-info-from-form-to-my-email/#findComment-906816 Share on other sites More sharing options...
ignace Posted August 26, 2009 Share Posted August 26, 2009 $message = implode("\r\n", array_walk('fmessage', array_keys($_POST), array_values($_POST))); print $message; function fmessage($key, $value) { return "$key: $value"; } Outputs something like: username: energysuperstore09 password: energy email_address: energy@superstore.com Quote Link to comment https://forums.phpfreaks.com/topic/171976-solved-how-can-i-send-info-from-form-to-my-email/#findComment-906817 Share on other sites More sharing options...
energysuperstore09 Posted August 26, 2009 Author Share Posted August 26, 2009 Here is the form <form action="confirm.php" method="post" name="form1" class="dress"><br /><br /><br /><br /> <label for="repnumber"><span class="algin"><span class="login">Rep Number</span></span></label> <input name="repnumber" type="text" class="rep" size="5" /> <br /> <label for="fname"><span class="algin"><span class="login">First Name</span></span></label> <input name="fname" type="text" class="field" /> <br> <label for="lname" class="li1"><span class="algin"><span class="login">Last Name</span></span></label> <input name="lname" type="text" class="field" /> <br> <label for="cname"><span class="algin"><span class="login">Company Name</span></span></label> <input name="cname" type="text" class="field" /> <br> <label for="phone"><span class="algin"><span class="login">Phone Number</span></span></label> <input name="phone" type="text" class="field" /> <br> <label for="email"><span class="algin"><span class="login">Email Address</span></span></label> <input name="email" type="text" class="field" /> <br> <span class="formtext">You will use your email address as your username </span> <br><br><label for="password"><span class="algin"><span class="login">Password</span></span></label> <input name="pass" type="password" class="field" /> <br> <label for="password" class="login"><span class="algin">Verify Password</span></label> <input name="pass2" type="password" class="field" /><br><br /> <input type="image" src="images/register-button.jpg" class="login-submit" value="Regsiter"/> <br> <br> <br /> <br /> <br /> <br /> <br /> <br /> </form> and here is the script that processes the from <?php $email = $_POST['email']; $password = $_POST['pass']; $password2 = $_POST['pass2']; @mysql_connect("205.178.146.75","fleco2008","xxxxxx") or die("Error: unable to connect to database"); @mysql_select_db("test09"); $result = mysql_query("SELECT * FROM `loginreg` WHERE `email`='$email'"); if (mysql_num_rows($result) != 0) { die("Another account is already using that email"); } if ($password != $password2) { die("The two passwords did not match"); } $password = md5($password); mysql_query("INSERT INTO `loginreg` (`email`, `password`, `fname`, `lname`, `repnumber`, `cname`, `phone`) VALUES ('$email', '$password', '$fname', '$lname', '$repnumber', '$cname', '$phone')") or die(mysql_error()); header("Location: /account-pending.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/171976-solved-how-can-i-send-info-from-form-to-my-email/#findComment-906818 Share on other sites More sharing options...
energysuperstore09 Posted August 26, 2009 Author Share Posted August 26, 2009 and here is the code that is placed in the head of my register page <?php function send_email($from, $to, $subject, $message){ $headers = "From: ".$from."\r\n"; $headers .= "Reply-To: ".$from."\r\n"; $headers .= "Return-Path: ".$from."\r\n"; $headers .= "Content-type: text/html\r\n"; if (mail($to,$subject,$message,$headers,$repnumber,$fname,$lname,$cname,$phone,$email) ) { } else { } } $messageee = ""; $subject = "Someone has Registered for Distributor Login"; $messageee .= "<html><body>"; $messageee .= "<b>Please inform Daniel.<br></b>"; $messageee .= "<br>"; $messageee .= "<br>Daniel will send an email to user once account is activated.<br>"; $messageee .= "<br>If you need assistance with your login information please contact Daniel Garvin at danielg@fleco.com"; $messageee .= "<br><br>"; $messageee .= "<br>Regards, <br>Texas Fluorescents"; $messageee .= "</body></html>"; send_email("no-reply@texasfluorescents.com", "danielg@fleco.com", $subject , $messageee); ?> Quote Link to comment https://forums.phpfreaks.com/topic/171976-solved-how-can-i-send-info-from-form-to-my-email/#findComment-906820 Share on other sites More sharing options...
ignace Posted August 26, 2009 Share Posted August 26, 2009 You can't do: mail($to,$subject,$message,$headers,$repnumber,$fname,$lname,$cname,$phone,$email) The proper syntax is: bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] ) .. $dashedline = str_repeat('-', 70); $messageee .= "\r\n\r\n$dashedline\r\nForm Information:\r\n\r\n" . implode("\r\n", array_walk('fmessage', array_keys($_POST), array_values($_POST))); send_email('no-reply@texasfluorescents.com, danielg@fleco.com', $subject, $messageee) Quote Link to comment https://forums.phpfreaks.com/topic/171976-solved-how-can-i-send-info-from-form-to-my-email/#findComment-906825 Share on other sites More sharing options...
energysuperstore09 Posted August 26, 2009 Author Share Posted August 26, 2009 where do i place this code? Quote Link to comment https://forums.phpfreaks.com/topic/171976-solved-how-can-i-send-info-from-form-to-my-email/#findComment-906827 Share on other sites More sharing options...
ignace Posted August 26, 2009 Share Posted August 26, 2009 function send_email($from, $to, $subject, $message){ $headers = "From: ".$from."\r\n"; $headers .= "Reply-To: ".$from."\r\n"; $headers .= "Return-Path: ".$from."\r\n"; $headers .= "Content-type: text/html\r\n"; if (mail($to,$subject,$message,$headers) ) { } else { } } function fmessage($key, $value) { return "$key: $value"; } $messageee = ""; $subject = "Someone has Registered for Distributor Login"; $messageee .= "<html><body>"; $messageee .= "<b>Please inform Daniel.<br></b>"; $messageee .= "<br>"; $messageee .= "<br>Daniel will send an email to user once account is activated.<br>"; $messageee .= "<br>If you need assistance with your login information please contact Daniel Garvin at danielg@fleco.com"; $messageee .= "<br><br>"; $messageee .= "<br>Regards, <br>Texas Fluorescents"; $messageee .= "</body></html>"; $dashedline = str_repeat('-', 70); $messageee .= "\r\n\r\n$dashedline\r\nForm Information:\r\n\r\n" . implode("\r\n", array_walk('fmessage', array_keys($_POST), array_values($_POST))); send_email('no-reply@texasfluorescents.com, danielg@fleco.com', $subject, $messageee); Quote Link to comment https://forums.phpfreaks.com/topic/171976-solved-how-can-i-send-info-from-form-to-my-email/#findComment-906833 Share on other sites More sharing options...
energysuperstore09 Posted August 26, 2009 Author Share Posted August 26, 2009 I get an error when I am use this script "Only variables can be passed by reference" on line 211 which is the following $messageee .= "\r\n\r\n$dashedline\r\nForm Information:\r\n\r\n" . implode("\r\n", array_walk('fmessage', array_keys($_POST), array_values($_POST))); Quote Link to comment https://forums.phpfreaks.com/topic/171976-solved-how-can-i-send-info-from-form-to-my-email/#findComment-906839 Share on other sites More sharing options...
ignace Posted August 26, 2009 Share Posted August 26, 2009 $keys = array_keys($_POST); $values = array_keys($_POST); $messageee .= "\r\n\r\n$dashedline\r\nForm Information:\r\n\r\n" . implode("\r\n", array_walk('fmessage', $keys, $values)); Quote Link to comment https://forums.phpfreaks.com/topic/171976-solved-how-can-i-send-info-from-form-to-my-email/#findComment-906877 Share on other sites More sharing options...
energysuperstore09 Posted August 26, 2009 Author Share Posted August 26, 2009 so how would this look again as far as script? Thank you for your help as well. I appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/171976-solved-how-can-i-send-info-from-form-to-my-email/#findComment-906891 Share on other sites More sharing options...
energysuperstore09 Posted August 26, 2009 Author Share Posted August 26, 2009 I am getting an error on line 30 $messageee .= "\r\n\r\n$dashedline\r\nForm Information:\r\n\r\n" . implode("\r\n", array_walk('fmessage', array_keys($_POST), array_values($_POST))); Here is the full code <?php function send_email($from, $to, $subject, $message){ $headers = "From: ".$from."\r\n"; $headers .= "Reply-To: ".$from."\r\n"; $headers .= "Return-Path: ".$from."\r\n"; $headers .= "Content-type: text/html\r\n"; if (mail($to,$subject,$message,$headers) ) { } else { } } function fmessage($key, $value) { return "$key: $value"; } $messageee = ""; $subject = "Someone has Registered for Distributor Login"; $messageee .= "<html><body>"; $messageee .= "<b>Please inform Daniel.<br></b>"; $messageee .= "<br>"; $messageee .= "<br>Daniel will send an email to user once account is activated.<br>"; $messageee .= "<br>If you need assistance with your login information please contact Daniel Garvin at danielg@fleco.com"; $messageee .= "<br><br>"; $messageee .= "<br>Regards, <br>Texas Fluorescents"; $messageee .= "</body></html>"; $dashedline = str_repeat('-', 70); $messageee .= "\r\n\r\n$dashedline\r\nForm Information:\r\n\r\n" . implode("\r\n", array_walk('fmessage', array_keys($_POST), array_values($_POST))); send_email('no-reply@texasfluorescents.com, danielg@fleco.com', $subject, $messageee); ?> Quote Link to comment https://forums.phpfreaks.com/topic/171976-solved-how-can-i-send-info-from-form-to-my-email/#findComment-906919 Share on other sites More sharing options...
ignace Posted August 26, 2009 Share Posted August 26, 2009 $keys = array_keys($_POST); $values = array_keys($_POST); $messageee .= "\r\n\r\n$dashedline\r\nForm Information:\r\n\r\n" . implode("\r\n", array_walk('fmessage', $keys, $values)); Please apply this first. Quote Link to comment https://forums.phpfreaks.com/topic/171976-solved-how-can-i-send-info-from-form-to-my-email/#findComment-907029 Share on other sites More sharing options...
energysuperstore09 Posted August 26, 2009 Author Share Posted August 26, 2009 So if I copy the script to my confirm.php page then i should be able to get the data Quote Link to comment https://forums.phpfreaks.com/topic/171976-solved-how-can-i-send-info-from-form-to-my-email/#findComment-907072 Share on other sites More sharing options...
ignace Posted August 27, 2009 Share Posted August 27, 2009 So if I copy the script to my confirm.php page then i should be able to get the data If you mean it will be present in the e-mail then yes. Quote Link to comment https://forums.phpfreaks.com/topic/171976-solved-how-can-i-send-info-from-form-to-my-email/#findComment-907356 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.