SupremeBeing Posted January 25, 2011 Share Posted January 25, 2011 Hello again guys, am having trouble with a login script I have been working on. Have crawled the web for answers so thought i would post here again for some help. A brief run down on what the script is intended to do: 1.) The script checks to see if a user is logged in, and asks them to if their not. 2.) If theuser is logged in their userid is grabbed from $_SESSION and assigned to $userid 3.) Connection to the database is made and the field premium is updated with value "1" where userid = $userid A error message is supposed to be shown if the query has an error, but currently an error is not produced, the premium field remains NULL and the echo is shown. Can't for the the life of me fiqure out why it isn't working, but i think it is quite simple. Heres my script <?php if (!is_authed()) { echo 'You are not logged-in. Please login so we can add your purchased video to your account.'; include 'login_form.inc.php'; } else { include 'cp/config.php'; include 'cp/opendb.php'; $_SESSION['userid'] = $userid; $query = "UPDATE user SET premium='1' WHERE userid='$userid'"; mysql_query($query) or die('Error, query failed : ' . mysql_error()); echo 'Thank You for purchasing our series. We have added it to your account so you can use it straight away.'; } ?> For some reason the Quote Link to comment Share on other sites More sharing options...
rockstarrem Posted January 25, 2011 Share Posted January 25, 2011 I may be missing something stupid, but where is the function is_authed defined? Quote Link to comment Share on other sites More sharing options...
Cagecrawler Posted January 25, 2011 Share Posted January 25, 2011 It should be $userid = $_SESSION['userid'] instead of the other way round. The script is executing properly but you're currently never setting $userid, hence why it's returning NULL into the query. Quote Link to comment Share on other sites More sharing options...
SupremeBeing Posted January 25, 2011 Author Share Posted January 25, 2011 Argh, I knew it would be a simple thing! Thank you so much Cagecrawler, you are an absolute legend. Now time to test if PayPal clears the sessions when visitors pay - hopefully not... Ekk Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted January 25, 2011 Share Posted January 25, 2011 Now time to test if PayPal clears the sessions when visitors pay - hopefully not... Ekk If you mean the session info you set: only your website (or the user) can clear it. Quote Link to comment Share on other sites More sharing options...
SupremeBeing Posted January 25, 2011 Author Share Posted January 25, 2011 Thank you BlueSkyIS, thats fantastic news. I thought they would make me send through some variables but seems too just work. Thank you all for your help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.