Hi all,
Iβm new to php, I already made a php page for email blast but i want to add a validating email script into the existing script, does anybody know how to do it? greatly appreciate your assistance, thanks
here is the code
[php]<?php
$name = ββ;
$email = ββ;
$msg_to_user = ββ;
if ($_POST[βnameβ] != ββ) {
include_once "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 /><h4><font color="FF0000">Please type an email address ' . $name . '.</font></h4>';
} else if ($numRows > 0) {
$msg_to_user = '<br /><br /><h4><font color="FF0000">' . $email . ' is already in the system.</font></h4>';
} else {
$sql_insert = mysql_query("INSERT INTO newsletter (name, email, dateTime)
VALUES('$name','$email',now() )") or die (mysql_error());
$msg_to_user = '<br /><br /><h4><font color="0066FF">Thanks ' . $name . ', you have been added successfully.</font></h4>';
$name = "";
$email = "";
}
}
?>
Subscribe to Our Newsletter Subscribe to Our Newsletter ΒName:
Email:
<?php echo $msg_to_user; ?>
[/php]