Link to home
Start Free TrialLog in
Avatar of syedasimmeesaq
syedasimmeesaqFlag for United States of America

asked on

The form doesn't send the value

I am trying to send the value of the for using this code to another update form

<?php
session_start();
require_once('rti_con_info.php');
$query = "SELECT * FROM survey where usercosf='".$_SESSION['COSFuser']."'";

$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body><form action="update.php" method="POST">

<table width="707" border="2">
  <tr>
    <td>R Id</td>
    <td>Dev</td>
    <td>Last Name</td>
    <td>First Name</td>
    <td>Month of Birth</td>
    <td>Date of Birth</td>
    <td>year of Birth</td>
  </tr>
<?php
$i=0;
while ($i < $num) {


$reigonid = mysql_result($result, $i,"reigonid");
$devlschool = mysql_result($result, $i,"devlschool");
$cln = mysql_result($result, $i, "cln");
$cfn = mysql_result($result, $i, "cfn");
$cdb_m = mysql_result($result, $i, "cdb_m");
$cdb_d = mysql_result($result, $i, "cdb_d");
$cdb_y = mysql_result($result, $i, "cdb_y");
$sid = mysql_result($result, $i, "sid");

?>
<tr>
<td><font face="Arial, Helvetica, sans-serif"><? echo $reigonid; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo $devlschool; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo $cln; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo $cfn; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo $cdb_m; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo $cdb_d; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo $cdb_y; ?></font></td>
<td> <?php echo $sid; ?></td>
<td><input type="submit" value="Update"></td>
</form>

<?
$i++;
}

echo "</table>";
?>
</body>
</html>
Now i need to send the $sid so it selects only related record and this is how my update form is set. I need to get the values out of the database and prepopulate the update form. However it is not getting any values from the database.
Please look at the update form in code snippet section below

Thanks


XXXXXXXupdate formXXXXXXXXXX
<?php
session_start();
 
if ($_SESSION['user'] && $_SESSION['pass']) {//1
 
 
if(isset($_POST["submit"]))
{//2
require_once('r_con_info.php');
$update_id=$_POST['sid'];
$reigonid = mysql_real_escape_string($_POST['reigonid']);
$devlschool = mysql_real_escape_string($_POST['devls']);
$cln = mysql_real_escape_string($_POST['cln']);
$cfn = mysql_real_escape_string($_POST['cfn']);
$cdb_m = mysql_real_escape_string($_POST['cdb_m']);
$cdb_d = mysql_real_escape_string($_POST['cdb_d']);
$cdb_y = mysql_real_escape_string($_POST['cdb_y']);
 
$updatequery = "UPDATE survey  SET reigonid='".$reigonid."', devls='".$devlschool."', cln='".$cln."',cfn='".$cfn."',cdb_m='".$cdb_m."', cdb_d='".$cdb_d."',cdb_y='".$cdb_y."',
WHERE usercosf='".$_SESSION['user']."'AND sid='$update_id'";
 
$resultupdate = mysql_query($updatequery) or die(mysql_error());
				echo"<BR><BR>Your records have been updated";
 
 
 
  }
        else 
        {
		require_once('rti_con_info.php');
                $query = "SELECT * FROM survey where usercosf='".$_SESSION['user']."'AND sid='$update_id'";
                
                
                $result = mysql_query($query);
                
                $row = mysql_fetch_array($result);
                
         
                
                
?>
 
<form id="form1" name="form1" method="post" action="process.php">
  <table width="790" border="1" bgcolor="#F1EACF">
    <tr>
      <td width="285"><p class="style1">I. Background</p></td>
      <td width="492">&nbsp;</td>
    </tr>
    <tr>
      <td>1.Today"s Date:</td>
      <strong><td><center><font color="red"><b><?php echo date("m-d-Y"); ?></b></font><input name="modifieddate" type="hidden" value="<?php echo date("Y-m-d"); ?>" /></td></strong>
    </tr>
    <tr>
      <td>2.Region:</td>
      <td>
        <?php echo $row['regionid']; ?>
    
      </td>
    </tr>
    <tr>
      <td>3.  Site:</td>
      <td><input name="devlschool" type="text" id="devlschool" size="32" value="<?php echo $row['devlschool']; ?>"/></td>
    </tr>
    <tr>
      <td>4. Last Name:</td>
      <td><input name="cln" type="text" id="cln" size="32" value="<?php echo $row['cln']; ?>"/></td>
    </tr>
    <tr>
      <td>5.First Name:</td>
      <td><input name="cfn" type="text" id="cfn" size="32" value="<?php echo $row['cfn']; ?>"/></td>
    </tr>
    <tr>
      <td>6Date of Birth:</td>
      <td><table width="200" border="0">
        <tr>
          <td><select name="cdb_m" id="cdb_m">
              <option>January</option>
              <option>Feburary</option>
              <option>March</option>
              <option>April</option>
              <option>May</option>
              <option>June</option>
              <option>July</option>
              <option>August</option>
              <option>September</option>
              <option>October</option>
              <option>November</option>
              <option>December</option>
              <option selected><?php echo $row['cdb_m']; ?></option>
          </select></td>
          <td><select name="cdb_d" id="cdb_d">
              <option>01</option>
              <option>02</option>
              <option>03</option>
              <option>04</option>
              <option>05</option>
              <option>06</option>
              <option>07</option>
              <option>08</option>
              <option>09</option>
              <option>10</option>
              <option>11</option>
              <option>12</option>
              <option>13</option>
              <option>14</option>
              <option>15</option>
              <option>16</option>
              <option>17</option>
              <option>18</option>
              <option>19</option>
              <option>20</option>
              <option>21</option>
              <option>22</option>
              <option>23</option>
              <option>24</option>
              <option>25</option>
              <option>26</option>
              <option>27</option>
              <option>28</option>
              <option>29</option>
              <option>30</option>
              <option>31</option>
              <option selected><?php echo $row['cdb_d']; ?></option>
          </select></td>
          <td><select name="cdb_y" id="cdb_y">
              <option>2000</option>
              <option>2001</option>
              <option>2002</option>
              <option>2003</option>
              <option>2004</option>
              <option>2005</option>
              <option>2006</option>
              <option selected><?php echo $row['cdb_y']; ?></option>
              
              </select></td>
              
              </form>
 
 
</body>
</html>
<?
}
echo "
<form action='logout.php' method='post'>
<input type='submit' value='Logout' style='height: 40px; width: 200px; color: red; font:bold'>
</form>";  
		}
		else
		{ echo"please have a valid username and password assigned to you";}
		
?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Frosty555
Frosty555
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oh also, if there's no errors, echo out the $query parameter and make sure it looks right. If necessary, pop open your mysql admin tool (usually its phpmyadmin on your webhost) and manually execute the query. It's always possible that the query actually didn't return any rows, and that the  behavior was correct.

Check the value of $num after you run the query to make sure it returned records.

OH! And DON'T CALL mysql_close(); UNTIL YOU'RE DONE WITH EVERYTHING! It dumps all your data! I just saw that.
Avatar of syedasimmeesaq

ASKER

Well for first, I just seen the submit button missing in the first form..the name is missing. So I fixed now I am getting sql syntax error. Will post back here shortly
Now it says Unknown column 'ing10' in 'field list'
I know in mysql I have column called ing10
how come it is not recognizing it..any help will be great.
Thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial