if(isset($_GET['id'])){
$nome = $_GET['nome'];
$cognome = $_GET['cognome'];
$id = $_GET['id'];
$sql = "UPDATE utenti SET nome = :nome, cognome = :cognome WHERE id = :id";
$req = $dbh->prepare($sql);
$req->execute(
array(
":nome" => $nome,
":cognome" => $cognome,
":id" => $id,
)
);
} else {
$nome = $_GET['nome'];
$cognome = $_GET['cognome'];
$sql = "INSERT INTO utenti (nome, cognome) VALUES (:nome, :cognome)";
$req = $dbh->prepare($sql);
$req->execute(
array(
":nome" => $nome,
":cognome" => $cognome,
)
);
}
大家好。我有这个代码在数据库中插入或更新表单的数据。我想要包含一个“if”检查,表明您正在检查数据库中是否存在该用户。我能怎么做?谢谢
答案 0 :(得分:0)
试试这个:
/etc/mysql/my.cnf
编辑2:现在应该可以使用^^