Update query is not working using php

别说谁变了你拦得住时间么 提交于 2019-12-13 06:39:30

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!