我已经做了一个登录和注册页面来检查用户的真实性。
php文件在XAMPP服务器上工作正常。但是当我将其上传到 000webhost.com 时,SESSION 变量没有被存储。
session_start();
$email = $_POST['email'];
$pass = $_POST['pass'];
$check = mysqli_query($con , "Select * from sellers where email = '$email'");
if(mysqli_num_rows($check)>=1){
while($row = mysqli_fetch_array($check)){
$dbemail = $row['email'];
$dbpass = $row['pass'];
}
if($email==$dbemail && md5($pass)==$dbpass){
$cookPass = $pass;
$pass=md5($pass);
//setcookie('sellMail', $email, time()+(86400*30));
$_SESSION['sellMail'] = $email;
if(isset($_POST['remember'])){
setcookie('email', $email, time()+(86400*30));
setcookie('pass', $cookPass, time()+(86400*30));
}else{
setcookie('email', $email, time()-(86400*30));
setcookie('pass', $cookPass, time()-(86400*30));
}
echo "<script>window.open('Seller.php', '_self')</script>";
}else{
echo "<script>alert('Email or Password is Wrong')</script>";
echo "<script>window.open('index.php', '_self')</script>";
}
}else{
echo "<script>alert('User Does Not exist')</script>";
echo "<script>window.open('index.php', '_self')</script>";
PHP代码来检查登录。
让我们看看这个。
确保文件夹中有一个 .htaccess 文件public_html如果没有,则创建一个名为 .htaccess 的文件,然后,
在您的 .htaccess 文件中添加这段代码,这将解决您的问题,
php_flag output_buffering 上
我想知道你是否还在寻找答案,但让我们看看这个。
您可以随时尝试将会话设置为自动启动,方法是在 .htaccess 上写下此行
php_flag session.auto_start on
并且不要忘记删除您的session_start();
,因为我们已经开始了会话。
我上面所有的想法都是 000webhostapp.com 但它不是会话变量,但它可以在 xampp 服务器上完美运行。