问题
I am passing id no to Url and get the id from GET function but id no which I passed to URL that not accepting the update query because of MD5. I tried $id=md5($_GET['user']);
but still getting issue. My user_id is 1 and that is converting into the md5 number and passing to update function to update the table. Would you help me in this?
$User_id1=1;
$user_id=md5($User_id1);
http://www.domaine.com/process.php?user=$user_id
if(isset($_GET['user']))
{
$id=$_GET['user'];
$sql="UPDATE request SET email_verification=1 WHERE Id='$id'";
$result = $conn->query($sql);
if ($result=== TRUE) {
header('Location: index.php');
} else {
echo "Error updating record: " . $conn->error;
}
}
回答1:
I don't think your md5-ied user_id is passing into update query because inside top if condition there is no md5() function which is doing the task and you must also sure that how is value stored inside the database, is it md5-ied user_id or normal user_id ? if for md5 user_id try it like this,
if(isset($_GET['user'])){
$id = $_GET['user'];
$id = md5($id);
$sql = "UPDATE request SET email_verification=1 WHERE Id='$id'";
$result = $conn->query($sql);
if ($result === TRUE) {
header('Location: index.php');
}
else {
echo "Error updating record: " . $conn->error;
}
}
来源:https://stackoverflow.com/questions/41908975/update-query-is-not-working-using-php