0
我使用PHP中的會話變量從一個頁面傳遞布爾值到另一個頁面,第二頁是爲了顯示結果,如果提交表單,我想觸發提交按鈕,如果布爾是真實的,並自動顯示結果,(回聲),但如果錯誤,頁面應顯示爲其意圖。由於我是新來的,請幫忙!另外,我對Ajax並不熟悉。使用會話變量觸發提交按鈕
感謝
<?php
session_start();
if(isset($_SESSION['answer'])) {
$v11=$_SESSION['answer'];//boolean value
}
$q=100;
$f=200;
$r=300;
?>
<link rel="stylesheet" type="text/css" href="../../styles/messages.css" />
<html>
<table cellpadding="0" cellspacing="0" border="0">
<form action="" name = "page0" method="GET" enctype="multipart/form- data">
<tr >
<td colspan= > ID </td><br>
<td colspan="2" size="30"> NAME </td>
<td colspan="3" size="50" > MACH </td>
</tr>
<tr>
<td colspan=><input type="text" name="ID" class="rw" value="<?php $phpvar=$v11; echo $phpvar; ?>"></td>
<td colspan="2" ><input type="text" name="NAME" class="rw" size="30" value="<?php $phpvar=$f; echo $phpvar; ?>"></td>
<td colspan="2"><input type="text" name="MACH" class="rw" size="70" value="<?php $phpvar=$r; echo $phpvar; ?>"></td>
</tr>
<input type="submit" button class="button" value="Calculate" name="second_call" onclick= "document.write('<?php hello(); ?>');" />
</form>
</table>
</html>
<?php
function hello()
{
//some operation using values q, f, r
echo(result);
//i want this echo to work when i click submit on the previous page from where im redirecting here if v11=true
}
?>
你能後的樣本你的代碼? – meucaa
我編輯過! –