表格在提交时显示空白页面

时间:2017-02-25 20:44:26

标签: php html forms post submit

我曾经遇到过其他问题而且似乎没有任何帮助我! 我设法使用之前的帮助主题获得了感谢信息,但从未导致过电子邮件。请帮帮我!

Html代码

<form name="AberdaronApplication" method="post" action="submit.php">
                <div class="form-group">
                    <div class="form-inline">
                        <label class="sr-only" for="ContactName">Main Contact Name</label>
                        <input type="text" name="ContactName" class="form-control main" id="ContactName" placeholder="Main Contact Name">

                        <label class="sr-only" for="FirstAddress">AddressFirstLine</label>
                        <input type="text" name="FirstAddress" class="form-control main" id="FirstAddress" placeholder="First Line of Address">
                    </div>
                </div>
                <div class="form-group">
                    <div class="form-inline">
                        <label class="sr-only" for="HomeNumber">Home Number</label>
                        <input type="tel" name="HomeNumber" class="form-control" id="HomeNumber" placeholder="Home Telephone">

                        <label class="sr-only" for="SecondAddress">Second Line of Address</label>
                        <input type="text" name="SecondAddress" class="form-control" id="SecondAddress" placeholder="Second Line of Address">
                     </div>
                </div>
                <div class="form-group">
                    <div class="form-inline">
                        <label class="sr-only" for="MobileNumber">Mobile Number</label>
                        <input type="tel" name="MobileNumber" class="form-control" id="MobileNumber" placeholder="Mobile Number">

                        <label class="sr-only" for="City">City</label>
                        <input type="text" name="City" class="form-control" id="City" placeholder="City">
                    </div>
                </div>
                <div class="form-group">
                    <div class="form-inline">
                        <label class="sr-only" for="Email">Email Address</label>
                        <input type="email" name="Email" class="form-control" id="Email" placeholder="Email Address">

                    <label class="sr-only" for="PostCode">Post Code</label>
                    <input type="text" name="PostCode" class="form-control" id="PostCode" placeholder="Post Code">
                    </div>
                </div>
                <div class="form-group">
                    <div class="form-inline">
                        <label class="sr-only" for="dob">dob</label>
                        <input type="date" name="dob" class="form-control dob" id="dob" placeholder="Date of Birth">

                        <label class="sr-only" for="age">Age</label>
                        <input type="number" name="age" class="form-control age" id="age" placeholder="Age">

                        <label class="sr-only" for="allergy">allergy</label>
                        <input type="text" name="allergy" class="form-control ale" id="allergy" placeholder="Allergies/Medical Info">
                     </div>
                </div>
                <br />
                <p class="Left">Details of Attendees<br />
                                    <small>Leave fields blank if no attendees and scroll down to Details of Accommodation</small></p>
                <div class="form-group">
                    <label class="sr-only" for="Contact1">Attendee Name</label>
                    <input type="text" name="Contact1" class="form-control main" id="Contact1" placeholder="Attendee Name">
                </div>
                <div class="form-group">
                    <div class="form-inline">
                        <label class="sr-only" for="dob1">dob</label>
                        <input type="date" name="dob1" class="form-control dob" id="dob1" placeholder="Date of Birth">

                        <label class="sr-only" for="age1">age</label>
                        <input type="number" name="age1" class="form-control age" id="age1" placeholder="Age">

                        <label class="sr-only" for="allergy1">allergy</label>
                        <input type="text" name="allergy1" class="form-control ale" id="allergy1" placeholder="Allergies/Medical Info">
                     </div>
                </div>
                <br />
                <div class="form-group">
                    <label class="sr-only" for="Contact2">Attendee Name</label>
                    <input type="text" name="Contatc2" class="form-control main" id="Contact2" placeholder="Attendee Name">
                </div>
                <div class="form-group">
                    <div class="form-inline">
                        <label class="sr-only" for="dob2">dob</label>
                        <input type="date" name="dob2" class="form-control dob" id="dob2" placeholder="Date of Birth">

                        <label class="sr-only" for="age2">age</label>
                        <input type="number" name="age2" class="form-control age" id="age2" placeholder="Age">

                        <label class="sr-only" for="allergy2">allergy</label>
                        <input type="text" name="allergy2" class="form-control ale" id="allergy2" placeholder="Allergies/Medical Info">
                     </div>
                </div>
                <br />
                <div class="form-group">
                    <label class="sr-only" for="Contact3">Attendee Name</label>
                    <input type="text" name="Contact3" class="form-control main" id="Contact3" placeholder="Attendee Name">
                </div>
                <div class="form-group">
                    <div class="form-inline">
                        <label class="sr-only" for="dob3">dob</label>
                        <input type="date" name="dob3" class="form-control dob" id="dob3" placeholder="Date of Birth">

                        <label class="sr-only" for="age3">age</label>
                        <input type="number" name="age3" class="form-control age" id="age3" placeholder="Age">

                        <label class="sr-only" for="allergy3">allergy</label>
                        <input type="text" name="allergy3" class="form-control ale" id="allergy3" placeholder="Allergies/Medical Info">
                     </div>
                </div>
                <br />
                <div class="form-group">
                    <label class="sr-only" for="Contact4">Attendee Name</label>
                    <input type="text" name="Contact4" class="form-control main" id="Contact4" placeholder="Attendee Name">
                </div>
                <div class="form-group">
                    <div class="form-inline">
                        <label class="sr-only" for="dob4">dob</label>
                        <input type="date" name="dob4" class="form-control dob" id="dob4" placeholder="Date of Birth">

                        <label class="sr-only" for="age4">age</label>
                        <input type="number" name="age4" class="form-control age" id="age4" placeholder="Age">

                        <label class="sr-only" for="allergy4">allergy</label>
                        <input type="text" name="allergy4" class="form-control ale" id="allergy4" placeholder="Allergies/Medical Info">
                     </div>
                </div>
                <br />
                <div class="form-group">
                    <label class="sr-only" for="Contact5">Attendee Name</label>
                    <input type="text" name="Contact5" class="form-control main" id="Contact5" placeholder="Attendee Name">
                </div>
                <div class="form-group">
                    <div class="form-inline">
                        <label class="sr-only" for="dob5">dob</label>
                        <input type="date" name="dob5" class="form-control dob" id="dob5" placeholder="Date of Birth">

                        <label class="sr-only" for="age5">age</label>
                        <input type="number" name="age5" class="form-control age" id="age5" placeholder="Age">

                        <label class="sr-only" for="allergy5">allergy</label>
                        <input type="text" name="allergy5" class="form-control ale" id="allergy5" placeholder="Allergies/Medical Info">
                     </div>
                </div>
                <br />
                <div class="form-group">
                    <label class="sr-only" for="Contact6">Attendee Name</label>
                    <input type="text" name="Contact6" class="form-control main" id="Contact6" placeholder="Attendee Name">
                </div>
                <div class="form-group">
                    <div class="form-inline">
                        <label class="sr-only" for="dob6">dob</label>
                        <input type="date" name="dob6" class="form-control dob" id="dob6" placeholder="Date of Birth">

                        <label class="sr-only" for="age6">age</label>
                        <input type="number" name="age6" class="form-control age" id="age6" placeholder="Age">

                        <label class="sr-only" for="allergy6">allergy</label>
                        <input type="text" name="allergy6" class="form-control ale" id="allergy6" placeholder="Allergies/Medical Info">
                     </div>
                </div>
                <br />
                <p class="Left">Details of Accommodation</p>
                <div class="form-group">
                    <select class="form-control">
                      <option>Camp Pod</option>
                      <option>Camp Tent</option>
                      <option>Own Tent</option>
                      <option>Own Caravan   </option>
                    </select>
                </div>


                <input type="submit" value="submit" id="submit" class="btn btn-success">Book Place</input>

               </form>

PHP代码

<?php
$ContactName = $_POST['ContactName'];
$FirstAddress = $_POST['FirstAddress'];
$SecondAddress = $_POST['SecondAddress'];
$City = $_POST['City'];
$Postcode = $_POST['Postcode'];
$HomeNumber = $_POST['HomeNumber'];
$MobileNumber = $_POST['MobileNumber'];
$Email = $_POST['Email'];

$Contact1 = $_POST['Contact1'];
$dob1 = $_POST['dob1'];
$age1 = $_POST['age1'];
$allergy1 = $_POST['allergy1'];

$Contact2 = $_POST['Contact2'];
$dob2 = $_POST['dob2'];
$age2 = $_POST['age2'];
$allergy2 = $_POST['allergy2'];

$Contact3 = $_POST['Contact3'];
$dob3 = $_POST['dob3'];
$age3 = $_POST['age3'];
$allergy3 = $_POST['allergy3'];

$Contact4 = $_POST['Contact4'];
$dob4 = $_POST['dob4'];
$age4 = $_POST['age4'];
$allergy4 = $_POST['allergy4'];

$Contact5 = $_POST['Contact5'];
$dob5 = $_POST['dob5'];
$age5 = $_POST['age5'];
$allergy5 = $_POST['allergy5'];

$Contact6 = $_POST['Contact6'];
$dob6 = $_POST['dob6'];
$age6 = $_POST['age6'];
$allergy6 = $_POST['allergy6'];

$formcontent = $ContactName . "\n" . $FirstAddress . "\n" . $SecondAddress . "\n" . $City . "\n" . $Postcode . "\n" . $HomeNumber . "\n" . $MobileNumber . "\n" . $Email . "\n" . $Contact1 . "\n" . $dob1 . "\n" . $age1 . "\n" . $allergy1 . "\n" . $Contact2 . "\n" . $dob2 . "\n" . $age2 . "\n" . $allergy2 . "\n" . $Contact3 . "\n" . $dob3 . "\n" . $age3 . "\n" . $allergy3 . "\n" . $Contact4 . "\n" . $dob4 . "\n" . $age4 . "\n" . $allergy4 . "\n" . $Contact5 . "\n" . $dob5 . "\n" . $age5 . "\n" . $allergy5 . "\n" . $Contact6 . "\n" . $dob6 . "\n" . $age6 . "\n" . $allergy6;
$to = 'myemail@me.com';
$subject = "Aberdaron Camp Booking";
$mailheader = "From:" $ContactName "\r \n";

if (isset($_POST['submit'])) 
{
    if (mail($to, $subject, $formcontent, $mailheader))
    { 
        echo '<p>Your message has been sent!</p>';
    } 
    else 
    { 
        echo '<p>Something went wrong, go back and try again!</p>'; 
    }
}
?>

2 个答案:

答案 0 :(得分:0)

您没有在name="ContactName" 帖子中添加<input type="text"....来获取name的输入值,而不是来自id put {在您的每个输入中{1}},然后选择name<input type="text" name="put field name here"...>

你的代码应该是这样的:

select name="name here"

并在<input type="number" name="age5" class="form-control age" id="age5" placeholder="Age"> 中连接(。)换行符,如:

$formcontent

<强>更新

扩展标题

$formcontent =   $ContactName . "\n" . $FirstAddress ."\n" . $so_on ;

答案 1 :(得分:0)

需要添加,如果服务器请求如下:

3

添加更多连接

   #include <iostream>

class A
{
public:
    A(int n = 0)
        : m_i(n)
    {
        std::cout << m_i;
        ++m_i;
    }

protected:
     int m_i;
};

class B
    : public A
{
public:
    B(int n = 5) : m_a(new A[2]), m_x(++m_i){ std::cout << m_i; }

    ~B() { delete [] m_a;}

private:
    A m_x;
    A *m_a;

};

int main()
{
    B b;
    std::cout << std::endl;

    return 0;
}

问题解决了