[Solved] PHP website debug [duplicate]


First of all, paste your code correctly… You are missing </table> and </form> in the end…

Second of all, you were missing a simple apostrophe and a semi-colon in the line

$result = mysquli_query($con, 'select * from account where username="'.$username.'" and password="'.$password.'")

Also, you should use mysqli_query instead of mysqlui_query… Typo!

Your code should be as follows :

<?php
session_start();
if (isset($_POST['bttLogin'])){
    require 'connect.php';
    $username = $_POST['username'];
    $password = $_POST['password'];
    $result = mysqli_query($con, 'select * from account where username="'.$username.'" and password="'.$password.'"');
    if(mysqli_num_rows($result)==1) {
        $_SESSION['username'] = $username;
        header("Location: welcome.php");
    }
    else
        echo "account is invalid";
}
?>

<form method="post">
<table cellpadding="2" cellspacing="2" border="1">
    <tr>
        <td>Username</td>
        <td><input type="text" name="username"></td>
    </tr>
    <tr>
        <td>Password</td>
        <td><input type="password"" name="password"></td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td><input type="submit" name="bttLogin" value="Login"></td>
    </tr>
</table>
</form>

7

solved PHP website debug [duplicate]