Solved

The form doesn't send the value

Posted on 2007-12-06
5
202 Views
Last Modified: 2013-12-12
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

0
Comment
Question by:syedasimmeesaq
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 31

Accepted Solution

by:
Frosty555 earned 250 total points
ID: 20424926
The biggest culprit is most likely your connection info.

In your  r_con_info.php file, I assume you call mysql_connect() somewhere. That function returns a link_id resource for your connection. Make sure that it actually returns something. If not, use mysql_error() to figure out what the error was.

Similarely, if you are connecting okay, make sure your query did not have errors in it. Call mysql_error() just after the call to mysql_query() to return any errors generated by the query.
0
 
LVL 31

Expert Comment

by:Frosty555
ID: 20424941
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.
0
 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 20425229
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
0
 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 20425370
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
0
 
LVL 3

Assisted Solution

by:HeroGuran
HeroGuran earned 250 total points
ID: 20427823
You are not using ing10 in any queries in the code you have posted.
Can you update us?

Some guesses are:
* Requesting the field name from the wrong table in a query (in order for this error to occor, it must be called)
* Referencing the wrong file (It looks like process.php is the upper one, and update.php is the lower. Is that correct?)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Wordpress Only run code if on a certain page 11 35
Showing multiple maps using PHP and Google Maps 12 42
PHP Web Development 6 28
Find RGB colors from a screen. 2 19
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question