SHARE
TWEET

Untitled

a guest May 22nd, 2017 624 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     /*
  3.     * @Sistema de login e senha - Login.php
  4.     *
  5.     * @author Rafael Mafra
  6.     * @email rafaelcps2@gmail.com
  7.     * @version v1.0
  8.     */
  9.    
  10.     $table = 'table';
  11.    
  12.     mysql_connect("localhost","root","");
  13.     mysql_select_db("data_base");
  14.    
  15.     if(isset($_POST['action']) && $_POST['action'] == 'login'):
  16.         $email = trim($_POST['email']);
  17.         $pass = trim($_POST['pass']);
  18.        
  19.         if(empty($email)):
  20.             echo '<script>alert("Fill in e-mail")</script>';
  21.             echo '<script>history.back()</script>';
  22.             exit;
  23.         elseif(empty($pass)):
  24.             echo '<script>alert("Fill in pass")</script>';
  25.             echo '<script>history.back()</script>';
  26.             exit;
  27.         else:
  28.             $email = (!get_magic_quotes_gpc()) ? addslashes($email) : $email;
  29.             $pass = (!get_magic_quotes_gpc()) ? addslashes($pass) : $pass;
  30.             $pass = md5($pass);
  31.            
  32.             $sql = "SELECT * FROM $table WHERE user = '$email' AND pass = '$pass'";
  33.             $qr = mysql_query($sql) or die(mysql_error());
  34.            
  35.             if(mysql_num_rows($qr) == 0):
  36.                 echo '<script>alert("Email and/or password invalid")</script>';
  37.                 echo '<script>history.back()</script>';
  38.                 exit;
  39.             else:
  40.                 session_start();
  41.                 $_SESSION['email'] = $email;
  42.                 $_SESSION['pass'] = $pass;
  43.                 header("Location: index.php");
  44.             endif;
  45.         endif;
  46.     endif;
  47. ?>
  48.  
  49. <link rel="stylesheet" type="text/css" href="estilo.css"/>
  50. <body>
  51. <form method="post" action="">
  52. <fieldset>
  53. <legend>Login Form</legend>
  54. <label><span>E-mail</span><input name="email" type="text" size="35"/></label>
  55. <label><span>Pass</span><input name="pass" type="text" size="35"/></label>
  56.  
  57. <input type="hidden" name="action"  value="login" />
  58. <label><span><input type="submit" class="btn" value="Login" /></span></label>
  59. </fieldset>
  60. </form>
  61. </body>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top