我有一個登錄PHP的形式,當用戶鍵入不正確的證書,那麼它會輸出「名或密碼錯誤」,然而這是在導航網站上面的頂部擺正。這裏有一個截圖:http://imgur.com/IAsaMWH樣式文本由輸出文件撰寫
我想將文本放置在網站包裝和一個div內,以便我可以用css編輯它。
我一直在使用document.getElementById('log').innerHTML
但是這隻能當格「日誌」是PHP代碼上面的嘗試,但是PHP已經留在上面,否則我得到一個錯誤:
Warning: session_start(): Cannot send session cache limiter - headers already sent
這裏我的php/js
總之,我想要做的是當登錄憑證錯誤時,向用戶顯示一條消息「不正確的用戶名或密碼」我需要使用CSS編輯此消息,因爲我需要將其重新放置在頁面上。 如果有人能夠編輯我的代碼並向我解釋他們做了什麼 - 這將非常感激。
這是我的PHP與JS:
<?php
session_start();
include_once 'dbconnect.php';
if(isset($_SESSION['user'])!="")
{
header("Location: account.php");
}
if(isset($_POST['btn-login']))
{
$email = mysql_real_escape_string($_POST['email']);
$upass = mysql_real_escape_string($_POST['pass']);
$res=mysql_query("SELECT * FROM users WHERE email='$email'");
$row=mysql_fetch_array($res);
if($row['password']==md5($upass))
{
$_SESSION['user'] = $row['user_id'];
header("Location: account.php");
}
else
{
?>
<script>document.write('Incorrect Username or Password');</script>
<?php
}
}
?>
這裏是我的HTML
<?php include"authentication/login.php";?>
<!DOCTYPE html>
<html>
<HEAD>
<title>Website | Loign</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<?php include "includes/page_sources.php"; ?>
</HEAD>
<body>
<?php include "includes/navigation.php"; ?>
<div id="wrapper">
<div id="login-form">
<form method="post">
<input type="text" name="email" placeholder="Your Email" required />
<input type="password" name="pass" placeholder="Your Password" required />
<button type="submit" name="btn-login">Log In</button>
<a href="register.php">Sign Up</a>
</form>
</div>
</div>
<?php include "includes/footer.php"; ?>
</body>
</html>
再次感謝你的幫助提前
的PHP無關了這個問題。我們需要呈現的HTML和CSS。 – j08691
你需要網站的圖像嗎?或者我應該添加頁面的CSS代碼? –