473,320 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How To put session In My code??

3
login.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. ?>
  4. <html>
  5. <body>
  6. <head>
  7. <link rel="stylesheet" type="text/css" href="style.css">
  8. <script language="javascript" type="text/javascript">
  9. alert("Welcome To My Site")
  10. </script>
  11. </head>
  12. <table border="0" cellpadding="6" cellspacing="1" width="50" align="right">
  13. <tr class="tablerow"><td align="center"><a href="welcome.php">Home</a></tr></td>
  14. </table>
  15. <br/>
  16. <br/>
  17. <br/>
  18. <br/>
  19. <br/>
  20.  
  21. <table border="0" cellpadding="8" cellspacing="1" width="500" align="center">
  22. <form action="loginsubmit.php" method="POST">
  23. <tr class="tableheader"><td align="center" colspan="2">Enter Login Details</td>
  24. </tr>
  25. <tr class="tablerow">
  26. <td align="right">Aadhar Card No.</td><td><input type="text" name="aadhar"></td></tr>
  27.  
  28. <tr class="tablerow">
  29. <td align="right">Password</td><td><input type="password" name="password"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="forget.php">Forget Password?</a></td></tr>
  30. <tr class="tablerow">
  31. <td align="center" colspan="2"><input type="submit" name="submit" value="submit"></td></tr>
  32. <tr class="tableheader">
  33. <td align="center" colspan="2"><a href="sign.php">New User Click Here</a></td></tr>
  34. </table>
  35. <br/>
  36. <br/>
  37.  
  38. </body>
  39. </html>
  40. <font face="Tahoma"><a target="_blank" href="#"><span style="font-size: 8pt; text-decoration: none"></span></a></font>
  41.  

loginsubmit.php
Expand|Select|Wrap|Line Numbers
  1. <head>
  2. <link rel="stylesheet" type="text/css" href="style.css">
  3. </head>
  4. <body>
  5.  
  6. <?php
  7. include("config.php");
  8.  
  9. echo'<table border="0" cellpadding="6" cellspacing="1" width="50" align="right">';
  10. echo '<tr class="tablerow"><td align="center"><a href="welcome.php">Home</a></tr></td>';
  11. echo "</table>";
  12. echo"<br/>";
  13. echo"<br/>";
  14.  
  15. $aadhar= $_POST['aadhar'];
  16. $password= $_POST['password'];
  17.  
  18.  
  19. $query = mysql_query(" SELECT * FROM data WHERE aadhar= '$aadhar' && password= '$password' ");
  20. if(mysql_num_rows($query))
  21. {
  22. WHILE ($rows = mysql_fetch_array($query)):
  23. echo'<table border="0" cellpadding="8" cellspacing="1" width="500" align="center">';
  24. $fname = $rows['fname'];
  25. $lname = $rows['lname'];
  26. $aadhar = $rows['aadhar'];
  27. $age = $rows['age'];
  28. $gender = $rows['gender'];
  29. $email = $rows['email'];
  30. $contact = $rows['contact'];
  31. $address1 = $rows['address1'];
  32. $address2 = $rows['address2'];
  33. $district = $rows['district'];
  34. $state = $rows['state'];
  35. $course = $rows['course'];
  36. $education = $rows['education'];
  37.  
  38. echo'<tr class="tableheader"><td align= "center" colspan="3"> Hello ' . $fname . ' Here Are Your Details</td></tr>';
  39.  
  40. echo'<tr class="tablerow"><td align="right">First Name</td><td align="center"> '.$fname.' </td><td align="center"><a href="changef.php">Update</a></td></tr>';
  41. echo'<tr class="tablerow"><td align="right">Last Name</td><td align="center"> '.$lname.' </td><td> </td></tr>';
  42. echo'<tr class="tablerow"><td align="right">Aadhar</td><td align="center"> '.$aadhar.' </td><td> </td></tr>';
  43. echo'<tr class="tablerow"><td align="right">Age</td><td align="center"> '.$age.' </td><td> </td></tr>';
  44. echo'<tr class="tablerow"><td align="right">Gender</td><td align="center"> '.$gender.' </td><td> </td></tr>';
  45. echo'<tr class="tablerow"><td align="right">Email Id</td><td align="center"> '.$email.' </td><td align="center"><a href="changem.php">Update</a></td></tr>';
  46. echo'<tr class="tablerow"><td align="right">Contact</td><td align="center"> '.$contact.' </td><td align="center"><a href="changec.php">Update</a></td></tr>';
  47. echo'<tr class="tablerow"><td align="right">Address 1</td><td align="center"> '.$address1.' </td><td> </td></tr>';
  48. echo'<tr class="tablerow"><td align="right">Address 2</td><td align="center"> '.$address2.' </td><td> </td></tr>';
  49. echo'<tr class="tablerow"><td align="right">District</td><td align="center"> '.$district.' </td><td> </td></tr>';
  50. echo'<tr class="tablerow"><td align="right">State</td><td align="center"> '.$state.' </td><td> </td></tr>';
  51. echo'<tr class="tablerow"><td align="right">Course</td><td align="center"> '.$course.' </td><td> </td></tr>';
  52. echo'<tr class="tablerow"><td align="right">Education</td><td align="center"> '.$education.' </td><td> </td></tr>';
  53.  
  54. echo'<tr class="tableheader"><td align= "center" colspan="3"> You Are Logged In </td></tr>';
  55. echo "</table>";
  56. endwhile;
  57.  
  58. echo '<table border="0" cellpadding="6" cellspacing="1" width="200" align="right">';
  59. echo '<tr class="tableheader"><td align="center"><a href="change.php">Change Password</a></tr></td>';
  60. echo '<tr class="tablerow"><td align="center">Or </tr></td>';
  61. echo '<tr class="tableheader"><td align="center"><a href="logout.php">Click Here To Logout</a></tr></td>';
  62. echo "</table>";
  63.  
  64. else {
  65. echo "<center><h2><p>Sorry, The Information Is Not Correct!!</p></h2></center>";
  66. }
  67.  
  68. ?>
  69.  
  70. </body>
  71.  

sign.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3.  
  4. ?>
  5. <head>
  6. <link rel="stylesheet" type="text/css" href="style.css">
  7. <script>
  8. function validateForm() {
  9.     var x = document.forms["myForm"]["fname"].value;
  10.         var y = document.forms["myForm"]["password"].value;
  11.         var z = document.forms["myForm"]["email"].value;
  12.         var w = document.forms["myForm"]["gender"].value;
  13.     if (x == null || x == "") {
  14.         alert("Name must be filled out");
  15.         return false;
  16.     }
  17.     else if (y.length < 6) {
  18.         alert("Password must be atleast 6 charecter long");
  19.         return false;
  20.     }
  21.     if (z == null || z == "") {
  22.         alert("Email must be filled out");
  23.         return false;
  24.     }
  25.     if (w == null || w == "") {
  26.         alert("Gender must be filled out");
  27.         return false;
  28.     }
  29. }
  30. </script>
  31. </head>
  32. <body>
  33. <table border="0" cellpadding="6" cellspacing="1" width="50" align="right">
  34. <tr class="tablerow"><td align="center"><a href="welcome.php">Home</a></tr></td>
  35. </table>
  36.  
  37. <table border="0" cellpadding="8" cellspacing="1" width="500" align="center">
  38. <form name="myForm" action="signsubmit.php" onsubmit="return validateForm()" method="post">
  39. <tr class="tableheader"><td align="center" colspan="2">Enter Details</td>
  40. </tr>
  41. <tr class="tablerow"> 
  42. <td align="right">First Name</td><td> <input type="text" name="fname"></td> </tr>
  43. <tr class="tablerow">
  44. <td align="right">Last Name</td><td> <input type="text" name="lname"></td> </tr>
  45. <tr class="tablerow">
  46. <td align="right">Password</td><td><input type="password" name="password"></td></tr>
  47. <tr class="tablerow">
  48. <td align="right">Aadhar Card No.</td><td><input type="text" name="aadhar"></td></tr>
  49. <tr class="tablerow">
  50. <td align="right">Age</td><td> <input type="text" name="age"></td> </tr>
  51.  
  52. <tr class="tablerow">
  53. <td align="right">Gender:</td><td>
  54. <input type="radio" name="gender"
  55. <?php if (isset($gender) && $gender=="female") echo "checked";?>
  56. value="female">Female
  57. <input type="radio" name="gender"
  58. <?php if (isset($gender) && $gender=="male") echo "checked";?>
  59. value="male">Male
  60. </td></tr>
  61.  
  62. <tr class="tablerow">
  63. <td align="right">Email</td><td><input type="text" name="email"></td></tr>
  64. <tr class="tablerow">
  65. <td align="right">Contact</td><td><input type="text" name="contact"></td></tr>
  66. <tr class="tablerow">
  67. <td align="right">Address Line1 </td><td><input type="text" name="address1"></td></tr>
  68. <tr class="tablerow">
  69. <td align="right">Address Line2 </td><td><input type="text" name="address2"></td></tr>
  70. <tr class="tablerow">
  71. <td align="right">District</td><td><input type="text" name="district"></td></tr>
  72. <tr class="tablerow">
  73. <td align="right">State </td><td><input type="text" name="state"></td></tr>
  74. <tr class="tablerow">
  75. <td align="right">Course You Want To Do</td><td><select name="course" style="width:142px;">
  76.  <option value=" "> </option>
  77.  <option value="Computer Basics">Computer Basics</option>
  78.  <option value="Tally">Tally</option>
  79.  <option value="Typing">Typing</option>
  80.  <option value="IELTS">IELTS</option>
  81.  </select></td></tr>
  82. <tr class="tablerow">
  83. <td align="right">Qualification</td><td><select name="education" style="width:142px;">
  84.  <option value=" "> </option>
  85.  <option value="10th">10th</option>
  86.  <option value="12th">12th</option>
  87.  <option value="Graduation">Graduation</option>
  88.  <option value="Above Graduation">Above Graduation</option>
  89.  </select></td></tr>
  90. <tr class="tableheader">
  91. <td align="center" colspan="2"><input type="submit" value="Submit"/></td></tr>
  92.  </form>
  93.  </table>
  94.  </body>
  95.  
  96.  

signsubmit.php
Expand|Select|Wrap|Line Numbers
  1. <head>
  2. <link rel="stylesheet" type="text/css" href="style.css">
  3. </head>
  4. <body>
  5.  
  6. <?php
  7. //connectivity
  8. include("config.php");
  9.  
  10. echo'<table border="0" cellpadding="6" cellspacing="1" width="50" align="right">';
  11. echo '<tr class="tablerow"><td align="center"><a href="welcome.php">Home</a></tr></td>';
  12. echo "</table>";
  13. echo"<br/>";
  14. echo"<br/>";
  15.  
  16. $fname = $_POST['fname'];
  17. $lname = $_POST['lname'];
  18. $password = $_POST['password'];
  19. $aadhar = $_POST['aadhar'];
  20. $age = $_POST['age'];
  21. $gender = $_POST['gender'];
  22. $email = $_POST['email'];
  23. $contact = $_POST['contact'];
  24. $address1 = $_POST['address1'];
  25. $address2 = $_POST['address2'];
  26. $district = $_POST['district'];
  27. $state = $_POST['state'];
  28. $course = $_POST['course'];
  29. $education = $_POST['education'];
  30. //echo"$address";
  31.  
  32. //insert data into database
  33. $sql= "INSERT INTO data (id,fname,lname,password,aadhar,age,gender,email,contact,address1,address2,district,state,course,education) VALUES('', '$fname', '$lname', '$password', '$aadhar', '$age', '$gender', '$email', '$contact', '$address1', '$address2', '$district', '$state', '$course', '$education')"; 
  34. $result= mysql_query($sql);
  35.  if($result){
  36.  echo"<br/>";
  37.  echo"<br/>";
  38.  echo"<br/>";
  39.  echo"<br/>";
  40.  echo"<br/>";
  41.  echo"<br/>";
  42.  echo'<table border="0" cellpadding="8" cellspacing="1" width="500" align="center">';
  43.  echo'<tr class="tableheader"><td align= "center"> Hello ' . $fname . ' You Are Successfully Registered</td></tr>';
  44.  echo'<tr class="tablerow"><td align= "center">We Will Contact You Shortly</td></tr>';
  45.  echo '<tr class="tableheader"><td align="center">Click Here To Go Back To <u><a href="welcome.php">Home</a></u></tr></td>';
  46.  echo"</table>";
  47.  } else {
  48.  $message ="Error!!";
  49.  echo $message;
  50.  }
  51.  
  52. ?>
  53.  
  54. </body>
  55.  


logout.php
Expand|Select|Wrap|Line Numbers
  1. <head>
  2. <link rel="stylesheet" type="text/css" href="style.css">
  3. </head>
  4. <body>
  5.  
  6. <?php
  7.  
  8. echo'<table border="0" cellpadding="6" cellspacing="1" width="50" align="right">';
  9. echo '<tr class="tablerow"><td align="center"><a href="welcome.php">Home</a></tr></td>';
  10. echo "</table>";
  11. echo"<br/>";
  12. echo"<br/>";
  13.  
  14. echo"<br/>";
  15. echo"<br/>";
  16. echo"<br/>";
  17. echo"<br/>";
  18. echo"<br/>";
  19. echo"<br/>";
  20. echo '<table border="0" cellpadding="6" cellspacing="1" width="500" align="center">';
  21. echo '<tr class="tableheader"><td align="center"> You Are Successfully Logged Out!!</tr></td>';
  22. echo '<tr class="tablerow"><td align="center">Bye Bye</tr></td>';
  23. echo '<tr class="tablerow"><td align="center"><a href="login.php">Click Here To Go To Home</a></tr></td>';
  24.  
  25. echo "</table>";
  26. ?>
  27.  
  28. </body>
  29.  
Jan 7 '16 #1
1 1256

Sign in to post your reply or Sign up for a free account.

Similar topics

30
by: Robert Tweed | last post by:
Does anyone know a good resource discussing the issues involved in session theft? I've read a couple, but none that really address the problem apart from acknowledging that it is a problem; you...
15
by: Thomas Scheiderich | last post by:
I am trying to understand Session variables and ran into a question on how they work with data that is passed. I have an HTM file that calls an ASP file and sends the name either by GET or POST....
9
by: Marcus | last post by:
Hello, Currently all of my php pages use SSL, not just my initial login. Originally I thought this would be more secure, but after thinking about things and looking at sites like Amazon and...
4
by: genc ymeri | last post by:
Hi I have placed an encounter code in the session_end as well in the session_start. I'm decreasing the number with 1 everytime a session ends. I open several IE-s and I closed some of them but...
5
by: Logickle | last post by:
Hi, all. I'm working on an application which requires communicating session info between separate web apps running on the same web server. The out of process server method sounded ideal, and...
1
by: sychedelico | last post by:
Hi I am using Visual Basic 2005 to add a logout page to the website I'm cureently working on. Could soneone help on the codes needed to end the session? Thanks!
3
by: Charles Abetz | last post by:
Hi all My problem is that I am creating a session file on the server when the user first visits my website, but when the user logs in i want to write to the file again with the timestamp and their...
2
by: Orgil | last post by:
I'm using ASP 3.0 however there is ASP.NET, because I'm working an old site that is built in ASP 3.0. I hope you for getting any help for my problem from you. So, my site's sessions are empty...
0
by: d0353101 | last post by:
I am having login.cgi. user enter id and password. if ok it redirects to main.cgi with user_id as main_page.cgi?user_id=$user_id. main.cgi is having left menu and right part is for doing some...
4
by: PHPstarter | last post by:
Basicly we're at a navigation page with a lot of different links. Clicking one of the links will lead you to a new index, but you would only be able to view the index if you are already logged in....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.