m00nz00mer Posted March 19, 2008 Share Posted March 19, 2008 hey, i was wondering if anyone could assist me in any way, in creating a very basic login system in php, basically i had this in mind... index.php will include a username and password form, if it is entered correcly, it will go to homepage.php else go to passwordError.php page. is this the way to do it? Quote Link to comment Share on other sites More sharing options...
helbom Posted March 19, 2008 Share Posted March 19, 2008 you want to store the username and password in index.php? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 19, 2008 Share Posted March 19, 2008 i suggest that you learn about sessions: http://us2.php.net/session Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted March 19, 2008 Share Posted March 19, 2008 Yes, that sounds like a good way to do it. You should start coding and ask specific questions about your code when you get stuck. If you are completely lost to how to even start, I recommend reading basic tutorials. www.tizag.com www.w3schools.com Quote Link to comment Share on other sites More sharing options...
m00nz00mer Posted March 19, 2008 Author Share Posted March 19, 2008 thanks, ive actually been trying this... <? $username = "user"; $password = "password"; if ($_POST['loginUserName']!= $username ¦¦ $_POST['loginPassword']!= $password) { ?> <h4>Login Below:</h4> <div class="detailTextGrey"> <!-- Login Form --> <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> User Name: <input type="text" name="loginUserName"> <br /> Password: <input type="password" name="loginPassword"> <br /><br /> <input type="hidden" name="submitted" value="1" /> <input type="submit" value="Submit"> </form> <? } else { ?> but im getting an error... Parse error: parse error, unexpected T_STRING in line 29 Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 19, 2008 Share Posted March 19, 2008 where is line 29? what happens after this? <? } else { ?> Quote Link to comment Share on other sites More sharing options...
m00nz00mer Posted March 19, 2008 Author Share Posted March 19, 2008 line 29 is this... if ($_POST['loginUserName']!= $username ¦¦ $_POST['loginPassword']!= $password) { and after that else im putting the html code which should be protected. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 19, 2008 Share Posted March 19, 2008 ah, i think you're not using the right pipe symbol. || Quote Link to comment Share on other sites More sharing options...
m00nz00mer Posted March 20, 2008 Author Share Posted March 20, 2008 ah awesome! how could i implement this basic system so that if you had already entered a password and you go back to this page, it will load the protected content? Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted March 20, 2008 Share Posted March 20, 2008 use sessions. set a session with the username and password and make it verify that the info stored in the session is the same as the stored username and password. then if (session-is-the-same) { "show-the-super-protected-top-secret-documents" } 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.