I am trying to compare two variables one is getting fetched from database and other is a textbox value.
If comparison is successful then the if statement block will return the value as matched and if they don't else statement block will return not matched
.
But it is always returning not matched
even if I enter same value that is in the database.
My code is this:
<?php
error_reporting(0);
$user_id = 5;
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db('qurefle');
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
if(isset($_POST["blccrcc"])){
$sql = 'SELECT l_coupon_c FROM cc_generator WHERE unique_id = "'.$user_id.'"';
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not get data: ' . mysql_error());
}
while($row = mysql_fetch_assoc($retval))
{
//fetching data
$l_coupon_c = $row['l_coupon_c'];
//Data Comparison
$friend_cc = $_POST["lccrcc"];
if ($l_coupon_c == $friend_cc) {
echo"it is matched";
}
else{
echo"Not Matched";
}
}//while bracket
}//if isset bracket
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>LCC AND RCC Coupon Code Chain Extender</title>
</head>
<body>
<center>
<form method="POST" action="">
Friend cc: <input type="text" name="lccrcc"><br><br>
<input type="submit" value="Use Coupon Code" name="blccrcc">
</form>
</center>
</body>
</html>