adamlacombe Posted June 16, 2009 Share Posted June 16, 2009 Does anyone know how to make a basic login user system with mysql? I know how to do most of it but not sure on the login process. Quote Link to comment https://forums.phpfreaks.com/topic/162408-solved-user-system/ Share on other sites More sharing options...
adamlacombe Posted June 16, 2009 Author Share Posted June 16, 2009 I have searched google for days for a user system tutorial but all i get are advanced scripts with lost password, sign up, members page, and profile page features. All im looking for is something that will let me login with mysql, I can make all the other features. If anyone knows of a tutorial that will help me or can write one up that would be great! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/162408-solved-user-system/#findComment-857294 Share on other sites More sharing options...
Maq Posted June 16, 2009 Share Posted June 16, 2009 If anyone knows of a tutorial that will help me or can write one up that would be great! Hate to burst your bubble princess, but I don't think anyone is going to write a tutorial just for you. I'm sure you can find basic tutorials on how to create a login script. This is a very common request. I would recommend doing a search on phpfreaks for some similar threads as well. I have searched google for days for a user system tutorial but all i get are advanced scripts with lost password, sign up, members page, and profile page features. Just ignore the extra features you don't want. Quote Link to comment https://forums.phpfreaks.com/topic/162408-solved-user-system/#findComment-857300 Share on other sites More sharing options...
adamlacombe Posted June 16, 2009 Author Share Posted June 16, 2009 well i have found a basic one i want to use but i dont know how to pull the info of the logged in user. i have tried: $_SESSION['username'] but that does not wanna work. I run into this problem a lot with the other script i have found too. the link to the tut is: http://dev.thatspoppycock.com/index.php/Creating_a_Simple_PHP_and_MySQL-Based_Login_System Quote Link to comment https://forums.phpfreaks.com/topic/162408-solved-user-system/#findComment-857325 Share on other sites More sharing options...
pgrevents Posted June 16, 2009 Share Posted June 16, 2009 silly question but is session_start(); at the top of all your pages? Quote Link to comment https://forums.phpfreaks.com/topic/162408-solved-user-system/#findComment-857326 Share on other sites More sharing options...
adamlacombe Posted June 16, 2009 Author Share Posted June 16, 2009 yeah its right at the top of the page. Quote Link to comment https://forums.phpfreaks.com/topic/162408-solved-user-system/#findComment-857328 Share on other sites More sharing options...
pgrevents Posted June 16, 2009 Share Posted June 16, 2009 are you setting your session is $_SESSION['sessionname'] = $stuffvar have you tried printing your session to see if it is infact working but its your other code that isnt? Quote Link to comment https://forums.phpfreaks.com/topic/162408-solved-user-system/#findComment-857349 Share on other sites More sharing options...
adamlacombe Posted June 16, 2009 Author Share Posted June 16, 2009 ok, got it working! I hate to be such a pain but any idea why this: <?php session_start(); include "db_connect.php"; //mysql db connection here print "<link rel='stylesheet' href='style.css' type='text/css'>"; print "<table class='maintable'>"; print "<tr class='headline'><td>From</td><td>Author</td><td>Message</td></tr>"; $getmail="SELECT * from PM where to='$_SESSION['username']'"; $getmail2=mysql_query($getmail) or die("Could not get mail"); while($getmail3=mysql_fetch_array($getmail2)) { print "<tr class='mainrow'><td>$getmail3[from]</a></td><td>$getmail3[msg]</a></td></tr>"; } print "</table>"; ?> does not work? it has something to do with the: $getmail="SELECT * from PM where to='$_SESSION['username']'"; Quote Link to comment https://forums.phpfreaks.com/topic/162408-solved-user-system/#findComment-857398 Share on other sites More sharing options...
Maq Posted June 16, 2009 Share Posted June 16, 2009 Change that to: $getmail="SELECT * from PM where to='{$_SESSION['username']}'"; It thought that the single quote in the query was ending the comparative value, when adding curly brackets it escapes the quotes and allows for variables such as arrays. Quote Link to comment https://forums.phpfreaks.com/topic/162408-solved-user-system/#findComment-857400 Share on other sites More sharing options...
adamlacombe Posted June 16, 2009 Author Share Posted June 16, 2009 hmm... I changed it to what you posted and got the error "could not get mail". Quote Link to comment https://forums.phpfreaks.com/topic/162408-solved-user-system/#findComment-857404 Share on other sites More sharing options...
Maq Posted June 16, 2009 Share Posted June 16, 2009 Change that line to: $getmail2=mysql_query($getmail) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/162408-solved-user-system/#findComment-857413 Share on other sites More sharing options...
adamlacombe Posted June 16, 2009 Author Share Posted June 16, 2009 ok now i get this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'to='test'' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/162408-solved-user-system/#findComment-857416 Share on other sites More sharing options...
Maq Posted June 16, 2009 Share Posted June 16, 2009 OK, 'to' is a reserved word - Reserved Words. The way around this is to use back ticks which will escape the reserved word and give the meaning literally. This should work: $getmail="SELECT * from PM where `to`='{$_SESSION['username']}'"; Quote Link to comment https://forums.phpfreaks.com/topic/162408-solved-user-system/#findComment-857419 Share on other sites More sharing options...
adamlacombe Posted June 16, 2009 Author Share Posted June 16, 2009 ok got it! Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/162408-solved-user-system/#findComment-857422 Share on other sites More sharing options...
Maq Posted June 16, 2009 Share Posted June 16, 2009 ok got it! Thank you! YW, please mark solved. Quote Link to comment https://forums.phpfreaks.com/topic/162408-solved-user-system/#findComment-857426 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.