我的 PHP 代码中有这样的代码:
<?php
require('../../server.php');
$role = strtoupper($_POST['role']);
$pool = strtoupper($_POST['pool']);
$psh = strtoupper($_POST['comp']);
if($role = "POOL")
{
$query2 = "INSERT INTO m_login (email, password, role, company_id)
VALUES ('$email', '$pass', '$role', '$pool')";
}
else
{
$query2 = "INSERT INTO m_login (email, password, role, company_id)
VALUES ('$email', '$pass', '$role', '$psh')";
}
if (mysql_query($query2))
{
$whatdo = strtoupper("add user ").$id;
include_once('../../serverlog.php');
$querys = "INSERT INTO m_log (user_id, description, waktu) VALUES ('$user', '$whatdo', '$input')";
if(mysql_query($querys))
{
echo'<script>alert("Penambahan data berhasil!");</script>
<meta http-equiv="refresh" content="0; url=index.php" />';
}
else
{
echo mysql_error();
}
}
else
{
echo'<script>alert("Failed!");</script> <br/>'.mysql_error().'<meta http-equiv="refresh" content="10; url=index.php" />';
}
?>
我的问题是,为 query2 创建条件我错了吗?因为当我运行程序时,我的数据总是得到角色的 POOL 结果,虽然我选择了 Admin 或 Supervisor,但它总是返回 POOL
我用于在注册表单中选择角色。因此,当我选择选项 admin 时,它返回池,当我选择 spv 时,它返回池。
任何人都可以给我解决方案吗?
对不起,我的英语不好