So hello thats again me xd
this time i have made everything but it have some bugs like
http://localhost/GrabPoints/like.php?id=1&myid=1
it adds 1 like from me to post where id=1
problem is users can easily change myid=2 or other number they can add another like from other user account how can i make
if session id = myid then it lets user get next
code:
[php]<?php
include(“connect.php”);
session_start();
if (!isset($_SESSION[‘id’])) {
header(‘Location: login.php’);
}
else
{
}
if( isset($_GET[‘id’],$_GET[‘myid’]) )
{
$pid = $_GET['id'];
$myid = $_GET['myid'];
$query = mysqli_query($conn,"SELECT * FROM likes WHERE pid='$pid' AND myid='$myid'");
$numrows = mysqli_num_rows($query);
if($numrows!==0)
{
while($row = mysqli_fetch_assoc($query))
{
$dbpid = $row['pid'];
$dbmyid= $row['myid'];
}
if($pid==$dbpid&&$myid==$dbmyid)
{
header("Location: topic.php?id=".$_GET['id']."");
}
}else
{
$id = $_GET['id'];
$myid = $_GET['myid'];
$sql= "INSERT INTO likes (pid,myid) VALUES ('$id','$myid')";
mysqli_query($conn, $sql);
header("Location: topic.php?id=$id");
}
}
?>[/php]
i dont know how to modify this part…
[php]if (!isset($_SESSION[‘id’])) {[/php]
i tried
[php]if ($_SESSION[‘id’]!==$_GET[‘myid’]) {[/php]