Reputation: 991
I have a database with the name Harry Butler in it under the columns first_name and last_name with this code :
<?PHP
//Create the connection…
//("where the database is", 'Database login' , 'database password' , "Database name")
$con=mysqli_connect("", 'root', 'root', "Social");
//Check our connection…
if (mysqli_connect_errno($con))
{
echo " Sorry Mate";
}
$fname = $_POST[fname];
$lname = $_POST[lname];
$result = mysqli_query($con, "SELECT * FROM `User_info` WHERE first_name = '$fname' AND last_name = '$lname'");
while($row = mysqli_fetch_array($result))
{
echo $row['first_name'];
}
?>
Which gets the form data from the previous page :
<form action="searching.php" method="post">
<input id="fname" align="center" placeholder="First Name" name="fname"></input>
<input id="lname" align="center" placeholder="Last Name" name="lname"></input>
<select id="gender">
<option value="Male">Male</option>
<option value="Female">Female</option>
<option value="Other">Other</option>
<option value="God">God</option>
</select>
<br />
</form>
Yet when the results are submitted i get nothing any ideas?
Upvotes: 0
Views: 57
Reputation: 5645
change
$fname = $_POST[fname];
$lname = $_POST[lname];
to this:
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$_POST is associative array,so i hope it helped
Upvotes: 1