php - 与 sqlsrv azure 一起使用时,php 中的 "session_register"命令失败

标签 php azure

我有这样一个index.php页面;

<?php
include("Config.php");
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST")
{
// username and password sent from Form 
$myusername=addslashes($_POST['username']); 
$mypassword=addslashes($_POST['password']);

$sql="SELECT ID, username, password FROM login WHERE username='$myusername' and password='$mypassword'";
$result=sqlsrv_query($bd, $sql);
$row=sqlsrv_fetch_array($result);
$active=$row['active'];
$count=sqlsrv_num_rows($result);


// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1)
{
session_register("myusername");
$_SESSION['login_user']=$myusername;

header("location: website/index.php");
}
else 
{
$error="Your Login Name or Password is invalid";
}
}
?>

我不明白出了什么问题,没有连接问题,

从html表单读取数据没有问题,

但是当我点击登录时,它仍然进入同一页面,而不是“website/index.php”。

如果session_register出现问题,可以采取什么替代方案?

我该如何管理它?

感谢您的帮助。

最佳答案

替代方法是使用 session 数组在 session 中存储数据,就像您已经完成的那样

$_SESSION['myusername']=$myusername;

注意:我已经评论过这个答案。但我将此作为答案帖子,以便这个问题可能不会被列为未答复,因为OP的问题已经解决,如下面的问题评论所示。

关于php - 与 sqlsrv azure 一起使用时,php 中的 "session_register"命令失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23843013/

相关文章:

php - 当创建csv导入mysql表时需要为索引添加空值?

php - Joomla K2 额外字段 : Differentiated Display

Azure CLI v1 与 v2?

Node.js typescript Azure 函数 : Cannot import with absolute path ( minimal reproducible example attached)

linux - 如何更改 godaddy 中的 dns 以指向 windows azure linux vms?

php - 根据 mysql (PHP) 中的选定列制作 pdf 报告

php - 如何在我的 FormRequest 中添加自定义验证器?

php - WordPress 作者链接

azure - 什么类型的 Azure 资源可以运行 powershell 并拥有系统本地的文件系统或存储?

Node.js - 使用 azure DocumentDB 和 readDocument(链接、选项、回调)时传递分区键