Guest User

Untitled

a guest
Sep 24th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.72 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4.  
  5. $user='root';
  6. $server='localhost';
  7. $movies='movie';
  8.  
  9. mysql_connect($server,$user);
  10. mysql_select_db($movies);
  11. if (isset($_POST['submit'])) {
  12.  
  13. $username = mysql_real_escape_string($_POST['username']);
  14. $password = ($_POST['password']);
  15.  
  16. $sql = "SELECT id FROM users
  17. WHERE username = '$username'
  18. AND password = '$password'";
  19. $result = mysql_query($sql);
  20.  
  21. //No result from the database
  22. //Redirect back to login with errormessage
  23. if (mysql_num_rows($result) == 0) {
  24. header("Location: index.php?badlogin=");
  25. exit;
  26. }
  27.  
  28. session_regenerate_id(); //Do something about session fixation...
  29.  
  30. //Set sessions with user id and username
  31. $_SESSION['sess_id'] = mysql_result($result, 0, 'id');
  32. $_SESSION['sess_user'] = $_POST['username'];
  33. header("Location: index.php");
  34. exit;
  35. }
  36.  
  37. //Logout
  38. if (isset($_GET['logout'])) {
  39. session_unset();
  40. session_destroy();
  41. header("Location: index.php");
  42. exit;
  43. }
  44.  
  45. $password=$_POST['password'];
  46. $firstname=$_POST['firstname'];
  47. $email=$_POST['email'];
  48. $contactnum=$_POST['contactnum'];
  49. $uname=$_SESSION['sess_user'];
  50.  
  51. $sql=mysql_query("UPDATE users SET
  52. firstname='$firstname',
  53. password='$password',
  54. contactnum='$contactnum',
  55. email='$email'
  56. WHERE username='$uname'");
  57.  
  58. $result=mysql_query($sql); //or die(mysql_error());
  59.  
  60. if ($result==true)
  61. {
  62. $firstname=$_POST['firstname'];
  63. $query="SELECT * from users where firstname='$firstname'";
  64. $edited=mysql_query($query) or die(mysql_error());
  65. $userinfo=mysql_fetch_assoc($edited);
  66.  
  67. echo "<html>";
  68. echo"<head>";
  69. echo "<link rel='stylesheet' href='css/home.css' />";
  70. echo "<link rel='stylesheet' href='css/960.css' />";
  71. echo "<link rel='stylesheet' href='css/login-box.css' />";
  72. echo"</head>";
  73. echo"<body>";
  74.  
  75. echo "<div class='container_12'>";
  76.  
  77.  
  78. echo "<div class='grid_12'>";
  79. echo "<ul id='list-nav'>";
  80. echo "<li><a href='home.php'>Home</a></li>";
  81. echo " <li><a href='logregister.php'>Register</a></li>";
  82. echo " <li><a href='showing.php'>Now Showing</a></li>";
  83. echo "<li><a href='logcontact.php'>Contact Us</a></li>";
  84. echo "<li><a href='logabout.php'>About Us</a></li>";
  85. echo "</ul>
  86. </div>
  87.  
  88. <div class='grid_3'>
  89.  
  90. <h2 class='heck'> Welcome </h2>
  91. <div class='urong2'>";
  92.  
  93.  
  94.  
  95. //Logged in
  96.  
  97. echo "Hello " . $_SESSION['sess_user'] . ", how are you today?<br>\n";
  98. echo "<a href=\"Edit.php\"> My Account</a><br>\n";
  99. echo "<a href=\"index.php?logout=\">Log out</a>";
  100.  
  101.  
  102. echo "</div>
  103. </div>
  104. <div class='grid_5'>
  105. <h2 class='hick'> My Account </h2>
  106. <div id='stylized' class='myform'>";
  107. echo"<form method='post' action='delete_account.php' class='text'>";
  108. echo"<table border='0' align='center' width='300px'>";
  109. echo"<tr><td height='30px'>First Name:</td><td>$userinfo[firstname]</td></tr>";
  110. echo"<tr><td height='30px'>Last Name:</td><td>$userinfo[lastname]</td></tr>";
  111. echo"<tr><td height='30px'>Email Address:</td><td>$userinfo[emailadd]</td></tr>";
  112. echo"<tr><td height='30px'>Contact Number:</td><td>09$userinfo[contactnum]</td></tr>";
  113. echo"<tr><td height='30px'>Username:</td><td>$userinfo[username]</td></tr>";
  114. echo"<tr><td height='30px'>Password:</td><td>$userinfo[password]</td></tr>";
  115. echo"<tr><td colspan='2' align='center' height='40px'><input type='submit' value='Delete Account' name='submit'/>";
  116.  
  117. echo"</div>";
  118. echo"</table>";
  119.  
  120. echo"</form>";
  121. echo "</div> </div>
  122.  
  123.  
  124. <div class='grid_3'>
  125. <h2 class='hack'> Movies </h2>
  126.  
  127. <img src = 'image/movies.gif' width='250px' class='urong'/>
  128.  
  129.  
  130. </div>
  131. <div class='grid_12'>
  132. <center>
  133. <p class='hola'> Copyright &copy; 2012. ReelMovieTicket.com. </p>
  134. </center>
  135. </div>
  136. </div>
  137.  
  138. </body>
  139. </html>";
  140. }
  141. ?>
Add Comment
Please, Sign In to add comment