Jump to content

Sql entry then email....


ball420

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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