[PHP] If Statement [Help]

Status
Not open for further replies.

wite

Posting Freak
Aug 3, 2012
593
131
Hi,

I need to create an If statement in PHP.

What this needs to do is if somebody gets their password wrong, a pop up box pops up and says "Incorrect passsword".

Anyone got any idea how to do this?
 

St4nley

Member
Apr 13, 2013
469
76
a thanks wouldnt be bad but here it is
remember, google is your friend

Code:
<?php
ob_start();
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="intranet"; // Database name
$tbl_name="employee"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Define $myusername and $mypassword
$salt = '~Z`!@#$%I^&*()_-+Q=}]{[\|"><';
$myusername = $_POST['txtunamea'];
$mypassword = $_POST['txtpassa'];
$encryptpass = hash('sha512', $mypassword . $salt);
//$sql = "SELECT * FROM $tbl_name WHERE uname = '$myusername' AND upass = '$mypassword')";
$sql= "SELECT * FROM employee WHERE uname='$username' and pswrd='$encryptpass'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
echo "correct Username or Password";
}
else {
    echo "$mypassword<br />";
    echo $encryptpass;
    echo $count;
    echo "Wrong Username or Password";
}
ob_end_flush();
?>
 

wite

Posting Freak
Aug 3, 2012
593
131
a thanks wouldnt be bad but here it is
remember, google is your friend

Code:
<?php
ob_start();
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="intranet"; // Database name
$tbl_name="employee"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Define $myusername and $mypassword
$salt = '~Z`!@#$%I^&*()_-+Q=}]{[\|"><';
$myusername = $_POST['txtunamea'];
$mypassword = $_POST['txtpassa'];
$encryptpass = hash('sha512', $mypassword . $salt);
//$sql = "SELECT * FROM $tbl_name WHERE uname = '$myusername' AND upass = '$mypassword')";
$sql= "SELECT * FROM employee WHERE uname='$username' and pswrd='$encryptpass'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
echo "correct Username or Password";
}
else {
    echo "$mypassword<br />";
    echo $encryptpass;
    echo $count;
    echo "Wrong Username or Password";
}
ob_end_flush();
?>

Thanks, - sorry for not saying thanks before.
 
Status
Not open for further replies.

Users who are viewing this thread

Top