php login page problem

Reply

Join Date: May 2008
Posts: 2
Reputation: sweetleilani is an unknown quantity at this point 
Solved Threads: 0
sweetleilani sweetleilani is offline Offline
Newbie Poster

php login page problem

 
0
  #1
May 15th, 2008
Hi. I'm a newbie to php and have created a login form that does not use an sql database. After inputing all the code I've tested it in IE and it doesn't work properly. If I leave the username and password blank but hit the submit button, it takes me to the page that is suppose to be restricted to those who put in the correct username and password. Even if I put in the wrong username and password, it takes me to the restricted page. I can't figure out if i've left out something or if I should just give up and go with using the sql database. Below is my code. Please help.
Thanks

  1. <?php
  2. ?>
  3. $username = "admin";
  4. $password = "adminpass";
  5. if(isset($_post['user'])&&isset($_post['password']))
  6. {
  7. if($username == $_post['user'] && $password == $_post['password'])
  8. {
  9. ?>
  10. <form name="form" action="membersonly-content.html" method="post">
  11. <?php
  12. }
  13. else
  14. {
  15. die("your login information was incorrect");
  16. }
  17. }
  18. else
  19. ?>
  20. <h1>Login</h1>
  21. <label for="txtusername">Username:</label>
  22. <input type="text" title="enter your username" name="textusername"/> </p>
  23. <label for="txtpassword">Password:</label>
  24. <input type="password" title="enter your password" name="txtpassword"/> </p>
  25. <input type="submit" name="submit" value="login"/></p>
  26. </form>
  27. <?php
  28. }
  29. else {
  30. ?>
  31. </php>
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 4
Reputation: jana36 is an unknown quantity at this point 
Solved Threads: 1
jana36 jana36 is offline Offline
Newbie Poster

Re: php login page problem

 
0
  #2
May 15th, 2008
accha tell me u have done the whole coding in one page only....in the same page u have post the form and there u r accessing the value .....
1) first make the login page with form and post , post it to some php page
2) in the php page then access the value of the textboxes(login name and password) from the php page and do the necessary query.

3) make the button as button type only not submit type and on clicking the button write one function in javascript which will check the field checking like empty or characters....there in the function use one FLAG which will prevent the page when there is some validation problem from submission......

reply me with all the details.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 2
Reputation: sweetleilani is an unknown quantity at this point 
Solved Threads: 0
sweetleilani sweetleilani is offline Offline
Newbie Poster

Re: php login page problem

 
0
  #3
May 16th, 2008
Thanks for the reply. I understand number 3 and will work on that, and i have already saved my login page as a php. Number 2 though is a little confusing. What are you talking about in number 2? How do you do a query if you are NOT using the sql database?
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 4
Reputation: jana36 is an unknown quantity at this point 
Solved Threads: 1
jana36 jana36 is offline Offline
Newbie Poster

Re: php login page problem

 
0
  #4
May 16th, 2008
sorry, i have taken that point by mistake, since you are not using any database then you dont need toh follow the instruction in line 2. you can simply follow number 3.
but in case of login page why dont u use a database, because if you are not using any databases how the login name and password values are verified?

please give me the update regularly

thanks
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC