-3

The page simply gets reloaded when I submit the form.Even when I change the PHP file for action the result is the same.No output telling me the status of how my code ran. The PHP i have shared is login.php

<?php
    include 'connect.php';
    if(isset($_POST['submit']))
    {
        $n=$_POST['name'];
        $p=$_POST['pass'];
        $q="SELECT NAME FROM user
            WHERE name='$n' and password='$p';";
        $res=$conn->query($q);
        echo "k";
        echo "<script>window.alert('here')</script>";
        if($res->num_rows == 1)
        {
            session_start();
            $_SESSION['name']=$n;
            $_SESSION['pass']=$p;
            echo "<a href='cust.php'>";
        }
        else
        {
            echo "<script>document.getElementById('resp').innerHTML='<i>please enter valid name and password</i><br></script>'";
        }
    }
?>
<html>
<head>
    <title>title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="description" content="" />
    <meta name="keywords" content="" />
    <meta name="robots" content="index,follow" />
    <!--<link rel="stylesheet" type="text/css" href="styles.css" />-->
</head>

<body>
    <form method="post" action="login.php" enctype="application/x-www-form-urlencoded">
        <!--<b>First Day of stay</b><input type="date" name="start"><br><br>
        <b>Last Day of stay</b><input type="date" name="start"><br><br>-->
        <input type="text" id="name" placeholder="Your name"><br><br>
        <input type="password" id="pass" placeholder="password"><br><br>
        <input type="submit" text="login">
        <span id="resp">
        </span>
    </form>
</body>
</html>
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Sidwa
  • 41
  • 1
  • 10

1 Answers1

0

Just a little correction:

 <input type="text" id="name" name="name" placeholder="Your name"><br><br>
 <input type="password" id="pass" name="pass" placeholder="password"><br><br>
 <input type="submit" name="submit" text="login">
Manikiran
  • 2,618
  • 1
  • 23
  • 39