Ecopetition
28 Aug 2006, 01:27 PM
My website (www.ecopetition.org) hosts a petition. I want to make it so that when someone signs the petition, they are sent an e-mail to the address they supply. Here is my code
<?php
$host="localhost"; // Host name
$username="X"; // Mysql username
$password="X"; // Mysql password
$db_name="X"; // Database name
$tbl_name="X"; //
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect server ");
mysql_select_db("$db_name")or die("cannot select DB");
$datetime=date("y-m-d h:i:s"); //date time
$sql="INSERT INTO $tbl_name(name, email, postcodezip, country, newsletter)VALUES('$name', '$email', '$postcodezip', '$country', '$newsletter')";
$result=mysql_query($sql);
//check if query successful
if($result){
echo "";
echo "Please wait while our server redirects you to the confirmation page...";
echo "<BR>";
echo "<a href='#'>Back to site.</a>"; // link to view guestbook page
}
else {
echo "ERROR. Please contact the administrator.";
}
mysql_close();
?>
Can anyone alter the code so that I can put an e-mail address in that i want the e-mail to appear to be from?
I'd be able to make the message which is sent ;)
I appreciate your help and time.
<?php
$host="localhost"; // Host name
$username="X"; // Mysql username
$password="X"; // Mysql password
$db_name="X"; // Database name
$tbl_name="X"; //
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect server ");
mysql_select_db("$db_name")or die("cannot select DB");
$datetime=date("y-m-d h:i:s"); //date time
$sql="INSERT INTO $tbl_name(name, email, postcodezip, country, newsletter)VALUES('$name', '$email', '$postcodezip', '$country', '$newsletter')";
$result=mysql_query($sql);
//check if query successful
if($result){
echo "";
echo "Please wait while our server redirects you to the confirmation page...";
echo "<BR>";
echo "<a href='#'>Back to site.</a>"; // link to view guestbook page
}
else {
echo "ERROR. Please contact the administrator.";
}
mysql_close();
?>
Can anyone alter the code so that I can put an e-mail address in that i want the e-mail to appear to be from?
I'd be able to make the message which is sent ;)
I appreciate your help and time.