2012-06-27 43 views
0

我想連接形式使用其中一個輸入作爲主鍵的形式。連接形式通過PHP和主鍵

例如,

---其中主密鑰被取

form1.php 

第一形式---第二形式,其中第1頁是基於輸入來自Form1中

form2.php?page1=primary key 

---第三種形式,其中page1基於來自form2的輸入

form3.php?page2=primary key 

---第四形式,其中第2頁第1頁是

form4.php?page3=primary key 

---第四形式,其中第3頁第2頁是

,並依此類推,直到最後一頁。我的問題是我如何連接它們?我如何檢索主要並將其傳遞給所有涉及的表單?到目前爲止,我只能將主鍵傳遞給form2,當它到達form3時,它就會消失。

順便說一句,每個表格完成後,它進入一個處理頁面。

---下面是一個樣表的代碼

<form id="form1" name="form1" method="post" action="eval_2.php"> 
      <table width="100%" border="0" cellpadding="2" cellspacing="0"> 

      <tr> 
      <td width="70%"> 
      <strong>1. Quality of Work </strong><br /> 
      - refers to his/her ability to work with thoroughness. 
      </td> 
      <td align="center"> <select name="qualityremark"> 
       <option>Select Remark</option> 
       <option>O</option> 
       <option>VS</option> 
       <option>S</option> 
       <option>US</option> 
       <option>P</option> 
      </select></td> 
      </tr> 

      <tr> 
      <td width="70%" height="10%"> &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; a. Works outstandingly accurate and complete in details</td> 
      <td width="30%" align="left"> O - Outstanding </td> 
      </tr> 
      <tr> 
      <td width="70%"> &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; b. Does thorough work; rarely commit errors</td> 
      <td width="30%" align="left"> VS - Very Satisfactory </td> 
      </tr> 
      <tr> 
      <td width="70%"> &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; c. Fairly completes work with few errors</td> 
      <td width="30%" align="left"> S - Satisfactory </td> 
      </tr> 
      <tr> 
      <td width="70%"> &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; d. Work is often incomplete, inaccurate</td> 
      <td width="30%" align="left"> US - Unsatisfactory</td> 
      </tr> 
      <tr> 
      <td width="70%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;e. Very careless work; errors frequently repeated</td> 
      <td width="30%" align="left"> P - Poor</td> 
      </tr> 
      <tr> 
      <td> Comments: </td> 
      <td></td> 
      </tr> 
      <tr> 
      <td><textarea name="qualitycomment" cols="80" rows="5" id="qualitycomment"></textarea></td> 
      </tr> 
      </table>  
      <tr> 
      <td></td> 
      <td><div align="right"> 
      <a href="performanceeval.php">Back</a>&nbsp;|&nbsp; 
      <!--<a href="performanceeval3.php">Next</a> --> 
      <input type="submit" value="Next" name="next" id="next" class="silver_button"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div></td> 
      </tr><br /> 
      </form> 

---下面是用於該過程頁面的代碼

require_once("dbconnect_gentemplate.php"); 
require_once("attendanceClass.php"); 

$newAcct= new attendance(); 
$m=$newAcct->eval_2(); 

$current=$_GET['page1']; 


header("Location: performanceeval3.php?page2=$current"); 

---下面爲函數的代碼

function eval_2(){ //page 2 

$current=$_GET['page1']; 

// $command="select recentact from ojt_evaluation"; 
// $commando=mysql_query($command) or die("Error ".mysql_error()); 
// $commander=mysql_fetch_array($commando); 

// $current=$commander['recentact']; 
// $cur=md5($current); 

if(isset($_POST['next'])){ 
    $qualityremark=$_POST['qualityremark']; 
    $qualitycomment=$_POST['qualitycomment']; 

    if(trim($qualityremark)=="") return "<p>Error creating account;blank qualityremark</p>"; 

    $sql="update ojt_evaluation set qualityremark='$qualityremark', qualitycomment='$qualitycomment' where student='$current'"; 

    $query=mysql_query($sql)or die ("Error".mysql_error()); 
    } 
    // header("Location: performanceeval3.php?session=$current"); 
} 

我哪裏錯了?我該怎麼辦?幫幫我!

回答

2

我想你沒有通過在以下變量的任何查詢字符串

將是空的,沒有參數的值賦給第1頁

$current=$_GET['page1']; 

還有一想到提交按鈕會點擊在加載

形式的行動可能ü嘗試這個

<form id="form1" name="form1" method="post" action="eval_2.php?page1=form1"> 
+0

第1頁被指定爲 '$電流= $ _ POST [ '學生']; header(「Location:performanceeval2.php?page1 = $ current」);' '$ _POST ['student']'是從form1獲取的用作'主鍵'的輸入 – ayou

+0

其中u表示賦值第1頁..給我看.. – 2012-06-27 06:15:45

+0

,因爲發佈評論的時間太長,我已將它放在shrib上, - > http://shrib.com/form1_ayou – ayou

0

你沒有正確地實例化你的變量。

header("Location: performanceeval3.php?page2=$current"); 

嘗試此

header('Location: performanceeval3.php?page2=' . $current . ');