简体   繁体   中英

Sending form information to an email address stored in database

Hi what I am trying to do is to create a form that a user fills out some information,on submit that information is then sent to email addresses that they have already saved into a database. I have created an sql statement where the user saves the persons name and email like so

  mysql_select_db("lr", $con);
 $sql="INSERT INTO bridesmaids (FirstName, email)
VALUES
('$_POST[firstname]','$_POST[email]')";

if (!mysql_query($sql,$con))

  {

  die('Error: ' . mysql_error());

  }
echo "Bridesmaid added"; 
?>

So in my other form I would like the information to be sent to the "email" field in this table, is this possible?

通常,您通常会从数据库中获取电子邮件,然后遍历它们,从而向您发送邮件, http://www.w3schools.com/php/php_mail.asp是发送邮件的良好起点。

Yes, its possible, but you need a mail server to use in order to send emails. if you are using an online hosting service that includes emails, it should be enough to use this line of code:

mail("to@email.com", "message subject", "message body", "From: from@email.com");

if you have a separate mail server you need to specify the mail server configuration in the php.ini file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM