我正在使用Codeigniter编写php代码。我的脚本在我的localhost中工作正常但是当我移动到服务器时,脚本的某些部分停止工作。它是一种简单的注册方式。
当我在firefox中运行脚本时,它显示了我:
连接已重置 页面加载时重置了与服务器的连接... ..... .......
当我按下提交按钮并发布表单
时会显示此错误<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Register extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->model('register_model');
}
public function index()
{
//echo 'user_full_name:' .$this->input->post('user_full_name', TRUE);
$data['page_title'] = 'Couple Dating Website - Registration';
$this->form_validation->set_rules('user_email', 'Email', 'required');
if ($this->form_validation->run() == FALSE)
{
//echo "<br>Validation Not Success";
$this->load->view('register_view',$data);
}
else //If validation success
{
$this->load->view('register_view',$data);
}
}
public function success()
{
$data['page_title'] = 'Couple Dating Website - Registration Success';
$this->load->view('register_success_view',$data);
}
public function add() {
$data['page_title'] = 'Couple Dating Website - Registration';
//Form Validation
$this->form_validation->set_rules('email', 'Email', 'required|is_unique[members.email]',array('is_unique' => '%s is already registered with us.'));
$this->form_validation->set_rules('pass_confirmation', 'Password', 'required');
$this->form_validation->set_rules('pass', 'Confirm Password', 'required');
$this->form_validation->set_rules('first_name_p1', 'Partner 1 Name', 'required');
$this->form_validation->set_rules('first_name_p2', 'Partner 2 Name', 'required');
$this->form_validation->set_rules('dob_mm', 'Month of Partner 1 Birthday', 'required');
$this->form_validation->set_rules('dob_dd', 'Day of Partner 1 Birthday', 'required');
$this->form_validation->set_rules('dob_yy', 'Year of Partner 1 Birthday', 'required');
$this->form_validation->set_rules('dob_mm2', 'Month of Partner 2 Birthday', 'required');
$this->form_validation->set_rules('dob_dd2', 'Day of Partner 2 Birthday', 'required');
$this->form_validation->set_rules('dob_yy2', 'Year of Partner 2 Birthday', 'required');
$this->form_validation->set_rules('relationship_status', 'Relationship Status', 'required');
$this->form_validation->set_rules('we_are', 'We Are', 'required');
$this->form_validation->set_error_delimiters('<div class="alert-danger">', '</div>');
if ($this->form_validation->run() == FALSE)
{
//echo "<br>Validation Not Success";
$this->load->view('register_view',$data);
}
else //If validation success
{
//Get Current Date and Time
//$this->load->helper('functions');
//echo get_current_datetime();
//$date_added = get_current_datetime();
$date_added = '2017-01-01 05:50:00';
//P1 DOB
$dob_p1 = $this->input->post('dob_yy', TRUE) . '-' . $this->input->post('dob_mm', TRUE) . '-' . $this->input->post('dob_dd', TRUE);
//P2 DOB
$dob_p2 = $this->input->post('dob_yy2', TRUE) . '-' . $this->input->post('dob_mm2', TRUE) . '-' . $this->input->post('dob_dd2', TRUE);
//echo "<br>Validation Success";
$input_data = array(
'email' => $this->input->post('email', TRUE),
'password' => md5($this->input->post('pass_confirmation', TRUE)),
'first_name_p1' => $this->input->post('first_name_p1', TRUE),
'first_name_p2' => $this->input->post('first_name_p2', TRUE),
'dob_p1' => $dob_p1,
'dob_p2' => $dob_p2,
'relationship_status' => $this->input->post('relationship_status', TRUE),
'we_are' => $this->input->post('we_are', TRUE),
'location' => $this->input->post('location', TRUE),
'status' => '1',
'date_added' => $date_added,
'date_updated' => $date_added
);
$res = $this->register_model->insert($input_data);
if($res)
{
//Send Welcome email
$message = 'Dear '.$this->input->post('first_name_p1', TRUE).',';
$message .= '<br><br>Welcome to BeeOurFriends.com ! ';
$message .= "<br><br>Thanks";
$message .= "<br>BeeOurFriends.com";
$this->send_mail($this->input->post('email', TRUE),$message);
redirect('register/success');
}
//
}
}
public function send_mail($to_email,$message) {
$from_email = "donotreply@beeourfriends.com";
$to_email = $this->input->post('email');
//Load email library
$this->load->library('email');
$this->email->set_mailtype("html");
$this->email->from($from_email, 'BeeOurFriends.com');
$this->email->to($to_email);
$this->email->subject('Forget Password');
$this->email->message($message);
//Send mail
if($this->email->send())
$this->session->set_flashdata("email_sent","Email sent successfully.");
else
$this->session->set_flashdata("email_sent","Error in sending Email.");
//$this->load->view('email_form');
}
}
?>
<?php
//session_start();
Class Register_model extends CI_Model
{
function __construct() {
parent::__construct();
}
public function insert($data) {
//echo "<br> Insert";
if ($this->db->insert("members", $data)) {
return true;
}
}
}
?>
<?php $this->load->view('header'); ?>
<div class="profile_banner">
<div class="container">
<h3>Register</h3>
</div>
</div>
<div class='profiles'>
<div class="container">
<?php echo form_open(base_url() .'register', array('id' => 'registration-form-main','method' => 'post')); ?>
<div class="register">
<div id="alert_success" class="alert alert-danger alert-dismissible fade in" role="alert" style="display:<?php if(validation_errors() != "") echo 'block'; else echo 'none'?>">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span> </button>
<?php echo validation_errors(); ?> </div>
<div class="register-top-grid">
<h3>ACCOUT INFORMATION</h3>
<div>
<span>Email<label>*</label></span>
<input type="text" name="email" id="email" data-validation="email" value="<?php echo set_value('user_email') . set_value('email'); ?>">
</div>
<div>
<span>Password<label>*</label></span>
<input type="password" name="pass_confirmation" id="pass_confirmation" data-validation="strength" data-validation-strength="2" data-validation-error-msg="Pasword has to be an alphanumeric and a special char">
<?php //echo form_error('pass_confirmation'); ?>
</div>
<div>
<span>Confirm Password<label>*</label></span>
<input type="password" name="pass" id="pass" data-validation="confirmation">
<?php //echo form_error('pass'); ?>
</div>
</div>
<div class="clearfix"> </div>
<div class="register-bottom-grid">
<h3>PERSONAL INFORMATION</h3>
<div>
<span>Partner 1 Name<label>*</label></span>
<input type="text" name="first_name_p1" id="first_name_p1" data-validation="length alphanumeric" data-validation-length="2-25" value="<?php echo set_value('user_full_name').set_value('first_name_p1'); ?>">
</div>
<div>
<span>Partner 2 Name<label>*</label></span>
<input type="text" name="first_name_p2" id="first_name_p2" data-validation="length alphanumeric" data-validation-length="2-25" value="<?php echo set_value('user_full_name2').set_value('first_name_p2'); ?>">
</div>
<div>
<span>Partner 1 Birthday<label>*</label></span>
<select id="dob_mm" name="dob_mm" class="select-box" style="width:100px;" data-validation="required" data-validation-error-msg=" ">
<option value="">MM</option>
<?php for($i=1;$i<=12;$i++) { ?>
<option value="<?php echo sprintf("%02d", $i); ?>" <?php if(set_value('dob_mm')== sprintf("%02d", $i)) echo 'selected';?> ><?php echo sprintf("%02d", $i); ?></option>
<?php } ?>
</select>
<select id="dob_dd" name="dob_dd" class="select-box" style="width:100px;" data-validation="required" data-validation-error-msg=" " >
<option value="">DD</option>
<?php for($i=1;$i<=31;$i++) { ?>
<option value="<?php echo sprintf("%02d", $i); ?>" <?php if(set_value('dob_dd')== sprintf("%02d", $i)) echo 'selected';?> ><?php echo sprintf("%02d", $i); ?></option>
<?php } ?>
</select>
<select id="dob_yy" name="dob_yy" class="select-box" style="width:100px;" data-validation="required" data-validation-error-msg=" " >
<option value="">YYYY</option>
<?php for($i=1910;$i<=2020;$i++) { ?>
<option value="<?php echo $i; ?>" <?php if(set_value('dob_yy')== sprintf("%02d", $i)) echo 'selected';?> ><?php echo $i; ?></option>
<?php } ?>
</select>
</div>
<div style="float:left">
<span>Partner 2 Birthday<label>*</label></span>
<select id="dob_mm2" name="dob_mm2" class="select-box" style="width:100px;" data-validation="required" data-validation-error-msg=" ">
<option value="">MM</option>
<?php for($i=1;$i<=12;$i++) { ?>
<option value="<?php echo sprintf("%02d", $i); ?>" <?php if(set_value('dob_mm2')== sprintf("%02d", $i)) echo 'selected';?> ><?php echo sprintf("%02d", $i); ?></option>
<?php } ?>
</select>
<select id="dob_dd2" name="dob_dd2" class="select-box" style="width:100px;" data-validation="required" data-validation-error-msg=" " >
<option value="">DD</option>
<?php for($i=1;$i<=31;$i++) { ?>
<option value="<?php echo sprintf("%02d", $i); ?>" <?php if(set_value('dob_dd2')== sprintf("%02d", $i)) echo 'selected';?> ><?php echo sprintf("%02d", $i); ?></option>
<?php } ?>
</select>
<select id="dob_yy2" name="dob_yy2" class="select-box" style="width:100px;" data-validation="required" data-validation-error-msg=" " >
<option value="">YYYY</option>
<?php for($i=1910;$i<=2020;$i++) { ?>
<option value="<?php echo $i; ?>" <?php if(set_value('dob_yy2')== sprintf("%02d", $i)) echo 'selected';?> ><?php echo $i; ?></option>
<?php } ?>
</select>
</div>
<div>
<span>Relationship Status<label>*</label></span>
<select id="relationship_status" name="relationship_status" class="select-box" data-validation="required">
<option value="">-----</option>
<option value="In Relationship" <?php if(set_value('relationship_status')== "In Relationship") echo 'selected';?> >In Relationship</option>
<option value="Engaged" <?php if(set_value('relationship_status')== "Engaged") echo 'selected';?> >Engaged</option>
<option value="Married" <?php if(set_value('relationship_status')== "Married") echo 'selected';?> >Married</option>
</select>
</div>
<div>
<span>We are a<label>*</label></span>
<select id="we_are" name="we_are" class="select-box" data-validation="required">
<option value="">-----</option>
<option value="Man and Woman" <?php if(set_value('we_are')== "Man and Woman") echo 'selected';?> >Man and Woman</option>
<option value="Man and Man" <?php if(set_value('we_are')== "Man and Man") echo 'selected';?> >Man and Man</option>
<option value="Woman and Woman" <?php if(set_value('we_are')== "Woman and Woman") echo 'selected';?> >Woman and Woman</option>
</select>
</div>
<div>
<span>Location<label>*</label></span>
<input type="text" name="location" id="location" data-validation="required" placeholder="City, State or Zipcode" value="">
</div>
<div class="clearfix"> </div>
</div>
<div class="clearfix"> </div>
<a class="news-letter" href="#">
<label class="checkbox"><input type="checkbox" name="checkbox" data-validation="required"><i> </i>I Agree terms of use </label>
</a>
<div class="register-but">
<input type="submit" value="Submit" class="btn1 btn-1 btn1-1b">
<input type="reset" value="Reset" class="btn1">
<div class="clearfix"> </div>
</div>
</div>
<?php echo form_close(); ?>
</div>
</div>
<?php $this->load->view('footer'); ?>