Login system question

This is my code, I have the login/signup forms in the same page (Bootstrap Template).

<?php require 'connections.php'; ?> <?php if(isset($_POST['btn-signup'])) { session_start(); $username = $_POST['username']; $email = $_POST['email']; $passwd = $_POST['passwd']; $sql = $con->query("INSERT INTO users (Email, Username, Password)values('{$email}', '{$username}', '{$passwd}')"); } ?> <?php if(isset($_POST['btn-login'])) { $loginemail = $_POST['login-username']; $loginpassword = $_POST['login-password']; $result = $con->query("select * from users where Email='$loginemail' AND Password='$loginpassword'"); $row = $result->fetch(MYSQLI_BOTH); session_start(); $_SESSION["UserID"] = $row['UserID']; hearder('Location: index.html'); } ?>

My issue is that logging in does nothing, it just shows what I put in the URL bar. However signing up still works.

You really need to look at prepared statements for one thing.

What is your form code? I am thinking you are either using a standard button, but I don’t know yet.

I only notice that header is spelt incorrectly in your code example. If you copied and pasted the code then maybe addressing that may get you on the right track.

Sponsor our Newsletter | Privacy Policy | Terms of Service