-2
我在我們的web服務器上部署web應用程序時遇到了一個錯誤,該應用程序在localhost上完美運行。 這裏是我啓動登錄頁面時顯示的內容。php html服務器部署
login($_POST['email'], $_POST['password']); $email=$_POST['email']; $_SESSION["email"] = "$email"; } ?>
這裏是我的login.php源
<?php
session_start();
if (isset($_POST['login']))
{
include_once 'user-dbop.php';
$objUser = new User();
$objUser->login($_POST['email'], $_POST['password']);
$email=$_POST['email'];
$_SESSION["email"] = "$email";
}
?>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<title>connexion </title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://fortawesome.github.io/Font-Awesome/assets/font-awesome/css/font-awesome.css">
<!--<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>-->
<link href='https://fonts.googleapis.com/css?family=Indie+Flower' rel='stylesheet' type='text/css'>
<style>
.at_background{
background: url(back2.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.at_font{
color: navy;
/*font-family: 'Indie Flower', cursive;*/
font-family: 'Lobster', cursive;
}
</style>
<style type="text/css">
body {
/**scalable background to fill available viewport**/
background: url(img/bleu.jpg) center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
</style>
<body>
<div class="container">
<div style=" margin-top: 5px" class="well well-sm">
<h1 style="color: white"><img src="img/mobilis-edd.png" class="img-rounded pull-xs-left" width="150" height="55"> <mark style="background-color:rgb(224,224,224) ">Gestion des demandes de récupirations</mark></h1>
</div>
<nav class="navbar navbar-inverse" style="background-color: #505050 ;">
<div class="container-fluid">
<div class="navbar-header">
<a class="glyphicon glyphicon-home navbar-brand" href="index.php"></a>
</div>
</div>
</nav>
<div class="row well well-lg ">
<div >
<div class="jumbotron ">
<h2 > Veuillez vous connecter !</h2>
<hr>
<form action="" method="post">
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" id="email" placeholder="Enter email" name="email" required>
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd" placeholder="Enter password" name="password">
</div>
<button type="submit" class="btn btn-primary" name="login">Connecter</button>
</form>
</div>
</div>
</div>
<div style="background-color: rgb(81,80,82)" class="panel-footer panel-custom">
<p style="color: #ffffff;" class="text-center">Equipe developement WEB DSI [email protected]</b>
</div>
</div>
</body>
</html>
和我的用戶drop.php所有功能
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<title>fonction</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://fortawesome.github.io/Font-Awesome/assets/font-awesome/css/font-awesome.css">
<!--<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>-->
<link href='https://fonts.googleapis.com/css?family=Indie+Flower' rel='stylesheet' type='text/css'>
<?php
if (!isset($_SESSION))
session_start();
include_once 'config.php';
class User {
var $dbObj;
public function __construct() {
$this->dbObj = new db();
}
public function insert($password, $name, $address, $contact_no, $about, $email, $affectation) {
$password = hash('sha256', $password);
$sql = " INSERT INTO `user`"
. " (`password`,`name`,`address`,`contact_no`,`about`,`email`,`affectation`,`user_id`)"
. " VALUES('$password','$name','$address','$contact_no','$about','$email','$affectation','')";
echo $sql;
return $this->dbObj->ExecuteQuery($sql, 2);
}
public function update( $password, $name, $address, $contact_no, $about, $old_password, $email, $user_id) {
if (empty($password))
$password = $old_password;
else
$password = hash('sha256', $password);
$sql = " UPDATE"
. " user "
. " SET password = '$password',name = '$name',address = '$address',"
. " contact_no = '$contact_no',about = '$about', email = '$email'"
. " WHERE user_id = '$user_id'";
return $this->dbObj->ExecuteQuery($sql, 3);
}
public function select_by_id($user_id) {
$sql = " SELECT"
. " user_id,user_name,password,name,address,contact_no,about,email"
. " FROM user WHERE user_id = '$user_id'";
return $this->dbObj->ExecuteQuery($sql, 1);
}
public function delete_account($user_id) {
$sql = " DELETE FROM user WHERE user_id = '$user_id'";
return $this->dbObj->ExecuteQuery($sql, 3);
}
public function login($email, $password) {
$password = hash('sha256', $password);
$sql = " SELECT"
. " name, email"
. " FROM user WHERE"
. " email = '$email' AND password = '$password'";
$data = $this->dbObj->ExecuteQuery($sql, 1);
if (mysqli_num_rows($data) > 0) {
$fetch_data = mysqli_fetch_assoc($data);
$_SESSION['user_id'] = $fetch_data['user_id'];
$_SESSION['name'] = $fetch_data['name'];
echo "<SCRIPT>alert(\"marquer sont message\");</SCRIPT>";
header("location:list.php");
}
else {
echo "<script >
window.location='login.php';
alert('Invalid User Name or Password !!');
</script>";
}
}
}
?>
</html>
這是什麼問題? – Epodax
用'session_start()'替換'if(!isset($ _ SESSION))session_start()'' – Justinas
你對此有何疑問? –