Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ob_start();
- $host="localhost"; // Host name
- $username="root"; // Mysql username
- $password="pass"; // Mysql password
- $db_name="stuffs"; // Database name
- $tbl_name="users"; // Table name
- mysql_connect("$host", "$username", "$password")or die("cannot connect");
- mysql_select_db("$db_name")or die("cannot select DB");
- $myusername=$_POST['username'];
- $mypassword=$_POST['password'];
- $myusername = stripslashes($myusername);
- $mypassword = stripslashes($mypassword);
- $myusername = mysql_real_escape_string($myusername);
- $mypassword = mysql_real_escape_string($mypassword);
- $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
- $result=mysql_query($sql);
- $count=mysql_num_rows($result);
- if($count==1){
- echo "success";
- // Register $myusername, $mypassword and redirect to file "login_success.php"
- //session_register("myusername");
- //session_register("mypassword");
- //header("location:login_success.php");
- }
- else {
- echo "Wrong username or password.";
- }
- ob_end_flush();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement