Jump to content

User Registration


ossieboy

Recommended Posts

Hi

Can anyone help with this problem it seems very simple, I am not an experienced PHP coder but keen to progress.

I am trying to create a User Registration project but have a problem. every time I try to login using  mysqli_fetch_assoc it drops through to my error Invalid Email /Password it seems that the mysqli code is not working correctly but I do not understand this function enough can anyone help. I have attached the coding if this helps.

This is the function

function Login_Attempt($Email,$Password){
    $Query="SELECT * FROM admin_panel WHERE email='$Email'";
    $Execute=mysqli_query($Connection,$Query);
    if($admin=mysqli_fetch_assoc($Execute)){
        if(Password_Check($Password,$admin["password"])){
            echo $Email;
             return $admin ;
            
        }
        }else{
        return null;    }
    }

 

This is the code I am using 

Login.php

<?php require_once("Include/Session.php"); ?>
<?php require_once("Include/Styles.css"); ?>
<?php require_once("Include/Functions.php"); ?>
<?php require_once("Include/DB.php"); ?>
<?php
if(isset($_POST["Submit"])){
$Email=mysqli_real_escape_string($Connection,$_POST["Email"]);
$Password=mysqli_real_escape_string($Connection,$_POST["Password"]);
if(empty($Email)||empty($Password)){
    $_SESSION["message"]="All Fields must be filled out";
    Redirect_To("Login.php");
}else{
    if(ConfirmingAccountActiveStatus()){
    $Found_Account=Login_Attempt($Email,$Password);
    if($Found_Account){
        $_SESSION["User_Id"]=$Found_Account['id'];
        $_SESSION["User_Name"]=$Found_Account['username'];
        $_SESSION["User_Email"]=$Found_Account['email'];
        if(isset($_POST["Remember"])){
            $ExpireTime=time()+86400;
            setcookie("SettingEmail",$Email,$ExpireTime);
            setcookie("SettingName",$Username,$ExpireTime);
        }
        
    Redirect_To("Welcome.php");
    }else{
        $_SESSION["message"]="Invalid Email / Password";
    Redirect_To("Login.php");
    }

    }else{
    $_SESSION["message"]="Account Confirmation Required";
    Redirect_To("Login.php");
    }
}
}
?>
<?php ?>
<!DOCTYPE>
<html>
<head>
        <title>Login</title>
</head>
    <body>
<div>        
<?php echo Message(); ?>
<?php echo SuccessMessage(); ?></div>
<div id="centerpage">
<br><a href="User_Registration.php"><span class="FieldInfo">Don't Have an account? Creat One !</span></a><br>
    <form action="Login.php" method="post">
    <fieldset>
<span class="FieldInfo">Email:</span><br><input type="email" Name="Email" value=""><br>
<span class="FieldInfo">Password:</span><br><input type="password" Name="Password" value=""><br>
<input type="checkbox" Name="Remember" ><span class="FieldInfo"> &nbsp;Remember me<span class="FieldInfo"><br>
<br><a href="Recover_Account.php"><span class="FieldInfo">Forgot Password</span></a>

<br><input type="Submit" Name="Submit" value="Login"><br>
        
        
    </fieldset>    
            
        
    </form>
    </div>
        
    </body>
</html>

Hope this Helps 

Ossieboy

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.