嗨,我已经有一段时间了,并且一直在努力做事。它只是进入数据库,我经常检查它,但你可以假设这是一种非常乏味的做事方式。这是我当前的代码。
<?php
$name = "";
$email = "";
$msg_to_user = "";
if ($_POST['name'] != "") {
include_once "newsletter/connect_to_mysql.php";
// Be sure to filter this data to deter SQL injection, filter before querying database
$name = $_POST['name'];
$email = $_POST['email'];
$sql = mysql_query("SELECT * FROM newsletter WHERE email='$email'");
$numRows = mysql_num_rows($sql);
if (!$email) {
$msg_to_user = '<br /><br /><span style="font color="FF0000">Please type an email address ' . $name . '.</span>';
} else if ($numRows > 0) {
$msg_to_user = '<br /><br /><font color="FF0000">' . $email . ' is already in the system.</font>';
} else {
$sql_insert = mysql_query("INSERT INTO newsletter (name, email, dateTime)
VALUES('$name','$email',now() )") or die (mysql_error());
$msg_to_user = '<br /><br /><div style="color=#F47926;width:180px;">Thanks ' . $name . ', expect an email shortly!</div>';
$name = "";
$email = "";
}
}
?>
我正在尝试添加一种简单的方法来使用电子邮件和名称向我自己的电子邮件地址发送和发送电子邮件。这样我就不必经常检查数据库本身,而是查看它们出现在我的电子邮件中的样子。我希望这是有道理的。