這是來自配置文件更新頁面;因此,如果一個人改變了他們的email2
從[email protected]到[email protected]我想email2_verified
被重置爲unverified
有沒有辦法在SQL更新聲明中添加PHP IF語句
我的代碼..
$updateSQL = sprintf("UPDATE user SET uname=%s,email=%s, email2=%s WHERE `uid`=%s && `pass_code`=%s",
GetSQLValueString($_POST['uname'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['email2'], "text"),
GetSQLValueString($_POST['uid'], "int"),
GetSQLValueString($password, "text"));
我也有一個場email2_verified
;目標是..如果email2
已經改變我想要它unverified
; 有沒有辦法在sql語句中添加一條if語句,它可以像下面的代碼一樣工作..?
$updateSQL = sprintf("UPDATE user SET uname=%s,email=%s, email2=%s
WHERE `uid`=%s && `pass_code`=%s,email2_verified=%s",
if($_POST['email2']){ // **has not changed**
GetSQLValueString($_POST['uname'], "text"),
GetSQLValueString($_POST['email'], "text"),
}
if($_POST['email2']){ //**has changed**
GetSQLValueString("unverified","text"),
}
GetSQLValueString($_POST['email2'], "text"),
GetSQLValueString($_POST['uid'], "int"),
GetSQLValueString($password, "text"));
我猜(最外行的方法是)我可能會創建一個更新語句之前運行和
if htmlentities($post['email2']) <> $row['email2']
use update statement 1
else
use update statement 2
select語句是最好的辦法還是有一個PHP函數我不知道可以在飛行中做到這一點?
你的代碼格式非常糟糕:D –
這個大膽的「改變」是什麼意思? –
它的標準格式從dreamweaver ..我不是像大多數這裏贊成:) – user3229526