It does not show any error when I run it but it does not store anything on the bookstore_hw3
database on the table clients.
There is one more column on the table clients called client_id
and is auto incremented. Is this the problem?
Can someone review this code and suggest what the problem is?
This is the HTML form:
<form action="clientData.php" method="post">
First Name: <input type='text' id='client_fname' /><br />
Last Name: <input type='text' id='client_lname' /><br />
City: <select id='client_city'>
<option>Please Choose</option>
<option>Prishtine</option>
<option>Mitrovice</option>
<option>Peje</option>
<option>Gjakove</option>
<option>Ferizaj</option>
<option>Prizren</option>
</select><br />
Gender: <select id='client_sex'>
<option>Please Choose</option>
<option>F</option>
<option>M</option>
</select><br />
Username(3-10 characters): <input type='text' id='client_username' /><br />
Password(3-10 characters): <input type='password' id='client_pass' /><br />
<input type='submit' value='Submit' />
<input type="reset" value="Clear" />
</form>
This is the PHP code:
<?php
include('db_login.php');
// Connect
$connection = mysql_connect($db_host, $db_username, $db_password);
if (!$connection){
die("Could not connect to the database: <br />". mysql_error( ));
}
// Select the database
$db_select = mysql_select_db($db_database);
if (!$db_select){
die ("Could not select the database: <br />". mysql_error( ));
}
$fname = isset($_POST['client_fname']);
$lname = isset($_POST['client_lname']);
$city = isset ($_POST['client_city']);
$sex = isset($_POST['client_sex']);
$username = isset ($_POST['client_username']);
$pass = isset($_POST['client_pass']);
$sql = "INSERT INTO clients (client_fname, client_lname, client_city, client_sex, client_username, client_pass) VALUES ('$fname','$lname','$city','$sex','$username','$pass')";
mysql_close();
echo "Data stored on database.";
?>
This is the login code:
<?php
$db_host='localhost';
$db_database='bookstore_hw3';
$db_username='root';
$db_password='';
?>