我是codeigniter的新手。我有一个联系表单,包含流,姓名,电子邮件,联系人字段。但我有一个问题,表格数据不会发送到管理员电子邮件。当我尝试在联系表单上提交数据时,页面源会发出警报,但我已经提供了其他警报数据。 我试过以下代码,
$('#interiorid').submit(function (e) {
e.preventDefault();
var interiorstream = $('#interiorstream').val();
var interiorname = $('#interiorname').val();
var interiormobile = $('#interiormobile').val();
var interioremail = $('#interioremail').val();
var mobileVarify = /[0-9]/.test(interiormobile);
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var dataString = 'interiorstream =' + interiorstream + '&interiorname =' + interiorname + '&interiormobile =' + interiormobile + '&interioremail =' + interioremail;
alert(interiorstream);
if (interiorstream == "0") {
alert('Please select Stream');
}
else {
if (interiorname.length > 2) {
if (mobileVarify == true && interiormobile.length == 10) {
if (regex.test(interioremail) == true) {
$.ajax({
url: 'interior_email',
type: 'post',
data: dataString,
success: function (msg, status) {
alert(status);
alert(msg);
$("#interiorid")[0].reset();
window.location.href = "/contact/thank-you";
}
});
}
else {
alert('Invalid Email');
}
}
else {
alert('Invalid Number');
}
}
else {
alert('Please enter name');
}
}
});

<!--- View ---->
<form id="interiorid">
<div class="form-div">
<select value="" id="interiorstream" >
<option value="0">Select a Stream</option>
<option value="Interior Designing">Interior Designing</option>
<option value="Fashion Designing">Fashion Designing</option>
</select>
</div>
<div class="form-div">
<input type="text" placeholder="Name" id="interiorname">
</div>
<div class="form-div">
<input type="text" placeholder="Phone" id="interiormobile">
</div>
<div class="form-div">
<input type="text" placeholder="Email" id="interioremail">
</div>
<div class="form-div">
<input type="submit" value="submit">
</div>
</form>
<!----Controller ---->
<?php
class Home extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->helper('url');
$this->load->library('email');
$this->load->helper(array('url'));
}
function index() {
$this->load->view('templates/header');
$this->load->view('home');
$this->load->view('templates/footer');
$this->load->helper('form');
$this->load->view('interior/interior-intro');
}
function interior_email()
{
if (!isset($_POST['e-mail'])){
//redirect if no parameter e-mail
redirect(base_url());
}else{
$interiorstream = $this->input->post('interiorstream');
$interiorname = $this->input->post('interiorname');
$interiorphone = $this->input->post('interiorphone');
$interioremail = $this->input->post('interioremail');
$message = 'Hello Admin, This mail received from Interior design page contact form.<br/><br/>
Stream:' . $interiorstream . '<br/><br/>
Name :' . $interiorname . '<br/><br/>
Contact :' . $interiorphone . '<br><br>
Email :' . $interioremail;
$headers1 = "MIME-Version: 1.0\r\n";
$headers1 .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers1 .= "To:";
$headers1 .= "example.com <info@example.com>";
$headers1 .= "\r\n";
$headers1 .= 'From: INIFD : info@example.com' . "\r\n";
$headers1 .= "\r\n";
$subject = "Enquiry From example.com Web";
$email = 'admin@example.com';
if (mail($email, $subject, $message, $headers1)) {
echo 'mail has been sent';
} else {
echo 'mail sending failed';
}
}
}
}
?>
&#13;
像这样错误的弹出窗口:
所以请帮助我。