princeofpersia Posted November 25, 2010 Share Posted November 25, 2010 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 More sharing options...
herghost Posted November 25, 2010 Share Posted November 25, 2010 if(isset($credit = '0')) { echo "you must purchase credit"; } else { your code } Link to comment https://forums.phpfreaks.com/topic/219836-if-statement-help/#findComment-1139593 Share on other sites More sharing options...
princeofpersia Posted November 25, 2010 Author Share Posted November 25, 2010 thank you, perfect solution Link to comment https://forums.phpfreaks.com/topic/219836-if-statement-help/#findComment-1139594 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.