Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * @Sistema de login e senha - Login.php
- *
- * @author Rafael Mafra
- * @email rafaelcps2@gmail.com
- * @version v1.0
- */
- $table = 'table';
- mysql_connect("localhost","root","");
- mysql_select_db("data_base");
- if(isset($_POST['action']) && $_POST['action'] == 'login'):
- $email = trim($_POST['email']);
- $pass = trim($_POST['pass']);
- if(empty($email)):
- echo '<script>alert("Fill in e-mail")</script>';
- echo '<script>history.back()</script>';
- exit;
- elseif(empty($pass)):
- echo '<script>alert("Fill in pass")</script>';
- echo '<script>history.back()</script>';
- exit;
- else:
- $email = (!get_magic_quotes_gpc()) ? addslashes($email) : $email;
- $pass = (!get_magic_quotes_gpc()) ? addslashes($pass) : $pass;
- $pass = md5($pass);
- $sql = "SELECT * FROM $table WHERE user = '$email' AND pass = '$pass'";
- $qr = mysql_query($sql) or die(mysql_error());
- if(mysql_num_rows($qr) == 0):
- echo '<script>alert("Email and/or password invalid")</script>';
- echo '<script>history.back()</script>';
- exit;
- else:
- session_start();
- $_SESSION['email'] = $email;
- $_SESSION['pass'] = $pass;
- header("Location: index.php");
- endif;
- endif;
- endif;
- ?>
- <link rel="stylesheet" type="text/css" href="estilo.css"/>
- <body>
- <form method="post" action="">
- <fieldset>
- <legend>Login Form</legend>
- <label><span>E-mail</span><input name="email" type="text" size="35"/></label>
- <label><span>Pass</span><input name="pass" type="text" size="35"/></label>
- <input type="hidden" name="action" value="login" />
- <label><span><input type="submit" class="btn" value="Login" /></span></label>
- </fieldset>
- </form>
- </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement