Login-Logout with session PHP Practice for Beginners

Submitted by: 
Visitors have accessed this post 52546 times.

This is a simple PHP sourcecode the Enables you to know how to login , logout with using sessions for security this sourcecode may help beginners want to learn Php.. hope this sourcecode my help you a Lot

database_name: database
include in the zip file..

thank you


Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.


1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.


This code is very nice and simple , it helps me as new php learner.

when i try to run this cold on my machine it just refreshes the page. any help please?

thannk u so much

nice code! thanks dude

Thank you so so much!It helped me a lot...It seems so simple and easy with that way!Congratulations!!

Free Php Sekhny ky liye rabta kary fb id=[email protected]
and skyep=aki.khan77

I love sourcecodester.com

  1. <?php
  2. include("includes/header.php");
  3. $page_title="changepassword";
  4. include('connection.php');
  6. if(isset($_POST['submitted'])){
  7. $rId = $_POST['submitted'];
  8. if(($_POST['newpassword']) == ($_POST['conpassword'])){
  9. $password = $_POST['change'];
  10. $npassword = $_POST['newpassword'];
  11. $cpassword = $_POST['conpassword'];
  12. $select = mysql_query("SELECT Pass FROM riderform WHERE RidersId='$rId'");
  14. if(mysql_num_rows($select) == 1){
  16. $row = mysql_fetch_array($select);
  17. $old_pass = $row['Pass'];
  18. if($old_pass == $password){
  20. $subquery = mysql_query("UPDATE riderform SET Pass='$cpassword' WHERE RidersId='$rId'");
  21. if($subquery){
  22. $update= "your password has been change successfully<br/>from ".$password." to ".$npassword;
  24. }
  25. else{
  26. echo "update is not ok ";
  27. }
  28. }
  29. else{
  30. $update= "confirm your old password".mysql_error();
  31. }
  32. }
  33. }
  34. else{
  35. $update = "your password do not match";
  36. }
  37. }
  39. ?>
  41. <h1 style="font-size:50px; text-align:center; color:green;" id="sub1">A.B.U</h1>
  42. <p style="font-size:20px; text-align:center; color:green;">Change your password here</p>
  43. <h4 align="center">
  44. </h4>
  45. <form action="rchange_password.php" method="POST">
  46. <div align="center">
  47. <h4 style="color:green">
  48. <?php
  49. if(isset($update)){
  50. echo $update;
  51. unset($update);
  52. }
  53. ?>
  54. </h4>
  55. <input type="password" required name="change" size="30" placeholder="Old password" ></br></br>
  56. <input type="password" required name="newpassword" size="25" placeholder="New password" ></br></br>
  57. <input type="password" required name="conpassword" size="25" placeholder="Confirm password" ></br></br>
  58. <p><input id="sub" type="submit" value="Send">&nbsp;<a class="ancor" href="user_activities.php?rId=<?php if(isset($_GET['id'])){ echo ($_GET['id']);} ?>"><input type="button" value="click back" id="sub"></a></p>
  59. <input type="hidden" name="submitted" value = "<?php if(isset($_GET['id'])){ echo base64_decode($_GET['id']);} ?>" />
  60. </div>
  61. </form>
  62. <br>
  63. <br>
  64. <br>
  65. <br>
  66. <br>
  67. <?php
  68. include("includes/footer.php");
  69. ?>
  70. </body>
  71. </html>

I love u all.

your code works well for me thanks

where is the code?????

there is a 'Download' button under the post :)

Hey, thank you very much for this. Simple yet very informative.

awesome code I am searching from many days. Now I am at right place.

This site very useful for php begginers include me thanks

excellent code. good job..

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.