我是一個真正的初學者,我做了一個簡單的login.php
,但我想知道如何使登錄按鈕重定向到另一個頁面。該腳本我有是:php登錄按鈕,重定向
<php
//Start the Session
session_start();
require('connect.php');
//3. If the form is submitted or not.
//3.1 If the form is submitted
if (isset($_POST['username']) and isset($_POST['password'])) {
//3.1.1 Assigning posted values to variables.
$username = $_POST['username'];
$password = $_POST['password'];
//3.1.2 Checking the values are existing in the database or not
$query = "SELECT * FROM `user` WHERE username='$username' and password='$password'";
$result = mysql_query($query) or die(mysql_error());
$count = mysql_num_rows($result);
//3.1.2 If the posted values are equal to the database values, then session will be created for the user.
if ($count == 1) {
$_SESSION['username'] = $username;
} else {
//3.1.3 If the login credentials doesn't match, he will be shown with an error message.
echo "Invalid Login Credentials.";
}
}
//3.1.4 if the user is logged in Greets the user with message
if (isset($_SESSION['username'])) {
$username = $_SESSION['username'];
echo "Hello " . $username . "
";
echo "This is the Members Area
";
?>
<!DOCTYPE html>
<head>
<title>Test Login</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<!-- Form for logging in the users -->
<div class="register-form">
<php
\t if(isset($msg) & !empty($msg)){
\t \t echo $msg;
\t }
?>
<h1>Login</h1>
<form action="" method="POST">
<p><label>User Name : </label>
\t <input id="username" type="text" name="username" placeholder="username" /></p>
<p><label>Password : </label>
\t <input id="password" type="password" name="password" placeholder="password" /></p>
<a class="btn" href="register.php">Signup</a>
<input class="btn register" type="submit" name="submit" value="Login" />
</form>
</div>
<php } ?>
,我希望它重定向到頁面是在位於父目錄名爲Site/form.html。 感謝您的任何和所有輸入!
告訴我,這是一個錯字'
'if(isset($ msg)&!empty($ msg)){'不會運行,語法錯誤。 –
我應該在dreamweaver中使用它不會註冊,除非我刪除?它只是顯示爲帶有問號的文本。 – KSykes