An empty row created in my mysql database

Problems with the Windows version of XAMPP, questions, comments, and anything related.

An empty row created in my mysql database

Postby julyhad » 18. September 2010 15:04

In the code below, am trying to build a form that will be sumitted to the database. Before submitting to the database the user will preveiw all what he has typed in the form and click confirm button to totally submit the details to the database.
The problem am having is that, the preveiw will print all the form input but when i click confirm button an empty row will be inserted into the database.
Pls, i need your help what else i can do to fix the error?
Thanks,
Julyhad.


<?php
$eppttitle = $_POST['eppttitle'];
$sname = $_POST['sname'];
$fname = $_POST['fname'];
$mname = $_POST['mname'];
if(isset($_POST['btncon'])){
$insert = (" INSERT INTO $dbtable(eppttitle,sname,fname)VALUES('$eppttitle','$sname','$fname')") ;
mysql_query($insert) or die (mysql_error());
header("location: indexpg.php ");}?>

<html><head><title>User Form</title></head><body>
<?
if(!isset($_POST['ret'])){ ?>
<form name="epptformfill" action="" method="post">
Title:<select name="eppttitle" id="eppttitle" >
<option value"<?=$eppttitle?>">--Please Select--</option>
<option value"<?=$eppttitle?>">Miss.</option>
<option value"<?=$eppttitle?>">Mr.</option>
<option value"<?=$eppttitle?>">Mrs.</option>
</select>
First Name:<input name="sname" type="text" id="sname" value="<?=$sname?>" size="35" maxlength="25" />
Middle Name:<input name="fname" type="text" id="fname" size="35" maxlength="25" />
<input name="ret" type="submit" value="preview" " >
</form>
<? } else{ ?>
If you are sure of the informations you just provided click the submit button below.<br>
First Name:<?=$fname?><br>
Middle Name: <?=$sname?><br>
Title:<?=$eppttitle?><br>
<input name="btncon" type="submit" value="Comfirm" >
<? } ?>
</body>
</html>
julyhad
 
Posts: 5
Joined: 21. February 2010 18:37

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 64 guests