Benim profile.php kullanıcının tüm ilanları, yorum, resim görüntüler. Kullanıcı silmek istiyorsa remove.php? Action = removeposting & posting_id = 2 gibi yani, o remove.php için Gönderiyor id gönderir. Bir resmi kaldırmak istiyorsanız, bu remove.php var? Action = removepicture & picture_id = 1.
Get verileri kullanarak, ben onlar silmek istiyorum ve bunu silmek istiyorsanız, onlar "evet" tıklayın bilgi görüntülemek için veritabanına bir sorgu yapmak. Yani veri $ cross-site istek sahteciliği önlemek için GET $ POST üzerinden silinir.
Benim soru Eminim yapabilirim nasıl GETler bazı javascript kodu olacak beni dağıtmayacak SQL injection değildir.
here is my remove.php
//how do I make $action safe?
//should I use mysqli_real_escape_string?
//use strip_tags()?
$action=trim($_GET['action']);
if (($action != 'removeposting') && ($action != 'removefriend')
&& ($action != 'removecomment'))
{
header("Location: index.php");
exit();
}
if ($action == 'removeposting')
{
//get the info and display it in a form. if user clicks "yes", deletes
}
if ($action =='removepicture')
{
//remove pic
}
Ben% 100 güvenli olamaz biliyorum, ama ben kullanabileceğiniz bazı yaygın savunmalar nelerdir.
EDIT
Do this to prevent xss
$oldaction=trim($_GET['action']);
$action=strip_tags($oldaction);
Then when I am 'recalling' the data back via POST, I would use
$posting_id = mysqli_real_escape_string($dbc, trim($_POST['posting_id']));
if ($action == 'removeposting')
{
//get the posting id from the user
$getposting_id = htmlspecialchars(trim($_GET['posting_id']));
//basic checks for the posting id
if (empty($getposting_id)){
//header ("Location: index.php");
echo '<p>Sorry, no posting was specified for removal.</p>';
exit();
}
if (!is_numeric($getposting_id))
{
echo "Not an integer";
exit();
}
//Also have check to see if the posting_id is the user's. If so, can delete