条件我有这样的代码在我的PHP代码:PHP MySQL的创建查询
<?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结果的角色,虽然我有选择管理或监事时,它总是返回POOL
我使用选择在登记表中的作用。所以当我选择选项admin时,它返回池,当我选择spv时,它返回池。
谁能给我解决?
对不起,我英文不好
'if($ role =“POOL”)'should should'if($ role ==“POOL “)' – itachi
对不起,没有阅读..我明白了。谢谢..:d –
@CrossVander你的代码是开放的SQL禁令 –