我遇到一些问题,当我提交带有完整数据的表单时,正在显示验证。但是,当我提交的表单不完整时,验证不会显示。
在添加调整大小代码之前,用于验证的代码成功,但是在验证失败的代码之后,未显示发送。
我想添加标题显示弹出窗口,但是对于JavaScript无法更改标题并使用其他代码。你知道吗?
我的代码出了什么问题?
我正在使用带有引导程序的框架codeigniter
这是我的代码控制器
<?php
public function submittrans(){
$input_name = $_POST['input_name'];
$input_email = $_POST['input_email'];
$input_code = $_POST['input_code'];
$config['file_name'] = $input_code;
$config['overwrite'] = TRUE;
$config['upload_path'] = './pict/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = 15000000;
$this->load->library('upload', $sendemail);
$this->upload->initialize($sendemail);
if(!empty($_FILES['archive']['name'])){
if ($input_pict = $this->upload->do_upload('archive')) {
$data = $upload_data = $this->upload->data();
//Compress Image
$imliber['image_library'] = 'gd2';
$imliber['source_image'] = './pict/'.$data['file_name'];
$imliber['create_thumb'] = FALSE;
$imliber['maintain_ratio'] = TRUE;
$imliber['master_dim'] = 'height';
$imliber['quality'] = '50%';
$imliber['width'] = 1024;
$imliber['height'] = 800;
$imliber['new_image'] = './pict/trans'.$data['file_name'];
$this->load->library('image_lib', $imliber);
if (!$this->image_lib->resize()) {
show_error($this->image_lib->display_errors());
}
}
if( $input_name !='' && $input_email !='' && $input_code !='' && $input_pict !=''){
$this->load->library('email');
$sendemail['protocol'] = 'smtp';
$sendemail['smtp_host'] = 'x.x.x.x';
$sendemail['smtp_port'] = 'xx';
$sendemail['charset'] = 'xxx-xx-xx';
$sendemail['mailtype'] = 'html';
$sendemail['wordwrap'] = TRUE;
$this->email->initialize($sendemail);
$mail_message = "
Your Info: <br/>
Name: $input_nama <br/>
Email: $input_email <br/>
Code: $input_kode_transaksi <br/>
";
$this->email->from('xx@xx.xx', 'Support xxxxxxx');
$this->email->to('xx@xx.xx');
$attched_file= "pict/trans".$data['file_name'];
$this->email->attach($attched_file);
$this->email->subject('Confirm');
$this->email->message($mail_message);
$this->email->send();
echo "<script>alert('Thanks, success input the form!');</script>";
echo "<script>window.history.go(-2);</script>";
}
}else{
echo "<script>alert('Make sure the form complete before submit!');window.history.go(-1);</script>";
}
}
?>
答案 0 :(得分:1)
请使用我的代码,
if(!empty($_FILES['archive']['name'])){
if ($input_pict = $this->upload->do_upload('archive')) {
$data = $upload_data = $this->upload->data();
//Compress Image
$imliber['image_library'] = 'gd2';
$imliber['source_image'] = './pict/'.$data['file_name'];
$imliber['create_thumb'] = FALSE;
$imliber['maintain_ratio'] = TRUE;
$imliber['master_dim'] = 'height';
$imliber['quality'] = '50%';
$imliber['width'] = 1024;
$imliber['height'] = 800;
$imliber['new_image'] = './pict/trans'.$data['file_name'];
$this->load->library('image_lib', $imliber);
if (!$this->image_lib->resize()) {
show_error($this->image_lib->display_errors());
}
}
}
if( $input_name !='' && $input_email !='' && $input_code !='' && $input_pict !=''){
$this->load->library('email');
$sendemail['protocol'] = 'smtp';
$sendemail['smtp_host'] = 'x.x.x.x';
$sendemail['smtp_port'] = 'xx';
$sendemail['charset'] = 'xxx-xx-xx';
$sendemail['mailtype'] = 'html';
$sendemail['wordwrap'] = TRUE;
$this->email->initialize($sendemail);
$mail_message = "
Your Info: <br/>
Name: $input_nama <br/>
Email: $input_email <br/>
Code: $input_kode_transaksi <br/>
";
$this->email->from('xx@xx.xx', 'Support xxxxxxx');
$this->email->to('xx@xx.xx');
$attched_file= "pict/trans".$data['file_name'];
$this->email->attach($attched_file);
$this->email->subject('Confirm');
$this->email->message($mail_message);
$this->email->send();
echo "<script>alert('Thanks, success input the form!');</script>";
echo "<script>window.history.go(-2);</script>";
}
}
您在拉制符号“}”中的错误以关闭代码调整input_pict的大小