條件我有這樣的代碼在我的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禁令 –