2011-05-01 84 views

回答

0
$stmt = mysqli_prepare($con,"INSERT INTO friend_request (ToUID, FromUID) VALUES (?,?)"); 
mysqli_stmt_bind_param($stmt, "ii", $fid, $uid); //i-> Integer, S -> string 
mysqli_stmt_execute($stmt); 
if (mysqli_stmt_affected_rows($stmt)) 
echo 'Request Sent'; 
else 
echo 'Something went wrong !'; 
0

这是我的过程:

 
//check to see if the request came from your server or not 
$server = substr($_SERVER[HTTP_REFERER],0,LENGTH OF INCOMING PAGE); 
$prevPage = ""; //the incoming page 
if ($server != $prevPage) { 
    header("Location: $prevPage"); 
    exit; 
} else { 
    //pull and sanitize the data 
    include('link.php'); //include the link to your database 
    $var = $link->mysql_real_escape_string($_POST['data']); 

    //check for null values in required fields 

    //run the data through a regular expression check 

    //then store the information 

有这么多你可以做,以验证所输入的数据。

+1

你明白,一个HTTP客户端可以很容易地伪造一个引用标头,对吧? – 2011-05-01 03:43:35

+0

是的,但它只是额外的验证码。 – awesomesyntax 2011-05-01 04:31:33

+0

我想我会重新翻译我的问题 - mysql_real_escape_string是否足够? – JDS 2011-05-01 22:59:48