Improve company productivity with a Business Account.Sign Up

x
?
Solved

The form doesn't send the value

Posted on 2007-12-06
5
Medium Priority
?
208 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
  • 2
  • 2
5 Comments
 
LVL 31

Accepted Solution

by:
Frosty555 earned 1000 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 1000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Laravel is the most sought after web development framework. It comes with ample amount of features that make it easy for developers to work around it. Know about its features in detail.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

595 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