Search code examples
phpmysqlvote

Like/Dislike system like FB


I have my tables set and the design I wanted...the only thing in my way of creating a sexy like/dislike system for my site is the actual PHP it would take (dont worry i wrote a bunmch of the code, its just not sending)

My problem is that my code isnt sending to any of the tables, so my question to you is how would I actually get it to send to the db?

Here's the code I have in place so far (along with the button)

Button

<form action="up.php">
<input type="image" value="upBtn" name="upBtn" id="upBtn" src="images/add.png"> Like
</form>

Actual code (up.php)

  <?php
    require 'connect2.php';

    if (isset($_POST['upBtn'])) {
               mysql_query("INSERT INTO votes (id, user, upvote, downvote) VALUES ('', '$username', '+ 1', '+ 0')");
               mysql_query("UPDATE searchengine SET rel = rel '+ 1' WHERE id = '$id'");
            }
    ?>

$user name def (on the top of the page all of this code is on)

if (isset($_SESSION['id'])) {
    $userid = $_SESSION['id'];
    $username = $_SESSION['username'];

$id was already defined on the page since all of this is on the page I wanted the votes to appear


Solution

  • Try adding method="post" to the form tag. If it still doesn't work, you should put some debugging code inside the if statement to see if your queries are actually being run.