Jump to content

php registration


soundworks

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.