使用css和js重新设置登录表单样式后,将其粘贴在登录页面上

时间:2017-12-04 04:31:39

标签: javascript php jquery html css

我知道之前发过了类似的问题,我已经通过了它,这里是链接Login code doesn't work, stay stuck on log in page,但我们的代码完全不同,我已经完成了3个小时但是没有解。这是我的代码在我设计之前最初看起来的样子。



<body>
<?php
	require('db.php');
	session_start();
    // If form submitted, insert values into the database.
    if (isset($_POST['username'])){
		
		$username = stripslashes($_REQUEST['username']); // removes backslashes
		$username = mysqli_real_escape_string($con,$username); //escapes special characters in a string
		$password = stripslashes($_REQUEST['password']);
		$password = mysqli_real_escape_string($con,$password);
		
	//Checking is user existing in the database or not
        $query = "SELECT * FROM `users` WHERE username='$username' and password='".md5($password)."'";
		$result = mysqli_query($con,$query) or die(mysql_error());
		$rows = mysqli_num_rows($result);
        if($rows==1){
			$_SESSION['username'] = $username;
			header("Location:../user/page/emergency.php"); // Redirect user to index.php
            }else{
				echo "<div class='form'><h3>Username/password is incorrect.</h3><br/>Click here to <a href='login.php'>Login</a></div>";
				}
    }else{
?>
<div class="form">
<h1>Log In</h1>
<form action="" method="post" name="login">
<input type="text" name="username" placeholder="Username" required />
<input type="password" name="password" placeholder="Password" required />
<input name="submit" type="submit" value="Login" />
</form>

<br /><br />

</div>
<?php } ?>


</body>
&#13;
&#13;
&#13;

以下是我尝试使用css和javascript设置样式后的样子。

&#13;
&#13;
<body>

<h2> Selamat Datang, Sila Log Masuk Untuk Kemaskini</h2>

<?php
	require('db.php');
	session_start();
    // If form submitted, insert values into the database.
    if (isset($_POST['username'])){
		
		$username = stripslashes($_REQUEST['username']); // removes backslashes
		$username = mysqli_real_escape_string($con,$username); //escapes special characters in a string
		$password = stripslashes($_REQUEST['password']);
		$password = mysqli_real_escape_string($con,$password);
		
	//Checking is user existing in the database or not
        $query = "SELECT * FROM `users` WHERE username='$username' and password='".md5($password)."'";
		$result = mysqli_query($con,$query) or die(mysql_error());
		$rows = mysqli_num_rows($result);
        if($rows==1){
			$_SESSION['username'] = $username;
			header("Location:../user/page/emergency.php"); // direct user to update page
            }else{
				echo "<div class='form'><h3>Username/password is incorrect.</h3><br/>Click here to <a href='login.php'>Login</a></div>";
				}
    }else{
?>
 <div class="container">
	<section id="content">
		<form action="" method="post" name="login">
			<h1>Daftar Masuk</h1>
			
			<div>
			<input type="text" placeholder= "Username" required ="" id ="username"/>
			</div>
			
			<div>
			<input type="password" placeholder= "Password" required ="" id ="password"/>
			</div>
			
			
		   <input name="submit" type="submit" value="Login" />
			
			
			</form>
		</section> 
 </div>
<?php } ?>
  <script  src="js/index.js"></script>
 
</body>
&#13;
&#13;
&#13;

一旦我设计了它,表单就会停留在登录页面上。帮帮我,我该怎么办?非常感谢任何建议和指导。

更新

好吧,伙计们,我已经找到了问题的根源,我只需要在第二张表格上删除。

1 个答案:

答案 0 :(得分:0)

事实证明,在我做样式的表单上,我只需要删除标记

所以来自

&#13;
&#13;
<div class="container">
	<section id="content">
		<form action="" method="post" name="login">
			<h1>Daftar Masuk</h1>
			
			<div>
			<input type="text" placeholder= "Username" required ="" id ="username"/>
			</div>
			
			<div>
			<input type="password" placeholder= "Password" required ="" id ="password"/>
			</div>
			
			
		   <input name="submit" type="submit" value="Login" />
			
			
			</form>
		</section> 
 </div>
&#13;
&#13;
&#13;

&#13;
&#13;
<div class="container">
	<section id="content">
		<form action="" method="post" name="login">
			<h1>Daftar Masuk</h1>
			
			
			<input type="text" placeholder= "Username" required ="" id ="username"/>
			
			
			
			<input type="password" placeholder= "Password" required ="" id ="password"/>
		
			
			
		   <input name="submit" type="submit" value="Login" />
			
			
			</form>
		</section> 
 </div>
&#13;
&#13;
&#13;