I am stuck on my coding: I need to check that the email is legitimate and also check if the passwords match.
As you can see I've tried to make sure it has '@' in it, but it doesn't work.
<?php
error_reporting(1);
include("../site/inc/config.php");
if (isset($_POST['submit'])) {
$username = clean($_POST['username']);
$password = clean($_POST['password']);
$pass_conf = clean($_POST['password2']);
$email = clean($_POST['email']);
$ip = $_SERVER['REMOTE_ADDR'];
$reg_date = date("F jS, Y - g:i a");
$md5 = md5($password);
if(!$username){
header("Location: /site/register.php?error=1");
//error
die;
}
if(!$password){
header("Location: /site/register.php?error=1");
//error
die;
}
if(!$pass_conf){
header("Location: /site/register.php?error=1");
//error
die;
}
if(!$email){
header("Location: /site/register.php?error=1");
//error
die;
}
$sign = '@';
if (strpos($email,$sign) !== true) {
header("Location: /site/register.php?error=122");
//error
die;
}
$check_user = mysql_query("SELECT `username` FROM `users` WHERE `username` = '".$username."'");
if(mysql_num_rows($check_user) !== 0){
header("Location: /site/register.php?error=2");
//error
die;
}
$check_email = mysql_query("SELECT `email` FROM `users` WHERE `email` = '".$email."'");
if(mysql_num_rows($check_email) !== 0){
header("Location: /site/register.php?error=3");
//error
die;
}
mysql_query("INSERT INTO `users` (`username`, `password`, `email`, `ip`, `rank`, `reg_date`) VALUES ('$username', '$md5', '$email', '$ip', '1', '$reg_date')");
header("Location: /site/register.php?success=1");
} else {
header("Location: register.php?error=4");
}
?>