Advertisement
Guest User

Untitled

a guest
Mar 8th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1.  
  2. <!DOCTYPE HTML>
  3. <html>
  4. <head>
  5. <title>Sign-In</title>
  6. <link rel='stylesheet'type='text/css' href='style-sign.css'>
  7. </head>
  8. <body id='body-color'> <div id='Sign-In'>
  9. <fieldset style='width:30%'><legend>LOG-IN HERE</legend>
  10. <form method='POST'action='connectivity.php'>
  11. <br><input type='text' name='username' size='40'><br> Password
  12. <br><input type='password' name='pass' size='40'><br>
  13. <input id='button' type='submit' name='submit' value='Log-In'>
  14. </form>
  15. </fieldset>
  16. </div>
  17. </body>
  18. </html>
  19.  
  20. <a href='http://xxxxxxxxxx.xxx/register.htm'>Register</a>
  21.  
  22. <?php
  23. require_once("connectivity.php");
  24.  
  25. try {
  26. /* Call connection to database function */
  27. $db = getConnection();
  28.  
  29. /* SQL Queries ---------------------------------------- */
  30.  
  31. /*Request the post functions from the loginForm.php */
  32. $name = $_REQUEST['name'];
  33. $password = $_REQUEST['pass'];
  34. $sublogin = $_REQUEST['sublogin'];
  35.  
  36. $sql="SELECT * FROM name WHERE email ='$name'
  37. AND pass='".md5($_POST['pass'])."'";
  38. $password['pass'];
  39. $query = $db->query( $sql );
  40.  
  41. if (count($db->$query)>0) {
  42. //Login Successful . Update the database, adding timestamp of last time member logged in.
  43. $db->query("UPDATE name SET lastlogin='". date("Y-m-d H:i:s",time())."' where email='".$_SESSION['name']."' and password='".$_SESSION['password']."'");
  44.  
  45. $name = $db->fetch($result);
  46. $_SESSION['name']=$name['name'];
  47. $_SESSION['password']=$password['password'];
  48. //Write session to disc
  49. session_write_close();
  50. header("location: test2.php");
  51. exit();
  52. }
  53. if(isset($_POST['sublogin'])){
  54. /* Check that all fields were typed in */
  55. if(!$_POST['name'] || !$_POST['pass']){
  56. die('You didn\'t fill in a required field.');
  57. }
  58.  
  59. /* Checks that email is in database and password is correct */
  60. $md5pass = md5($_POST['pass']);
  61. $result = confirmUser($_POST['name'], $md5pass);
  62.  
  63. /* Check error codes */
  64. if($result == 1){
  65. die('That name doesn\'t exist in our database.');
  66. }
  67. else if($result == 2){
  68. die('Incorrect password, please try again.');
  69. }
  70.  
  71. /* email and password correct, register session variables */
  72. $_POST['name'] = $_POST['name'];
  73. $_SESSION['name'] = $_POST['name'];
  74. $_SESSION['password'] = $md5pass;
  75. }
  76. }
  77. catch( PDOException $e ) {
  78. echo $e->getMessage();
  79. }
  80. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement