表格问题,提交不做任何事情

时间:2016-01-15 05:48:52

标签: javascript php html forms

我是HTML,PHP,JavaScript的新手,几乎所有的网页设计。我只想在继续之前把它放在那里。这是我的情况:我正在帮助一位朋友将他的网站转移到新的注册商和主机提供商。我登录FTP,复制了public_html的内容,并将其移动到他的新主机指向该站点的位置的public_html。唯一的问题是现在他的形式不再有效了。

我正在尝试“修复”当前的表单。单击“提交”按钮不执行任何操作。显然,它曾经工作过。我已经做了大量的阅读和研究,从我所知道的,表格缺少一些东西,例如说明它是一种形式。我不知道这个表单是发布到php还是一些javascript,这就是表单文件夹中的内容:

process.php

<?php

require_once '../phpmailer/PHPMailerAutoload.php';
include_once '../phpmailer/functions.php';

if( ! valid_captcha() ) die('Not valid');
if( form_is_empty($_POST) ) die('All fields required');


$name = $_POST['name'];
$email = $_POST['email'];
$phone = isset($_POST['phone']) ? $_POST['phone'] : 'N/A';
$rooms = isset($_POST['rooms']) ? $_POST['rooms'] : 'N/A';
$sqft = isset($_POST['sqft']) ? $_POST['sqft'] : 'N/A';
$message = $_POST['message'];

$date = date("F j, Y", strtotime('now'));

$html = <<<HTML
        <!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="format-detection" content="telephone=no">
    <title>Single Column</title>
    <style type="text/css">
        .header,
        .title,
        .subtitle,
        .footer-text {
            font-family: Helvetica, Arial, sans-serif;
        }

        .header {
            font-size: 24px;
            font-weight: bold;
            padding-bottom: 12px;
            color: #DF4726;
        }

        .footer-text {
            font-size: 12px;
            line-height: 16px;
            color: #aaaaaa;
        }
        .footer-text a {
            color: #aaaaaa;
        }

        .container {
            width: 600px;
            max-width: 600px;
        }

        .container-padding {
            padding-left: 24px;
            padding-right: 24px;
        }

        .content {
            padding-top: 12px;
            padding-bottom: 12px;
            background-color: #ffffff;
        }

        code {
            background-color: #eee;
            padding: 0 4px;
            font-family: Menlo, Courier, monospace;
            font-size: 12px;
        }

        hr {
            border: 0;
            border-bottom: 1px solid #cccccc;
        }

        .hr {
            height: 1px;
            border-bottom: 1px solid #cccccc;
        }

        .title {
            font-size: 18px;
            font-weight: 600;
            color: #374550;
            margin-bottom: 20px;
        }

        .subtitle {
            font-size: 16px;
            font-weight: 600;
            color: #2469A0;
        }
        .subtitle span {
            font-weight: 400;
            color: #999999;
        }

        .body-text {
            font-family: Helvetica, Arial, sans-serif;
            font-size: 14px;
            line-height: 20px;
            text-align: left;
            color: #333333;
        }

        body {
            margin: 0;
            padding: 0;
            -ms-text-size-adjust: 100%;
            -webkit-text-size-adjust: 100%;
        }

        table {
            border-spacing: 0;
        }

        table td {
            border-collapse: collapse;
        }

        .ExternalClass {
            width: 100%;
        }

        .ExternalClass,
        .ExternalClass p,
        .ExternalClass span,
        .ExternalClass font,
        .ExternalClass td,
        .ExternalClass div {
            line-height: 100%;
        }

        .ReadMsgBody {
            width: 100%;
            background-color: #ebebeb;
        }

        table {
            mso-table-lspace: 0pt;
            mso-table-rspace: 0pt;
        }

        img {
            -ms-interpolation-mode: bicubic;
        }

        .yshortcuts a {
            border-bottom: none !important;
        }

        @media screen and (max-width: 599px) {
            .force-row,
            .container {
                width: 100% !important;
                max-width: 100% !important;
            }
        }
        @media screen and (max-width: 400px) {
            .container-padding {
                padding-left: 12px !important;
                padding-right: 12px !important;
            }
        }
        .ios-footer a {
            color: #aaaaaa !important;
            text-decoration: underline;
        }


    </style>
</head>
<body style="margin:0; padding:0;" bgcolor="#F0F0F0" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

    <table border="0" width="100%" height="100%" cellpadding="0" cellspacing="0" bgcolor="#F0F0F0">
        <tr>
            <td align="center" valign="top" bgcolor="#F0F0F0" style="background-color: #F0F0F0;">

                <br>

                <!-- 600px container (white background) -->
                <table border="0" width="600" cellpadding="0" cellspacing="0" class="container">
                    <tr>
                        <td class="container-padding content" align="left">
                            <br>

                            <div class="title">Quote Request Form from Drterrazzo.com on {$date}</div>

                            <div class="body-text">
                                <table>
                                    <tr>
                                        <td><strong>Full Name</strong></td>
                                        <td>:</td>
                                        <td>$name</td>
                                    </tr>

                                    <tr>
                                        <td><strong>Email</strong></td>
                                        <td>:</td>
                                        <td>$email</td>
                                    </tr>

                                    <tr>
                                        <td><strong>Phone</strong></td>
                                        <td>:</td>
                                        <td>$phone</td>
                                    </tr>

                                    <tr>
                                        <td><strong>Rooms</strong></td>
                                        <td>:</td>
                                        <td>$rooms</td>
                                    </tr>

                                    <tr>
                                        <td><strong>Sq. Feet</strong></td>
                                        <td>:</td>
                                        <td>$sqft</td>
                                    </tr>

                                    <tr>
                                        <td><strong>Message</strong></td>
                                        <td>:</td>
                                        <td>$message</td>
                                    </tr>

                                </table>

                            </div>

                        </td>
                    </tr>
                </table><!--/600px container -->


            </td>
        </tr>
    </table><!--/100% background wrapper-->

</body>
</html>

HTML;

$config = getMailConfig();

$sendmail = sendMail($config['to'], $config['from'], $config['replyto'], 'Quote Request Form from Drterrazzo.com', $html);

if ($sendmail) {
$data = array('status' => 'success', 'message' => 'Form submitted. We will contact you as soon as possible.');
echo json_encode($data);
exit;
} else {
$data = array('status' => 'error', 'message' => 'Error submitting form. Please contact us via phone. Thank you.');
echo json_encode($data);
exit;
}

和quick-reservation.php

<?php

require_once '../phpmailer/PHPMailerAutoload.php';
include_once '../phpmailer/functions.php';

if( ! valid_captcha() ) die('Not valid');
if( form_is_empty($_POST) ) die('All fields required');


$name = $_POST['name'];
$email = $_POST['email'];
$phone = isset($_POST['phone']) ? $_POST['phone'] : 'N/A';
$rooms = isset($_POST['rooms']) ? $_POST['rooms'] : 'N/A';
$sqft = isset($_POST['sqft']) ? $_POST['sqft'] : 'N/A';
$message = $_POST['message'];

$date = date("F j, Y", strtotime('now'));

$html = <<<HTML
    <!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="format-detection" content="telephone=no">
    <title>Single Column</title>
    <style type="text/css">
        .header,
        .title,
        .subtitle,
        .footer-text {
            font-family: Helvetica, Arial, sans-serif;
        }

        .header {
            font-size: 24px;
            font-weight: bold;
            padding-bottom: 12px;
            color: #DF4726;
        }

        .footer-text {
            font-size: 12px;
            line-height: 16px;
            color: #aaaaaa;
        }
        .footer-text a {
            color: #aaaaaa;
        }

        .container {
            width: 600px;
            max-width: 600px;
        }

        .container-padding {
            padding-left: 24px;
            padding-right: 24px;
        }

        .content {
            padding-top: 12px;
            padding-bottom: 12px;
            background-color: #ffffff;
        }

        code {
            background-color: #eee;
            padding: 0 4px;
            font-family: Menlo, Courier, monospace;
            font-size: 12px;
        }

        hr {
            border: 0;
            border-bottom: 1px solid #cccccc;
        }

        .hr {
            height: 1px;
            border-bottom: 1px solid #cccccc;
        }

        .title {
            font-size: 18px;
            font-weight: 600;
            color: #374550;
            margin-bottom: 20px;
        }

        .subtitle {
            font-size: 16px;
            font-weight: 600;
            color: #2469A0;
        }
        .subtitle span {
            font-weight: 400;
            color: #999999;
        }

        .body-text {
            font-family: Helvetica, Arial, sans-serif;
            font-size: 14px;
            line-height: 20px;
            text-align: left;
            color: #333333;
        }

        body {
            margin: 0;
            padding: 0;
            -ms-text-size-adjust: 100%;
            -webkit-text-size-adjust: 100%;
        }

        table {
            border-spacing: 0;
        }

        table td {
            border-collapse: collapse;
        }

        .ExternalClass {
            width: 100%;
        }

        .ExternalClass,
        .ExternalClass p,
        .ExternalClass span,
        .ExternalClass font,
        .ExternalClass td,
        .ExternalClass div {
            line-height: 100%;
        }

        .ReadMsgBody {
            width: 100%;
            background-color: #ebebeb;
        }

        table {
            mso-table-lspace: 0pt;
            mso-table-rspace: 0pt;
        }

        img {
            -ms-interpolation-mode: bicubic;
        }

        .yshortcuts a {
            border-bottom: none !important;
        }

        @media screen and (max-width: 599px) {
            .force-row,
            .container {
                width: 100% !important;
                max-width: 100% !important;
            }
        }
        @media screen and (max-width: 400px) {
            .container-padding {
                padding-left: 12px !important;
                padding-right: 12px !important;
            }
        }
        .ios-footer a {
            color: #aaaaaa !important;
            text-decoration: underline;
        }


    </style>
</head>
<body style="margin:0; padding:0;" bgcolor="#F0F0F0" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

    <table border="0" width="100%" height="100%" cellpadding="0" cellspacing="0" bgcolor="#F0F0F0">
        <tr>
            <td align="center" valign="top" bgcolor="#F0F0F0" style="background-color: #F0F0F0;">

                <br>

                <!-- 600px container (white background) -->
                <table border="0" width="600" cellpadding="0" cellspacing="0" class="container">
                    <tr>
                        <td class="container-padding content" align="left">
                            <br>

                            <div class="title">Quote Request Form from Drterrazzo.com on {$date}</div>

                            <div class="body-text">
                                <table>
                                    <tr>
                                        <td><strong>Full Name</strong></td>
                                        <td>:</td>
                                        <td>$name</td>
                                    </tr>

                                    <tr>
                                        <td><strong>Email</strong></td>
                                        <td>:</td>
                                        <td>$email</td>
                                    </tr>

                                    <tr>
                                        <td><strong>Phone</strong></td>
                                        <td>:</td>
                                        <td>$phone</td>
                                    </tr>

                                    <tr>
                                        <td><strong>Rooms</strong></td>
                                        <td>:</td>
                                        <td>$rooms</td>
                                    </tr>

                                    <tr>
                                        <td><strong>Sq. Feet</strong></td>
                                        <td>:</td>
                                        <td>$sqft</td>
                                    </tr>

                                    <tr>
                                        <td><strong>Message</strong></td>
                                        <td>:</td>
                                        <td>$message</td>
                                    </tr>

                                </table>

                            </div>

                        </td>
                    </tr>
                </table><!--/600px container -->


            </td>
        </tr>
    </table><!--/100% background wrapper-->

</body>
</html>

HTML;

$config = getMailConfig();

$sendmail = sendMail($config['to'], $config['from'], $config['replyto'], 'Quote Request Form from Drterrazzo.com', $html);

if ($sendmail) {
$data = array('status' => 'success', 'message' => 'Form submitted. We will contact you as soon as possible.');
echo json_encode($data);
exit;
} else {
$data = array('status' => 'error', 'message' => 'Error submitting form. Please contact us via phone. Thank you.');
echo json_encode($data);
exit;
}

这是与表单相关的HTML:

 <div class="quote">
                    <h1>Quote Request </h1>
                    <form class="form mt10"><span style="display:none;">Don't enter anything here for proper submission...<input type="text" name="field" /></span>
                        <div class="field">
                            <input type="text" class="tinput" placeholder="Name (Required)" name="name" onclick="clearText(this)" onblur="clearText(this)"/>
                            <input type="text" class="tinput" placeholder="Email (Required)" name="email" onclick="clearText(this)" onblur="clearText(this)"/>
                            <input type="text" class="tinput" placeholder="Phone" name="phone" onclick="clearText(this)" onblur="clearText(this)"/>
                            <input type="text" class="tinput" placeholder="No. of Rooms" name="rooms" onclick="clearText(this)" onblur="clearText(this)"/>
                            <input type="text" class="tinput" placeholder="Approx Sq. ft." name="sqft" onclick="clearText(this)" onblur="clearText(this)"/>
                            <textarea class="traea" onclick="clearText(this)" onblur="clearText(this)" placeholder="Message" name="message"></textarea>
                            <input type="button" class="btn re-quote fr" >
                        </div>
                    </form>

                </div>

HTML中没有任何内容表示“我们正在创建一个表单”,所以我知道这可能是一个问题,除非       涵盖... Idk。我只需要一些指导。我很确定我是在推翻一切。请善待。

     <div class="quote">
                    <h1>Quote Request </h1>
                    <form class="form mt10" method"post" action="process.php"><span style="display:none;">Do not enter anything into this field for proper for submission...<input type="text" name="field" /></span>
                        <div class="field">
                            <input type="text" class="tinput" placeholder="Name (Required)" name="name" onclick="clearText(this)" onblur="clearText(this)"/>
                            <input type="text" class="tinput" placeholder="Email (Required)" name="email" onclick="clearText(this)" onblur="clearText(this)"/>
                            <input type="text" class="tinput" placeholder="Phone" name="phone" onclick="clearText(this)" onblur="clearText(this)"/>
                            <input type="text" class="tinput" placeholder="No. of Rooms" name="rooms" onclick="clearText(this)" onblur="clearText(this)"/>
                            <input type="text" class="tinput" placeholder="Approx Sq. ft." name="sqft" onclick="clearText(this)" onblur="clearText(this)"/>
                            <textarea class="traea" onclick="clearText(this)" onblur="clearText(this)" placeholder="Message" name="message"></textarea>
                            <input type="submit" class="btn re-quote fr" >
                        </div>
                    </form>

                </div>


            </div>

        </div>

1 个答案:

答案 0 :(得分:0)

form需要具有method值的POST属性才能作为POST进行处理。 form还需要action;该操作是表单提交的位置。

您的表单还需要input类型为submitimage,或者提供一些提交它的JavaScript函数。

所以你的form元素应该是:

<form class="form mt10" method="post" action="process.php">

并且您的submit元素应为:

<input type="submit" class="btn re-quote fr" >

要将该按钮作为图像,您可以使用image类型。您可以在here上了解更多信息:

<input type="image" src="image.png">

我建议您查看有关表单处理的一些教程: