Jump to content

If statement help


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?




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

//welcome messaage
echo "Welcome, " .$_SESSION['username']."!<p>";
//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'> 

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 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.