我的问题是,当我点击提交按钮,它确实提交的形式,我没有收到任何问题的网站上或控制台内.唯一的变化,我对我的代码是编辑的php部分,这是创建表,我不知道它触发的问题.但不知何故,我没有收到任何邮件后,我点击提交按钮。你们能帮我解决这个问题吗?
HTML CODES
<div class="container contact-form-container text-center">
<div class="row">
<form method="post" action="php/process.php">
<div class="col-12">
<p class="contact-form-title">CONTACT US</p>
</div>
<div class="col-12 contact-form-col">
<div class="contact-form-div">
<label class="contact-form-label" for="first-name">First Name <span class="contact-form-span">*</span></label>
<input class="contact-form-input" type="text" id="first-name" name="first-name" required>
</div>
<div class="contact-form-div">
<label class="contact-form-label" for="surname">Surname <span class="contact-form-span">*</span></label>
<input class="contact-form-input" type="text" id="surname" name="surname" required>
</div>
</div>
<div class="col-12 contact-form-col">
<div class="contact-form-div">
<label class="contact-form-label" for="email">Email <span class="contact-form-span">*</span></label>
<input class="contact-form-input" type="text" id="email" name="email" required>
</div>
<div class="contact-form-div">
<label class="contact-form-label" for="phone-number">Phone Number <span class="contact-form-span">*</span></label>
<input class="contact-form-input" id="tel" type="text" id="phone-number" name="phone-number" placeholder="(+1) 123 456 789" required>
</div>
</div>
<div class="col-12 contact-form-col">
<div class="contact-form-div">
<label class="contact-form-label" for="country">Country <span class="contact-form-span">*</span></label>
<input class="contact-form-input" type="text" id="country" name="country" value="United States" required>
</div>
<div class="contact-form-div">
<label class="contact-form-label" for="state">State / Province <span class="contact-form-span">*</span></label>
<select class="contact-form-select" name="state" required>
<option value="" disabled selected>Select State</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District Of Columbia</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
</select>
</div>
</div>
<div class="col-12 contact-form-col">
<div class="contact-form-div">
<label class="contact-form-label" for="company-name">Company Name</label>
<input class="contact-form-input" type="text" id="company-name" name="company-name">
</div>
<div class="contact-form-div">
<label class="contact-form-label" for="how-did-you-hear-about-us">How Did You Hear About Us?</label>
<input class="contact-form-input" type="text" id="how-did-you-hear-about-us" name="how-did-you-hear-about-us">
</div>
</div>
<div class="col-12 contact-form-col">
<div class="contact-form-div">
<label class="contact-form-label" for="tell-us-about-your-project">Tell Us About Your Project?</label>
<textarea class="contact-form-textarea" id="tell-us-about-your-project" name="tell-us-about-your-project" rows="5" cols="90%"></textarea>
</div>
</div>
<div class="submit-button-div">
<div class="col-6 contact-form-col">
<div class="contact-form-div">
<input class="contact-form-submit-button" type="submit" value="Submit">
</div>
</div>
</div>
</form>
<?php
if (isset($_GET['email']) && isset($_GET['status'])) {
if ($_GET['email'] == 'send') {
if ($_GET['status'] == 'ok') {
echo '<script>';
echo 'if (!localStorage.getItem("refreshed")) {';
echo ' localStorage.setItem("refreshed", "true");';
echo ' alert("Email send success");';
echo ' window.location.reload();';
echo '}';
echo '</script>';
} elseif ($_GET['status'] == 'no') {
echo '<script>alert("Email send error");</script>';
}
}
}
?>
</div>
</div>
<script>
var inputEl = document.getElementById('tel');
var goodKey = '0123456789+ ';
var checkInputTel = function(e) {
var key = (typeof e.which == "number") ? e.which : e.keyCode;
var start = this.selectionStart,
end = this.selectionEnd;
var filtered = this.value.split('').filter(filterInput);
this.value = filtered.join("");
/* Prevents moving the pointer for a bad character */
var move = (filterInput(String.fromCharCode(key)) || (key == 0 || key == 8)) ? 0 : 1;
this.setSelectionRange(start - move, end - move);
}
var filterInput = function(val) {
return (goodKey.indexOf(val) > -1);
}
inputEl.addEventListener('input', checkInputTel);
</script>
<script>
var uploadField = document.getElementById("file-size");
uploadField.onchange = function() {
if(this.files[0].size > 50000000){
alert("File is too big!");
this.value = "";
};
};
</script>
PHP CODES
enter code here<?php
require 'vendor/autoload.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
$mail = new PHPMailer(true);
if (isset($_POST['email'])) {
try {
$html = "<table>";
$html .= '<tbody>';
$html .= '<tr>';
$html .= '<th>Full Name: </th>';
$html .= '<td>' . $_POST['first-name'] . ' ' . $_POST['surname'] . '</td>';
$html .= '</tr>';
$html .= '<tr>';
$html .= '<th>Email: </th>';
$html .= '<td>' . $_POST['email'] . '</td>';
$html .= '</tr>';
$html .= '<tr>';
$html .= '<th>Phone Number: </th>';
$html .= '<td>' . $_POST['phone-number'] . '</td>';
$html .= '</tr>';
$html .= '<tr>';
$html .= '<th>Country: </th>';
$html .= '<td>' . $_POST['country'] . '</td>';
$html .= '</tr>';
$html .= '<tr>';
$html .= '<th>State / Province: </th>';
$html .= '<td>' . $_POST['state'] . '</td>';
$html .= '</tr>';
$html .= '<tr>';
$html .= '<th>Company Name: </th>';
$html .= '<td>' . $_POST['company-name'] . '</td>';
$html .= '</tr>';
$html .= '<tr>';
$html .= '<th>How Did You Hear About Us?: </th>';
$html .= '<td>' . $_POST['how-did-you-hear-about-us'] . '</td>';
$html .= '</tr>';
$html .= '<tr>';
$html .= '<th>Tell Us About Your Project: </th>';
$html .= '<td>' . nl2br($_POST['tell-us-about-your-project']) . '</td>';
$html .= '</tr>';
// Add code for handling file attachment here
$html .= '</tbody>';
$html .= "</table>";
$mail->SMTPDebug = SMTP::DEBUG_SERVER | SMTP::DEBUG_CLIENT;
$mail->isSMTP();
$mail->SMTPDebug = 3;
$mail->Host = 'localhost';
$mail->Port = 25;
$mail->SMTPAuth = false;
$mail->SMTPSecure = false;
$mail->SMTPAutoTLS = false;
$mail->setFrom('[email protected]', 'no-name');
$mail->addAddress('[email protected]');
$mail->isHTML(true);
$mail->addReplyTo($_POST['email'], $_POST['name']);
$mail->Subject = $_POST['subject'];
$mail->Body = $html;
$response = $mail->send();
if ($response) {
header('Location: https://www.demo.com/');
} else {
echo $response;
}
} catch (Exception $e) {
echo $mail->ErrorInfo;
}
}
?>
2条答案
按热度按时间uyto3xhc1#
我找到解决办法了
代码之前
新代码
我认为谷歌是因为标题而阻止它的。目前它的工作。
vxqlmq5t2#
有两件事在脑海中。
首先,您需要检查php.ini中的display_errors和error_reporting是否已设置,以便在发生错误时可以看到错误。
其次,最好在真实的主机或服务器上测试你的代码,或者至少使用Gmail免费的SMTP服务器,这样你就可以诊断出问题是关于代码或服务器的。