Advertisement
Guest User

Untitled

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