soundworks Posted September 1, 2008 Share Posted September 1, 2008 Hi i need help i couldnt show the error msg when both of the password are key wrongly and it still insert into the database. thank u <?php session_start(); include "includes/mysql_connect.php"; include "includes/redirect.php"; $username = $_POST['_username']; $query_username = "SELECT `id` FROM fs_user WHERE `username`='$username' "; if (!empty($_POST['_password']) && !empty($_SESSION['username'])) { if ($_POST['_password'] != $_POST['_password2']) { $_SESSION['error'] = 'The 2 passwords you have entered do not match.</font>'; } else { $password = $_POST['_password']; } } else { $_SESSION['error'] = 'Please provide a password and username.</font>'; } $exists = query_to_array($query_username); //print_r($exists); if ($exists != ''){ $_SESSION['err_msg'] = "Please try another username"; do_redirect('register.php'); }else{ $fullname = $_POST['_fullname']; $email = $_POST['_emailaddress']; $password = $_POST['_password']; $query_new_user = "INSERT INTO fs_user (`username`, `password`, `email`, `fullname`) VALUES ('$username','$password','$email','$fullname')"; query($query_new_user); $profile = query_to_array("SELECT `id`, `fullname`, `email` FROM fs_user WHERE `username`='$username'"); $_SESSION["u_id"]= $profile["id"]; $_SESSION["u_fullname"]= $profile["fullname"]; $_SESSION["u_email"]= $profile["email"]; $_SESSION["username"]= $username; do_redirect('index.php'); } ?> Link to comment https://forums.phpfreaks.com/topic/122180-php-registration/ Share on other sites More sharing options...
ratcateme Posted September 1, 2008 Share Posted September 1, 2008 so what is wrong?? Link to comment https://forums.phpfreaks.com/topic/122180-php-registration/#findComment-630759 Share on other sites More sharing options...
soundworks Posted September 1, 2008 Author Share Posted September 1, 2008 so what is wrong?? i couldnt show the error msg when both of the password are key wrongly and it still insert into the database. Link to comment https://forums.phpfreaks.com/topic/122180-php-registration/#findComment-630785 Share on other sites More sharing options...
soundworks Posted September 1, 2008 Author Share Posted September 1, 2008 anybody can help? thanks Link to comment https://forums.phpfreaks.com/topic/122180-php-registration/#findComment-631027 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.