Login-Logout with session PHP Practice for Beginners

Language
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.

FOR YOUR OWN SAFETY, PLEASE:

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.

Tags

Comments

This site very useful for php begginers include me thanks

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

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

where is the code?????

In reply to by mayank3359 (not verified)

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

your code works well for me thanks

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

I love sourcecodester.com

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

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

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

Add new comment