因此,我有2頁用於測試的多頁表單。當我單獨測試表單的第一部分時,它工作正常。所有信息都會根據從我的數據庫中檢索的信息進行顯示。一切都很好,直到我點擊提交按鈕到下一頁,確認所有的值。當我嘗試點擊提交時,應該也會傳遞用戶的輸入,並將它們保存爲$ _POST [],這會給我一個服務器錯誤。我對PHP很陌生,所以我不太熟悉我可能需要的所有東西。傳遞包含php變量的表單時遇到問題
這是我的第一部分代碼:
<?php
$db = mysql_connect(
':/Applications/MAMP/tmp/mysql/mysql.sock',
'root',
'root'
);
if(!$db) die("Error connecting to MySQL database.");
mysql_select_db('onlineform', $db);
$newQuery = mysql_query("SELECT newPrice,numberOfWeeks FROM onlineformdata ORDER BY id DESC LIMIT 1");
$newRow = mysql_fetch_row($newQuery);
$newQuery1 = mysql_query("SELECT newCampSessions FROM onlineformdata ORDER BY id DESC LIMIT 1") or die('Error ' . mysql_error());
$newFoo = mysql_fetch_array($newQuery1);
$newQuery2 = mysql_query("SELECT pricePerWeek FROM onlineformdata ORDER BY id DESC LIMIT 1") or die('Error ' . mysql_error());
$newFoo1 = mysql_fetch_array($newQuery2);
$newQuery3 = mysql_query("SELECT numberOfSchools FROM onlineformdata ORDER BY id DESC LIMIT 1");
$newRow1 = mysql_fetch_row($newQuery3);
$newQuery4 = mysql_query("SELECT schools FROM onlineformdata ORDER BY id DESC LIMIT 1") or die('Error ' . mysql_error());
$newFoo2 = mysql_fetch_array($newQuery4);
$newOldString = $newFoo['newCampSessions'];
$newOldString2 = $newFoo1['pricePerWeek'];
$newOldString3 = $newFoo2['schools'];
$newChangedString = unserialize($newOldString);
$newChangedString2 = unserialize($newOldString2);
$newChangedString3 = unserialize($newOldString3);
$_SESSION['quickVariable'] = $newChangedString2;
settype($newRow[1], "integer");
$limit = $newRow[1];
$anotherLimit = $newRow1[0];
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>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.7.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.10/jquery-ui.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<link type="text/css" rel="stylesheet" href="stylesheet.css"/>
<link href='http://fonts.googleapis.com/css?family=Alef' rel='stylesheet' type='text/css'>
<link type="text/css" rel="stylesheet" href="style3.css"/>
<script type="text/javascript" src="JavaScript.js">
</script>
<script type="text/javascript">var jslang='EN';
</script>
<link href="http://activemindandbody.orgStyleSheets/ModuleStyleSheets.css" rel="StyleSheet" type="text/css" />
<script type="text/javascript">var jslang='EN';
</script>
<link href="http://activemindandbody.org/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/modernizr.custom.04022.js"></script>
<link href='http://fonts.googleapis.com/css?family=Open+Sans+Condensed:700,300,300italic' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Alef' rel='stylesheet' type='text/css'>
</head>
<body>
<!-- BC_OBNW -->
<div id="container">
<div id="header"><div id="header_text" style="top: 118px; left: 23px;">
<p>Make a donation today and help âCreating a Brighter Future
Together.â <a href="http://activemindandbody.org/donation.html">Make a donation now !</a> </p>
</div>
</div>
<div id="content">
<section class="tabs">
<input id="tab-1" type="radio" name="radio-set" class="tab-selector-1" checked="checked" />
<label for="tab-1" class="tab-label-1">1. Camper's Info</label>
<input id="tab-2" type="radio" name="radio-set" class="tab-selector-2" />
<label for="tab-2" class="tab-label-2">2. Parent's Info</label>
<input id="tab-3" type="radio" name="radio-set" class="tab-selector-3" />
<label for="tab-3" class="tab-label-3">3. Emergency<br/> Contacts</label>
<input id="tab-4" type="radio" name="radio-set" class="tab-selector-4" />
<label for="tab-4" class="tab-label-4">4. Camper's Ride Home</label>
<input id="tab-5" type="radio" name="radio-set" class="tab-selector-5" />
<label for="tab-5" class="tab-label-5">5. <br/> Camp Days & Prices</label>
<input id="tab-6" type="radio" name="radio-set" class="tab-selector-6" />
<label for="tab-6" class="tab-label-6">6. Confirm your details</label>
<input id="tab-7" type="radio" name="radio-set" class="tab-selector-7" />
<label for="tab-7" class="tab-label-7">7. <br />Paypal</label>
</section>
<div class="clear-shadow"></div>
<div class="content indent">
<form id="paymentform" action="amd8.php" method="post">
<br/>
<br />
<label><b>Camp Sessions: 1-6 (Check off the week(s) the camper will be participating in.)</b> </label><br /><br />
<ol>
<?php
for ($count = 0; $count < $limit; $count=$count+1)
{
echo"<li>"; echo $newChangedString[$count]; echo '($'; echo $newChangedString2[$count]; echo '/child)<input type=checkbox name="campsessions[]" value="'; echo $newChangedString[$count]; echo '"></li>';
}
?>
</ol>
<br/>
<label><b>Select camp location:</b> </label><br /><br />
<select name="schoolChoice">
<?php
for ($count1 = 0; $count1 < $anotherLimit; $count1=$count1+1)
{
echo"<option value="; echo $newChangedString3[$count1]; echo '">'; echo $newChangedString3[$count1]; echo "</option>";
}
?>
</select>
<br/><br/>
<input type="hidden" name="totalprice" />
<input type="submit" name="formSubmit" value="Submit" class="button greenButton"/>
<input type="button" name="cancel" value="Cancel" class="button redButton" onclick="href='activemindandbody.org'">
</form>
</div>
</div>
</body>
</html>
而以下頁面:(將一個不,當我點擊提交我以前的頁面上,而是加載給了我一個「服務器錯誤「)
<?php
session_start();
if($_POST['formSubmit'] == "Submit")
{
$errorMessage="";
if (empty($_POST['campsessions[]']))
{
$errorMessage .="";
}
if (empty($_POST['campcare']))
{
$errorMessage ="";
}
if (empty($_POST['totalprice']))
{
$errorMessage ="";
}
$_SESSION['campcare'] = $_POST['campcare'];
$_SESSION['campsessions'] = $_POST['campsessions'];
$_SESSION['totalprice'] = $_POST['totalprice'];
$_SESSION['schoolChoice'] = $_POST['schoolChoice'];
$weeklyPrice = $_SESSION['quickVariable'];
$totalPrice = 0;
while (isset($_SESSION['campsessions']))
{
foreach ($weeklyPrice as $total)
{
$totalPrice = $totalPrice + $total;
}
}
}
?>
<!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>
<title>Active Mind And Body</title>
<!-- BC_OBNW -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="http://activemindandbody.org/StyleSheets/ModuleStyleSheets.css" rel="StyleSheet" type="text/css" />
<script type="text/javascript">var jslang='EN';</script>
<link href="http://activemindandbody.orgStyleSheets/ModuleStyleSheets.css" rel="StyleSheet" type="text/css" />
<script type="text/javascript">var jslang='EN';</script>
<link href="http://activemindandbody.org/style.css" rel="stylesheet" type="text/ css" />
<link rel="shortcut icon" href="../favicon.ico">
<link rel="stylesheet" type="text/css" href="css/demo.css" />
<link rel="stylesheet" type="text/css" href="style3.css" />
<script type="text/javascript" src="js/modernizr.custom.04022.js"></script>
<link href='http://fonts.googleapis.com/css?family=Open+Sans+Condensed: 700,300,300italic' rel='stylesheet' type='text/css'>
<link type="text/css" rel="stylesheet" href="stylesheet.css"/>
<link href='http://fonts.googleapis.com/css?family=Alef' rel='stylesheet' type='text/css'>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.7.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.10/jquery-ui.js"></script>
<script src="Javascript2.js" type="text/javascript"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<!-- BC_OBNW -->
<div id="container">
<div id="header"><div id="header_text" style="top: 118px; left: 23px;">
<p>Make a donation today and help âCreating a Brighter Future
Together.â <a href="http://activemindandbody.org/donation.html">Make a donation now !</a> </p>
</div>
</div>
<div id="content">
<section class="tabs">
<input id="tab-1" type="radio" name="radio-set" class="tab-selector-1" checked="checked" />
<label for="tab-1" class="tab-label-1">1. Camper's Info</label>
<input id="tab-2" type="radio" name="radio-set" class="tab-selector-2" />
<label for="tab-2" class="tab-label-2">2. Parent's Info</label>
<input id="tab-3" type="radio" name="radio-set" class="tab-selector-3" />
<label for="tab-3" class="tab-label-3">3. Emergency<br/> Contacts</label>
<input id="tab-4" type="radio" name="radio-set" class="tab-selector-4" />
<label for="tab-4" class="tab-label-4">4. Camper's Ride Home</label>
<input id="tab-5" type="radio" name="radio-set" class="tab-selector-5" />
<label for="tab-5" class="tab-label-5">5. <br/> Camp Days & Prices</label>
<input id="tab-6" type="radio" name="radio-set" class="tab-selector-6" />
<label for="tab-6" class="tab-label-6">6. Confirm your details</label>
<input id="tab-7" type="radio" name="radio-set" class="tab-selector-7" />
<label for="tab-7" class="tab-label-7">7. <br />Paypal</label>
</section>
<div class="clear-shadow"></div>
<div class="content indent">
<br />
Please confirm the following details:
<p class="confirmation">
<b>SPECIAL CONSIDERATIONS AND PAYMENT INFORMATION:</b><br/><br/>
Is Camper picked up? <?php echo $_SESSION['camperpickedup'] ?> <br/><br/>
Who is picking up the camper? <?php echo $_SESSION['personPickingUpCamper'] ?> <br/><br/>
Chosen Camp Sessions: <br/>
<pre> <?php
if(isset($_SESSION['campsessions']))
{
foreach ($_SESSION['campsessions'] as $_SESSION['campsessions'])
{
echo "{$_SESSION['campsessions']}\n";
}
}
?>
</pre> <br />
</p>
<p>
Total Price: $<?php echo $_SESSION['totalprice'] ?><br/><br/>
</p>
<form action="amd9.php" method="post">
<input type="submit" value='Confirm' class="button greenButton" name="formSubmit">
</form>
</div>
</div>
</body>
</html>
很抱歉,如果這是太多的代碼讓我知道這樣我就可以剪斷下來,我被處罰了很多不提供適當的信息最後一次。
但作爲一個更普遍的問題,我正在做什麼,關於使用php變量來顯示我的表單,好嗎? 還是那個大問題?
確切的錯誤是什麼? – user20232359723568423357842364
當我點擊提交時,第一頁是永久加載,最後說服務器錯誤。 – user2588785
我明白,但有很多類型的服務器錯誤..它究竟說了什麼?什麼是錯誤號碼? – user20232359723568423357842364