|
Not tested the below script, I just wrote it but it should work. Make sure you have ID in the database set as auto_increment. Also make sure the form text box names are "email", "name", "mobile".
Any errors let me know and I will fix it.
<?php
if (isset($_POST) {
if ($_POST['email'] && $_POST['name'] && $_POST['mobile'] != "") {
$sql = mysql_query("SELECT * FROM `table_name` WHERE `NAME` = " . $_POST['email'] . " LIMIT 1");
$rows = mysql_num_rows($sql);
if ($rows == "1") {
echo ?>
<p>Sorry that email address has been used to register here before, please try another.</p>(INSERT FORM AGAIN HERE)
<?php ;
}
else {
$ins = mysql_query("INSERT INTO `table_name` (`ID`, `Name`, `Email`, `MobileNo`) VALUES ('', '" . $_POST['name'] . "', '" . $_POST['email'] . "', '" . $_POST['mobile'] . "'));
echo ?>
<p>Thanks for registering... You have been added to our database.</p>
<?php ;
}
}
else {
echo ?><p>You did note complete all fields in the form please try again.</p> (INSERT FORM AGAIN)
<?php ;
}
else {
echo ?>
(INSERT FORM HERE)
<?php ;
}
?>
__________________
I have become death, destroyer of worlds.
|