View Full Version : No value inserted into database

01-25-2007, 10:03 AM
Hi all

I have a problem inserting value into the database. When I click the submit button on a preview page, it goes to insert.php where a record is added into the database but the fields are blank. Below are the codes for insert.php:

$person = $_REQUEST["person"];
$venue1 = $_REQUEST["venue1"];
$venue2 = $_REQUEST["venue2"];
$venue3 = $_REQUEST["venue3"];
$day1 = $_REQUEST["day1"];
$day2 = $_REQUEST["day2"];
$day3 = $_REQUEST["day3"];
$timeslot1 = $_REQUEST["timeslot1"];
$timeslot2 = $_REQUEST["timeslot2"];
$timeslot3 = $_REQUEST["timeslot3"];
$childName = $_REQUEST["childName"];
$nationality = $_REQUEST["nationality"];
$sex = $_REQUEST["sex"];
$race = $_REQUEST["race"];
$religion = $_REQUEST["religion"];
$homeAddress = $_REQUEST ["homeAddress"];
$correspondingAddress = $_REQUEST ["correspondingAddress"];
$postCode = $_REQUEST ["postCode"];
$areaCode = $_REQUEST ["areaCode"];
$telNo = $_REQUEST ['telNo'];
$language = $_REQUEST ['language'];
$birthcertNo = $_REQUEST ['birthcertNo'];
$dy = $_REQUEST ['birthDate'];
$mo = $_REQUEST ['birthMonth'];
$yr = $_REQUEST ['birthYear'];
$siblings = $_REQUEST ['siblings'];
$preschoolDate = $_REQUEST ['preschoolDate'];
$preschoolName = $_REQUEST ['preschoolName'];
$pastillness = $_REQUEST ['pastIllness'];
$checkOne = $_REQUEST ['declaration'];
$handicaps = $_REQUEST ['handicaps'];


$con = mysql_connect("localhost","root","");
if (!$con)
die('Could not connect: ' . mysql_error());

mysql_select_db("euusers", $con);

if(isset($_REQUEST['Submit'])) {

$sql="INSERT INTO tbl_euusers (person, venue1, venue2, venue3, day1, day2, day3, timeslot1, timeslot2, timeslot3,childName, nationality, sex, race, religion, homeAddress, correspondingAddress, postCode, areacode, telNo, language, birthcertNo, birthDate, birthMonth, birthYear, siblings, preschoolDate, preschoolName, pastIllness, declaration, handicaps)
VALUES('$_REQUEST[person]','$venue1','$venue2','$venue3','$day1','$day2','$day3','$timeslot1','$timeslot2','$timeslot3','$chi ldName','$nationality','$sex','$race','$religion','$homeAddress',
'$correspondingAddress','$postCode','$areaCode','$telNo','$language', '$birthcertNo','$dy','$mo','$yr','$siblings','$preschoolDate', '$preschoolName', '$pastillness', '$checkOne','$handicaps')";

$result = mysql_query($sql,$con);
if (!$result) {
die('Invalid query: ' . mysql_error());
echo 'Data has been input into the database';


Could anyone try to help me please?



01-25-2007, 10:31 AM
Tried echo'ing the $sql string to see if anything's actually been filled in?

01-25-2007, 10:52 AM
I would also print_r($_REQUEST) to make sure that the data is actually making it to the page.

01-26-2007, 01:31 AM
Both of you are right. The data is not making to the innsert.php page. What am I missing in form_preview.php? Why it is not global? Here is the code for form_preview.php:

<form action="insert.php" name="frm_register" id="frm_register" method="POST" >
<br />

<table width="100%" border="0" cellspacing="5" cellpadding="5">
<td colspan="2"><h2 align="center">Child's Particulars </h2></td>

<td width="52%" align="right">Person who fill in this form: </td>
<td width="48%"><label><?php echo $_REQUEST["person"]; ?></label></td>
<td align="right">Venue (Choice 1):</td>
<td><?php echo $_REQUEST["venue1"]; ?></td>
<td align="right">Venue (Choice 2):</td>
<td><?php echo $_REQUEST["venue2"]; ?></td>
<td align="right">Venue (Choice 3): </td>
<td><?php echo $_REQUEST["venue3"]; ?></td>
<td align="right"><input type="button" value=" &lt;-- BACK " onclick="history.go(-1);return false;" /> </td>
<td colspan="2" align="left">
<input name="Submit" type="submit" id="Submit" value="Submit">

Could anyone help me please?

01-26-2007, 02:32 AM
You need to put the values into form fields, or session variables. You can't submit plain text through a form without it being in a field. Try putting them into hidden text inputs