ball420 Posted April 16, 2008 Share Posted April 16, 2008 I have gotten my script to write to my sql database no problem works great. I want it then to email, I have been staring at this for hours and trying a thousand things. can someone give me some insight on what i might be doing wrong. Thanks for the help <?php $host= 'slkd'; $username= 'sd'; $password= 'm5sdd'; $db_name= 'db2sdfsdsfsdf77'; $tbl_name= 'entries'; $firstname = $_POST['firstname']; $lasttname = $_POST['lastname']; $email = $_POST['email']; $location = $_POST['location']; $age = $_POST['age']; mysql_connect("$host", "$username", "$password")or die("cannot connect server "); mysql_select_db("$db_name")or die("cannot select DB"); $sql="INSERT INTO $tbl_name (firstname, lastname, email, location, age) VALUES ('$firstname', '$lastname', '$email','$location','$age')"; $result=mysql_query($sql) or die("query error:".mysql_error() ); if($result){ $firstname = $_POST['firstname']; $lasttname = $_POST['lastname']; $email = $_POST['email']; $location = $_POST['location']; $age = $_POST['age']; $sendTo = "[email protected]"; $subject = "Signup"; $sign = "Sign up"; $up = "form"; $emailer ="promotions.com"; $messager = "Someone has signed up on ations.com" $headers = "From: " . $_POST["$sign"] ." ". $_POST["$up"] . "<" . $_POST["$emailer"] .">\r\n"; $headers .= "Reply-To: " . $_POST["$emailer"] . "\r\n"; $headers .= "Return-path: " . $_POST["$emailer"]; mail($sendTo, $subject, $messager, $headers); } else { echo "ERROR"; } mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/101295-sql-entry-then-email/ Share on other sites More sharing options...
jonoc33 Posted April 16, 2008 Share Posted April 16, 2008 $messager = "Someone has signed up on ations.com" Change that to this: $messager = "Someone has signed up on ations.com"; You forgot to add a colon . Another problem might be that you havent connected to SMTP. Link to comment https://forums.phpfreaks.com/topic/101295-sql-entry-then-email/#findComment-518124 Share on other sites More sharing options...
ball420 Posted April 17, 2008 Author Share Posted April 17, 2008 thanks for your help i was really struggling with it. I did solve the issue what i ended up doing was on the submit of the form it calls two different scripts one for the email and the other to enter the info into the database. I didn't fix the problem with the script but i did get it to work. thanks again for your much appricated. Link to comment https://forums.phpfreaks.com/topic/101295-sql-entry-then-email/#findComment-519980 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.