Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    No value inserted into database

    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:
    Code:
    <?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'];
    
    ?>
    
    
    
    <?php
    $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','$childName','$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());
    }
    else
    {
    echo 'Data has been input into the database';
    }
    mysql_close();
    }
    
    ?>
    Could anyone try to help me please?

    Thanks

    Mocha

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Tried echo'ing the $sql string to see if anything's actually been filled in?

  • #3
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I would also print_r($_REQUEST) to make sure that the data is actually making it to the page.

  • #4
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:

    Code:
    <form action="insert.php" name="frm_register"  id="frm_register" method="POST" >
      <br />
    
    
    <table width="100%" border="0" cellspacing="5" cellpadding="5">
    	<tr> 
    		<td colspan="2"><h2 align="center">Child's Particulars </h2></td>
    		
    
    	</tr>
      <tr>
        <td width="52%" align="right">Person who fill in this form: </td>
        <td width="48%"><label><?php echo $_REQUEST["person"]; ?></label></td>
        </tr>
      <tr>
        <td align="right">Venue (Choice 1):</td>
        <td><?php echo $_REQUEST["venue1"]; ?></td>
        </tr>
      <tr>
        <td align="right">Venue (Choice 2):</td>
        <td><?php echo $_REQUEST["venue2"]; ?></td>
        </tr>
      <tr>
        <td align="right">Venue (Choice 3): </td>
        <td><?php echo $_REQUEST["venue3"]; ?></td>
        </tr>
    <tr>  
    <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">
        </td></tr>
    Could anyone help me please?

  • #5
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •