if(isset($_POST['add_user'])){
$passw = trim(htmlentities($_POST['password']));
$encrypted = enc_salt($passw);
$con = "true";
$sql = "SELECT * FROM users WHERE username='".$_POST['user_name']."'";
$result = $database->query($sql);
$row = $database->fetch_array($result);
if($row!=""){
$con="false";
}
if($con!="false"){
$sql = "INSERT INTO photo_gallery.users (username, password, first_name, last_name)";
$sql .= " VALUES ('".trim(htmlentities($_POST['user_name']))."','".$encrypted."', '".trim(htmlentities($_POST['first_name']))."', '".trim(htmlentities($_POST['last_name']))."')";
$result_set = $database->query($sql);
echo '<script type="text/javascript">alert("Account Created!");</script>';}
else{
echo '<script type="text/javascript">alert("This username already exist!");</script>';
}
}
i already had this code in adding users
and my function enc_salt is:
function enc_salt($string){
//encrypting
$pass_word = sha1($string);
$salt = md5("user");
$pepper = "cxlkdawpoalsk";
$pass_encrypted = $salt.$pass_word.$pepper;
return $pass_encrypted;
}
my problem right now is the time when logging in.