标题已发送错误联系引擎

时间:2017-12-16 10:34:44

标签: php

自定义订阅表单会产生可怕的错误。

警告:无法修改标题信息 - 已经发送的标题(/customers/3/3/a/website.nl/httpd.www/aanmelden/contactengine.php:87中的输出)/ customers / 3/3第89行/a/website.nl/httpd.www/aanmelden/contactengine.php

联系引擎不会发送表单,它显示此错误。 并弹出不会发送消息的JavaScript错误。

有人有什么建议吗?

  

catch(Exception $ e){       print" window.alert(' Bericht is niet verzonden')&#34 ;;       打印" http://www.website.com/aanmelden/index.php \">&#34 ;;       标题('位置:http://www.website.com/aanmelden/index.php');警告:无法修改标头信息 - 已发送的标头   (输出开始于/ ... contactengine.php:82)/ customers / 3/3 / a / ....   在线84 [在此处输入图像说明] [1]

contactengine.php

<?php
  use PHPMailer\PHPMailer\PHPMailer;
  use PHPMailer\PHPMailer\SMTP;
  use PHPMailer\PHPMailer\Exception;
  ini_set('display_errors', '1');
  require('src/PHPMailer/vendor/autoload.php');

  $mail = new PHPMailer(true);
  try {
    $mail->IsSMTP();  // Telling the class to use SMTP
    $mail->SMTPDebug = 0; // shows debugging
    $mail->Host     = "mailout.one.com"; // SMTP server
    $mail->SMTPAuth = true;
    $mail->Username = "--"; // "The account"
    $mail->Password = "--"; // "The password"
    $mail->SMTPSecure = "false";
    $mail->Port = 25; // "The port"


// - Mailer: SMTP Mail Function 
// - Mail from: [active account in your domain]
// - From Name: [your name]
// - Sendmail Path   /usr/sbin/sendmail 
// - SMTP Authentication:  True  
// - SMTP Username: [Same as the Mail from stated above]
// - SMTP Password: [password of the above username]
// - SMTP Host: mailout.one.com
// - SMTP Security: [none]
// - Port 25

    $mail->setFrom('info@email.com', 'Buisiness name');
    $mail->addAddress('info@email.com'); // recipient address
    $mail->addReplyTo('info@email.com');

    $mail->isHTML(true);
    $mail->Subject = 'Nieuwe aanmelding';

    $mail->Body = "";
    $mail->Body .= "<h3>Nieuwe aanmelding</3>";
    $mail->Body .= "<h5>Nieuwe aanmelding</h5>";
    $mail->Body .= Trim(stripslashes($_POST['aanhef']));
    $mail->Body .= " ";
    $mail->Body .= Trim(stripslashes($_POST['Name']));
    $mail->Body .= Trim(stripslashes($_POST['Surname']));
    $mail->Body .= "<br /><br />";
    $mail->Body .= "<h5>Geboorteland</h5>";
    $mail->Body .= Trim(stripslashes($_POST['geboorteland']));
    $mail->Body .= "<br /><br />";
    $mail->Body .= "<h5>BSN</h5>";
    $mail->Body .= Trim(stripslashes($_POST['bsn']));
    $mail->Body .= "<br /><br />";
    $mail->Body .= "<h5>Geboortedatum</h5>";
    $mail->Body .= Trim(stripslashes($_POST['date']));
    $mail->Body .= "<br /><br />";
    $mail->Body .= "<h5>Aankomst</h5>";
    $mail->Body .= Trim(stripslashes($_POST['aankomst']));
    $mail->Body .= "<br /><br />";
    $mail->Body .= "<h5>Woonadres</h5>";
    $mail->Body .= Trim(stripslashes($_POST['woonadres']));
    $mail->Body .= "<br /><br />";
    $mail->Body .= "<h5>Postcode</h5>";
    $mail->Body .= Trim(stripslashes($_POST['postcode']));
    $mail->Body .= "<br /><br />";
    $mail->Body .= "<h5>Woonplaats</h5>";
    $mail->Body .= Trim(stripslashes($_POST['woonplaats']));
    $mail->Body .= "<br /><br />";
    $mail->Body .= "<h5>Telefoonnummer</h5>";
    $mail->Body .= Trim(stripslashes($_POST['telefoon']));
    $mail->Body .= "<br /><br />";
    $mail->Body .= "<h5>Aanmelding voor locatie</h5>";
    $mail->Body .= Trim(stripslashes($_POST['locatie']));
    $mail->Body .= "<br /><br />";
    $mail->Body .= "<h5>Inschrijving</h5>";
    $mail->Body .= Trim(stripslashes($_POST['inschrijven']));

    $mail->send();
    print "<script language=JavaScript>window.alert('Bericht is verzonden')</script>";
    print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.website.com/aanmelden/index.php\">";
    header('Location: index.php');
  } catch (Exception $e) {
    print "<script language=JavaScript>window.alert('Bericht is niet verzonden')</script>";
    print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.website.com/aanmelden/index.php\">";
    header('Location: http://www.website.com/aanmelden/index.php');
  }

?>

aanmelden.php

<?php include_once ('../inc/header.inc.php'); ?>


<form method="post" action="contactengine.php">

                                                    <div class="container">
                                                        <div class="row">
                                                            <div class="col-md-3 col-md-offset-0">
                                                                <p>Aanhef<br /> Preamble // الى حضرة<br/>
                                                                </div>
                                                            <div class="col-md-6 col-md-offset-0">
                                                                <ul class=" style-5 clearfix"><li>
                                                                    <select name="aanhef">
                                                                        <option value="Dhr">Dhr. | Mr.  | السيد</option>
                                                                    <option value="Mevr">Mevr. | Mrs. | السيدة</option>
                                                                </select>
                                                                </ul></div>
                                                        </div>

                                                        <div class="row">
                                                            <div class="col-md-3 col-md-offset-0"><p>Voornaam<br/>First name // الإسم الشخصي<br/></div>
                                                            <div class="col-md-6 col-md-offset-0"><ul class=" style-5 clearfix"><li>
                                                                    <input type="text" name="Name" id="Name" cols="10" class="textbox" required /><br />
                                                            </li></ul></div>
                                                        </div>

                                                        <div class="row">
                                                            <div class="col-md-3 col-md-offset-0"><p>Achternaam<br/>Surname // الاسم العائلي<br/></div>
                                                            <div class="col-md-6 col-md-offset-0"><ul class=" style-5 clearfix"><li>
                                                                    <input type="text" name="Surname" id="Surname" cols="10" class="textbox" required /><br />
                                                            </li></ul></div>
                                                        </div>

                                                        <div class="row">
                                                        <div class="col-md-3 col-md-offset-0"><p>Geboorteland<br/>Country of Birth//  بلد الولادة<br/></div>
                                                        <div class="col-md-6 col-md-offset-0">
                                                        <ul class=" style-5 clearfix"><li>
                                                                <select name="geboorteland" id="geboorteland">
                                                                    <option value="0" label="Select a country … " selected="selected">Select a country … </option>
                                                                    <optgroup id="country-optgroup-Africa" label="Africa">
                                                                        <option value="Algeria" label="Algeria">Algeria</option>
                                                                        <option value="Angola" label="Angola">Angola</option>
                                                                        <option value="Benin" label="Benin">Benin</option>
                                                                        <option value="Botswana" label="Botswana">Botswana</option>
                                                                        <option value="Burkina Faso" label="Burkina Faso">Burkina Faso</option>
                                                                        <option value="Burundi" label="Burundi">Burundi</option>
                                                                        <option value="Cameroon" label="Cameroon">Cameroon</option>
                                                                        <option value="Cape Verde" label="Cape Verde">Cape Verde</option>
                                                                        <option value="Central African Republic" label="Central African Republic">Central African Republic</option>
                                                                        <option value="Chad" label="Chad">Chad</option>
                                                                        <option value="Comoros" label="≈">Comoros</option>
                                                                        <option value="Congo Brazzaville" label="Congo - Brazzaville">Congo - Brazzaville</option>
                                                                        <option value="Congo Kinshasa" label="Congo - Kinshasa">Congo - Kinshasa</option>
                                                                        <option value="Côte d’Ivoire" label="Côte d’Ivoire">Côte d’Ivoire</option>
                                                                        <option value="Djibouti" label="Djibouti">Djibouti</option>
                                                                        <option value="Egypt" label="Egypt">Egypt</option>
                                                                        <option value="Equatorial Guinea" label="Equatorial Guinea">Equatorial Guinea</option>
                                                                        <option value="Eritrea" label="Eritrea">Eritrea</option>
                                                                        <option value="Ethiopia" label="Ethiopia">Ethiopia</option>
                                                                        <option value="Gabon" label="Gabon">Gabon</option>
                                                                        <option value="Gambia" label="Gambia">Gambia</option>
                                                                        <option value="Ghana" label="Ghana">Ghana</option>
                                                                        <option value="Guinea" label="Guinea">Guinea</option>
                                                                        <option value="Guinea-Bissau" label="Guinea-Bissau">Guinea-Bissau</option>
                                                                        <option value="Kenya" label="Kenya">Kenya</option>
                                                                        <option value="Lesotho" label="Lesotho">Lesotho</option>
                                                                        <option value="Liberia" label="Liberia">Liberia</option>
                                                                        <option value="Libya" label="Libya">Libya</option>
                                                                        <option value="Madagascar" label="Madagascar">Madagascar</option>
                                                                        <option value="Malawi" label="Malawi">Malawi</option>
                                                                        <option value="Mali" label="Mali">Mali</option>
                                                                        <option value="Mauritania" label="Mauritania">Mauritania</option>
                                                                        <option value="Mauritius" label="Mauritius">Mauritius</option>
                                                                        <option value="Mayotte" label="Mayotte">Mayotte</option>
                                                                        <option value="Morocco" label="Morocco">Morocco</option>
                                                                        <option value="Mozambique" label="Mozambique">Mozambique</option>
                                                                        <option value="Namibia" label="Namibia">Namibia</option>
                                                                        <option value="Niger" label="Niger">Niger</option>
                                                                        <option value="Nigeria" label="Nigeria">Nigeria</option>
                                                                        <option value="Rwanda" label="Rwanda">Rwanda</option>
                                                                        <option value="Réunion" label="Réunion">Réunion</option>
                                                                        <option value="Saint Helena" label="Saint Helena">Saint Helena</option>
                                                                        <option value="Senegal" label="Senegal">Senegal</option>
                                                                        <option value="Seychelles" label="Seychelles">Seychelles</option>
                                                                        <option value="Sierra Leone" label="Sierra Leone">Sierra Leone</option>
                                                                        <option value="Somalia" label="Somalia">Somalia</option>
                                                                        <option value="South Africa" label="South Africa">South Africa</option>
                                                                        <option value="Sudan" label="Sudan">Sudan</option>
                                                                        <option value="Swaziland" label="Swaziland">Swaziland</option>
                                                                        <option value="São Tomé and Príncipe" label="São Tomé and Príncipe">São Tomé and Príncipe</option>
                                                                        <option value="Tanzania" label="Tanzania">Tanzania</option>
                                                                        <option value="Togo" label="Togo">Togo</option>
                                                                        <option value="Tunisia" label="Tunisia">Tunisia</option>
                                                                        <option value="Uganda" label="Uganda">Uganda</option>
                                                                        <option value="Western Sahara" label="Western Sahara">Western Sahara</option>
                                                                        <option value="Zambia" label="Zambia">Zambia</option>
                                                                        <option value="Zimbabwe" label="Zimbabwe">Zimbabwe</option>
                                                                    </optgroup>
                                                                    <optgroup id="country-optgroup-Americas" label="Americas">
                                                                        <option value="Anguilla" label="Anguilla">Anguilla</option>
                                                                        <option value="Antigua and Barbuda" label="Antigua and Barbuda">Antigua and Barbuda</option>
                                                                        <option value="Argentina" label="Argentina">Argentina</option>
                                                                        <option value="Aruba" label="Aruba">Aruba</option>
                                                                        <option value="Bahamas" label="Bahamas">Bahamas</option>
                                                                        <option value="Barbados" label="Barbados">Barbados</option>             <option value="Austria" label="Austria">Austria</option>
                                                                        <option value="Belarus" label="Belarus">Belarus</option>
                                                                        <option value="Belgium" label="Belgium">Belgium</option>
                                                                        <option value="Bosnia and Herzegovina" label="Bosnia and Herzegovina">Bosnia and Herzegovina</option>
                                                                        <option value="Bulgaria" label="Bulgaria">Bulgaria</option>
                                                                        <option value="Croatia" label="Croatia">Croatia</option>
                                                                        <option value="Cyprus" label="Cyprus">Cyprus</option>
                                                                        <option value="Tuvalu" label="Tuvalu">Tuvalu</option>
                                                                        <option value="U.S. Minor Outlying Islands" label="U.S. Minor Outlying Islands">U.S. Minor Outlying Islands</option>
                                                                        <option value="Vanuatu" label="Vanuatu">Vanuatu</option>
                                                                        <option value="Wallis and Futuna" label="Wallis and Futuna">Wallis and Futuna</option>
                                                                    </optgroup>
                                                                </select>
                                                            </ul></div>
                                                        </div>

                                                        <div class="row">
                                                            <div class="col-md-3 col-md-offset-0"><p>BSN<br/>Fiscal number //  رقم الخدمة المدنية   <br/></div>
                                                                    <div class="col-md-6 col-md-offset-0"><ul class=" style-5 clearfix"><li>
                                                                    <input type="text" name="bsn" id="bsn" class="textbox" required /><br />
                                                                    </li></ul></div>
                                                        </div>

                                  <div class="row">
                                                            <div class="col-md-3 col-md-offset-0"><p>Aanmelden voor locatie<br/> //  Registration for location<br/>//رقم الخدمة المدنية <br/></div>
                                                                    <div class="col-md-6 col-md-offset-0"><ul class=" style-5 clearfix"><li>

                                        <select name="locatie" id="locatie">
                                          <option value="0" label="Select a location … " selected="selected">Select a location … </option>
                                          <option value="Breda">Breda</option>
                                          <option value="Rotterdam">Rotterdam</option>
                                          <option value="Hellevoetsluis">Hellevoetsluis</option><br />
                                          <option value="Leiden">Leiden</option><br />
                                      </select>
                                                                    </li></ul></div>
                                                        </div>


                                                        <div class="row">
                                                            <div class="col-md-3 col-md-offset-0"><p>Geboortedatum<br/>Date of birth // تاريخ الميلاد<br/></div>
                                                            <div class="col-md-6 col-md-offset-0"><ul class=" style-5 clearfix"><li>
                                                                    <input id="date" name="date" placeholder="MM/DD/YYYY" type="text" required/><br />
                                                            </li></ul></div>
                                                        </div>

                                                        <div class="row">
                                                            <div class="col-md-3 col-md-offset-0"><p>Datum van aankomst in Nederland<br/>Date of arrival in the Netherlands //  تاريخ الوصول إلى هولندا<br/></div>
                                                            <div class="col-md-6 col-md-offset-0"><ul class=" style-5 clearfix"><li>
                                                                    <input id="aankomst" name="aankomst" placeholder="MM/DD/YYYY" type="text" required/><br />
                                                            </li></ul></div>
                                                        </div>

                                                        <div class="row">
                                                            <div class="col-md-3 col-md-offset-0"><p>Woonadres<br/>Adress // العنوان<br/></div>
                                                            <div class="col-md-6 col-md-offset-0"><ul class=" style-5 clearfix"><li>
                                                                    <input id="woonadres" name="woonadres" type="text" required/><br />
                                                            </li></ul></div>
                                                        </div>

                                                        <div class="row">
                                                            <div class="col-md-3 col-md-offset-0"><p>Postcode<br/>Postal code // الرمز<br/></div>
                                                            <div class="col-md-6 col-md-offset-0"><ul class=" style-5 clearfix"><li>
                                                                    <input id="postcode" name="postcode" type="text" required/><br />
                                                            </li></ul></div>
                                                        </div>

                                                        <div class="row">
                                                            <div class="col-md-3 col-md-offset-0"><p>Woonplaats<br/>Place // مكان الإقامة<br/></div>
                                                            <div class="col-md-6 col-md-offset-0"><ul class=" style-5 clearfix"><li>
                                                                    <input id="woonplaats" name="woonplaats" type="text" required/><br />
                                                            </li></ul></div>
                                                        </div>

                                                        <div class="row">
                                                            <div class="col-md-3 col-md-offset-0"><p>Telefoonnummer<br/>Telephone //الهاتف<br/></div>
                                                            <div class="col-md-6 col-md-offset-0"><ul class=" style-5 clearfix"><li>
                                                                    <input id="telefoon" name="telefoon" type="text" maxlength="10" required/><br />
                                                            </li></ul></div>
                                                        </div>

                                                        <div class="row">
                                                            <div class="col-md-12 col-md-offset-0">&nbsp;
                                                            <div class="col-md-12 col-md-offset-0"><ul class=" style-5 clearfix"><li>

                                                                </li></ul></div>
                                                        </div>
                                                    </div>

                                                        <div class="row">
                                                            <div class="col-md-3 col-md-offset-0">&nbsp;
                                                            <div class="col-md-6 col-md-offset-0">
                                                                    <input name="submit" class="btn" type="submit" value="Verstuur" /><br class="clear" />
                                                                    <br />
                                                                </div>
                                                        </div>
                                                    </div>


                                                                  </form>




<?php include_once ('../inc/footer.inc.php'); ?>

1 个答案:

答案 0 :(得分:0)

我不知道为什么会出现标头问题的确切原因,但是您可以通过使用JavaScript的window.location代替PHP的标头重定向来解决此问题。

替换

header('Location: index.php');

echo("<script>window.location='index.php';</script>");

并替换

header('Location: http://www.website.com/aanmelden/index.php');

使用

echo("<script>window.location='http://www.website.com/aanmelden/index.php';</script>");

希望它有所帮助!