Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $loginpopup = 'Login Success';
- $failpopup = 'Wrong Username or Password';
- if(!$con)
- {
- die("Error connection" . mysqli_connect_error());
- }
- if (isset($_POST['submitlogin']))
- {
- $login = "SELECT * from admin where username = '$_POST[user]' AND password ='$_POST[pass]'";
- $getuser = mysqli_query($con,$login) or die(mysql_error());
- while($row = mysqli_fetch_array($getuser))
- {
- if($row==0)
- {
- echo "<SCRIPT>alert('$failpopup');</SCRIPT>";
- header("location:index.php");
- }
- else
- {
- echo "<SCRIPT>alert('$loginpopup');</SCRIPT>";
- header("location:home.php");
- }
- }
- }
- ?>
- include('movieshub/includes/config.php');
- if ($getuser = mysqli_query($con,$login)) { // check if the query succeeded running
- $count = mysqli_num_rows($getuser);
- if ($count == 0 ) {
- echo "<SCRIPT>alert('$failpopup');</SCRIPT>";
- header("location:index.php");
- } else {
- while($row = mysqli_fetch_array($getuser))
- { //output data }
- echo "<SCRIPT>alert('$loginpopup');</SCRIPT>";
- header("location:home.php");
- }
- }
- } else {
- echo "query failed to run";
- }
- <?php
- //if your are using wamp then let $servername,$username and $password be same as below otherwise change them.
- $servername = "localhost"; //insert your severname at the place of localhost
- $username = "root"; //insert your username at the place of root
- $password = ""; //insert your password at the place of ""
- // Create connection
- $con = mysqli_connect($servername, $username, $password);
- //select database
- mysqli_select_db($con,"test"); //here enter your database name at the place of test
- // Check connection
- if (!$con) {
- die("Connection failed: " . mysqli_connect_error());
- }
- $loginpopup = 'Login Success';
- $failpopup = 'Wrong Username or Password';
- if (isset($_POST['submitlogin']))
- {
- $user=$_POST["user"];
- $pass=$_POST["pass"];
- $login = "SELECT * from admin where username=$user AND password=$pass";
- $getuser = mysqli_query($con,$login);
- $row=mysqli_affected_rows($con);
- if($row>1)
- {
- echo "<SCRIPT>alert('$loginpopup');</SCRIPT>";
- header("location:home.php");
- }
- else
- {
- echo "<SCRIPT>alert('$failpopup');</SCRIPT>";
- header("location:index.php");
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement