Jump to content

If statement help


princeofpersia

Recommended Posts

Hi guys

 

I have the code below, which allows logged in users to add their movie link to database but before that they need to by credit which has been done successfully.

The code below reduces on credit from their credit bought, but I want to disable their post of they don’t have a credit, for example if they have their credit 0 a they wont be able to add anything to the database. Could you please give me some advice?

 

 

<?php
session_start();

include ("../global.php");

//welcome messaage
echo "Welcome, " .$_SESSION['username']."!<p>";
$username=$_SESSION['username'];
//get user id 
$query=mysql_query("SELECT id FROM users");
while($row = mysql_fetch_array($query))
{
$id = $row['id'];
}

  if ($_POST['register'])
    {
     //get form data
     $title = addslashes(strip_tags($_POST['title']));
     $link = addslashes(strip_tags($_POST[link]));
     $movie = addslashes(strip_tags($_POST[movie]));


     //get form data
     
     $submit = mysql_query("INSERT INTO movie  (title, link, movie) VALUES (‘$title’, ‘$link’, ‘$movie’)");
     echo "This movie has been added to our database";

$update = mysql_query("UPDATE users SET credit= credit-1 WHERE username='$username'");

}
?>
  <form action='addmovie’method='POST'>
    Title:<br />
    <input type='text' name='title' ><p />
    Movie Name:<br />
    <input type='text' name='name'><p />
    Link:<br />
    <input type='text' name='name'><p />

                    
    <input type='submit' name='register' value='Update'> 
    </form>

Link to comment
https://forums.phpfreaks.com/topic/219836-if-statement-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.