Selected responses on form are not picked up on 2nd php page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Karl Forshee

    Selected responses on form are not picked up on 2nd php page

    I have a section of code that I'm stumped on how to handle. The Selected options on the drop down menues are not being picked up on the second PHP page. That is to say the variables error, error1 & error2 on the second page remain blank. I had the same issue with other variables, but was able to fix them with $_POST, but not sure how to handle this with the query.

    This form worked great on our main server, but doesn't want to work on the PHP enabled Qnap. Here is the section of script for page 1. It pulls the information from a database. It is displayed correctly on the users screen. at the bottom is page 2

    Code:
    $result19 = mysql_query("SELECT * FROM struc order by number DESC limit 1"); 
    $f = mysql_fetch_array($result19); 
    $i = 100; 
    $zx = 0; 
    for ($i =100; $i<=$f[number] ; $i +100){ 
    $result11 = mysql_query("SELECT * FROM catagory where number = '$i' ORDER BY catagory"); 
    $w = mysql_fetch_array($result11); 
    ?> 
              <tr>  
                <td width="269" bgcolor="#284357"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF"><b>  
                  <? 
    echo "$w[catagory]"; 
    ?> 
                  </b></font></td> 
                <td width="47" bgcolor="#284357">  
                  <input type="radio" name="chk" value="<? echo $i; ?>"> 
                </td> 
                <td width="398" bgcolor="#284357">  
                  <select class=texta name="<? echo $i; ?>" onchange="changeRadio(document.forms[0].chk,this,<? echo $zx; ?>)"> 
                    <option>  
                    <? 
    $result8 = mysql_query("SELECT * FROM struc where number = '$i' ORDER BY name "); 
    if ($h = mysql_fetch_array($result8)) { 
    do{ 
    ?> 
                   <option>  
                    <? echo $h[name]; ?> 
                    </option> 
     
                    <?php 
     
    }  
    while($h = mysql_fetch_array($result8));     
    } 
    ?> 
                  </select> 
                </td> 
              </tr> 
              <? 
     
    $zx = $zx + 1; 
    $i = $i + 100; 
    } 
    ?>
    --------------------------------------------------------------------------------

    Now the problem script on page 2
    Code:
    $result19 = mysql_query("SELECT * FROM struc order by number DESC limit 1"); 
    $f = mysql_fetch_array($result19); 
    $n = 0; 
    for ($i = 100; $i <= $f[number] ; $i + 100) 
    { 
      if ($$i != "") 
    { 
       $y[$n] = $$i;  
       $n = $n + 1; 
    } 
    $i = $i + 100; 
    } 
    $error = $y[0]; 
    $error1 = $y[1]; 
    $error2 = $y[2]; 
     
     
                    <p><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">1.  
                      <? echo $error; ?> 
                      <font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">  
                      </font> </font></p> 
                    <input type="hidden" name="error" value="<? echo $error; ?>"> 
                    <p><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">2.  
                      <? echo $error1; ?> 
                      </font></p> 
                    <input type="hidden" name="error1" value="<? echo $error1; ?>"> 
                    <p><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">3.  
                      <? echo $error2; ?> 
                      </font></p> 
                    <input type="hidden" name="error2" value="<? echo $error2; ?>">
  • Shenno
    New Member
    • Sep 2010
    • 59

    #2
    u had to specify value attribute in option tag..

    look at example below..

    Code:
                   <option value="<? echo $h[name]; ?>">   
                    <? echo $h[name]; ?>  
                    </option>
    bettween option tags u specify the string that just appear to user and not rly sent to second php page..

    in option value attribute u specify the value that will be sent when that option has been selected..

    hope this helps.

    Comment

    • Karl Forshee

      #3
      Thanks for the suggestion. I tried this but still had same results.

      I'm thinking it has to do with the line
      <select class=texta name="<? echo $i; ?>" onchange="chang eRadio(document .forms[0].chk,this,<? echo $zx; ?>)">

      Since $i is a number I don't know how to use $_POST to get the selected response on the second php page. Tried changing <? echo $i; ?> to test[] & on 2nd page use $test = $_POST('test'); but the 2nd page crashes after submit is pressed.

      Comment

      Working...