连接登录到仪表板(不检测密码)



请检查我的代码,并告诉我如何在单击提交按钮时制作它,它会转到仪表板页面。但它不起作用。帮助我认为功能不起作用。我搞不清楚问题出在哪里。我已经创建了我的数据库,并在该数据库中添加了详细信息。

(我添加了数据库,(我也会附加GitHub链接。请检查一下你是否有时间。

https://github.com/Dushan26/my_assignment.git

<?php  

$host="localhost";
$user="root";
$password="";
$db="project_db";
$connect_error = 'Sorry, we're experiencing connection issues.';
$con=mysqli_connect($host,$user,$password);
mysqli_select_db($con, 'project_db') or die(mysqli_error($con));
if(isset($_POST['username'])){

$uname=$_POST['txtUsername'];
$password=$_POST['txtPassword'];

$sql="select * from user where email='".$uname."'AND password='".$password."' limit 1";

$result=mysql_query($sql);

if(mysql_num_rows($result)==1){
echo " You Have Successfully Logged in";
exit();
}
else{
echo " You Have Entered Incorrect Password";
exit();
}

}
?>

<html>
<head>
<title>Online class</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">

<style>
body{
width: 100%;
height: 400px;
background-image:url(../assets/img/online-class.png);
background-size: cover;
}</style>

</head>
<body>
<div class="container">
<div class="row"><!--row 01-->
<div class="col-sm-9 col-md-7 col-lg-5 mx-auto"><!--row 02-->
<div class="card my-5"> <!-- card-->
<div class="card-body"><!--card body-->

<h5 class="text-center my-2"><b>:::LOGIN:::</h5></b><br>
<form class="form" action="" role="form" method="POST">

<div clss="my-5" id="divEmail"><!--txtusername-->
<input type="text" id="email" name="txtUsername" class="form-control" placeholder="Enter Email">
</div><!--end oftxtusername--><br>

<div clss="my-5" id="divPassword"><!-- password-->
<input type="password" id="password" name="txtPassword" class="form-control" placeholder="Enter Password">
</div><!--end of password--><br>

<div clss="my-4"><!-- button-->
<button type="submit" id="btnSubmit" class="btn btn-danger btn-block text-uppercase col-12">Submit</button>
</div><!--end of button-->




<hr class="my-4"><h6>Enter Your Email & Password</h6>


</form><!--end of form-->


</div><!--end of card body-->
</div><!--end of card-->
</div><!--end row 02-->

</div><!--end of row 01-->
</div><!--end of container-->

我认为您的提交按钮是一种"提交";。当它在表单中并单击时,默认情况下,无论您的单击功能如何,它都会提交表单。

您可以将按钮类型更改为";按钮";或者更改点击功能以停止表单提交

$("form").submit(function (e) {
e.preventDefault();
// your code here
});

最新更新