Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ob_start();
- $host="mysql5.000webhost.com"; // Host name
- $sqlusername="X"; // Mysql username
- $sqlpassword="X"; // Mysql password
- $db_name="X"; // Database name
- $tbl_name="X"; // Table name
- // Connect to server and select databse.
- mysql_connect("$host", "$sqlusername", "$sqlpassword")or die("cannot connect");
- mysql_select_db("$db_name")or die("cannot select DB");
- // Define $username and $password
- $username=$_POST['username'];
- $password=$_POST['password'];
- $sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password'";
- $result=mysql_query($sql);
- // Mysql_num_row is counting table row
- $count=mysql_num_rows($result);
- // If result matched $myusername and $password, table row must be 1 row
- if($count==1){
- // Register $myusername, $password and redirect to file "login_success.php"
- session_register("username");
- session_register("password");
- header("location:home.php");
- }
- else {
- echo "Wrong Username or Password";
- }
- ob_end_flush();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement