The first problem is in the HTML code. PHP recognizes the data from the HTML form by the attribute name
not id
, so you should modify your HTML tags this way:
<input type='text' id='client_fname' name='client_fname' />
The second problem is with your PHP code. Replace this part:
$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']);
with this:
$fname = isset($_POST['client_fname']) ? $_POST['client_fname'] : null;
$lname = isset($_POST['client_lname']) ? $_POST['client_lname'] : null;
$city = isset ($_POST['client_city']) ? $_POST['client_city'] : null;
$sex = isset($_POST['client_sex']) ? $_POST['client_sex'] : null;
$username = isset ($_POST['client_username']) ? $_POST['client_username'] : null;
$pass = isset ($_POST['client_pass']) ? $_POST['client_pass'] : null;
isset()
only checks if the variable exists and returns true/false. In my code, the statement isset(foo) ? foo : bar
checks if the variable exists and if yes, its content is returned, if no, then null
is returned.
The third problem is that you are not executing your SQL query on the database. So add there also this:
mysql_query($sql);
Also your PHP code is vulnerable to SQL injection and should be fixed (you can read more about it in this post: How can I prevent SQL injection in PHP?)