阅读背景:

如何在SQL查询中使用会话变量?

来源:互联网 

Here is my relevant code:

这是我的相关代码:

<?php
 require("common.php");

 $userID = $_SESSION['user']['id'];

echo $userID;
if(!empty($_POST)) 
{ 
    if(empty($_POST['bio'])) 
        { 
            die("Please enter your Bio."); 
        }

    if(empty($_POST['location'])) 
        { 
            die("Please enter your location");      
        }  


    $query = 'UPDATE users
              SET usertype = 1
              WHERE id="$userID"';


    $query_params = array( 
        ':bio' => $_POST['bio'],
        ':location' => $_POST['location'], 
    ); 

    try 
    { 
        $stmt = $db->prepare($query); 
        $result = $stmt->execute(); 
    } 
    catch(PDOException $ex) 
    {   
        die("Failed to run query: " . $ex->getMessage()); 
    }

    // header("Location: myprofile.php");
} 
?> 
<?php
 



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: