I'm trying to create a really basic like system using auto increment in mysql.
Basically this script inserts the user_id
and auto increments the like column to 1, what I need to try and do though is once the the user_id
and like has been inserted the first time round I then need to make my script say something like if result already exists update else insert?
Can someone please show me how I could do this thanks:
<?php
require_once('includes/session.php');
require_once('includes/functions.php');
require('includes/_config/connection.php');
session_start();
confirm_logged_in();
if (isset ($_GET['to'])) {
$user_to_id = $_GET['to'];
}
if (!isset($_GET['to']))
exit('No user specified.');
$user_id = $_GET['to'];
$result1 = mysql_query("INSERT INTO ptb_likes (liked_id) VALUES (".$user_to_id.")");
if($result1)
{
header("Location: {$_SERVER['HTTP_REFERER']}");
}
?>