单击页面http://localhost:8080/Jan182017/users/add_user/上的提交按钮,它将被重定向到http://localhost/Jan182017/users/add_user/#menu1,并显示 - 无法访问此站点localhost拒绝连接错误消息。添加的最佳方式是什么:8080到提交的URL,我的代码如下,
Controller:users.php
function add_user(){
global $SITE;
global $USER;
$data = array();
if($USER->permissions[0] == 'all' || $this->uri->segment(3)==$USER->userdetid) {
$data['team_details']=$this->mod_users->get_team_details();
$data['error_message'] = '';
$data['id'] = $this->uri->segment(3);
$data['action'] = 'add';
$data['heading'] = 'Add';
$data['row'] = new stdClass();
$data['row'] = $this->admin_init_elements->set_post_vals($this->input->post());
$data['msg_class'] = 'sukses';
$post_action = $this->input->post('action');
$data['proofs'] = $this->mod_common->get_cat_array2('pr_proofs',NULL,NULL,'');
if($post_action=='add' || $post_action =='update' ){
$post_array = $this->input->post();
$action = ($post_action == 'add')?'inserted':'updated';
$data['error_message'] = $this->mod_users->validate_user_form($this->input->post('id'));
if($data['error_message']=='valid'){
if($_FILES['profileimage']['name']!=''){
$upload_val = $this->admin_init_elements->do_upload_img('profileimage',$SITE->user_profile_image_src);
if($upload_val!='' && !is_array($upload_val)){
$post_array['profileimage'] = $upload_val;
if($action=='updated' && $post_array['originalprofileimage']!='' && $post_array['originalprofileimage']!= DEFAULT_IMG_NAME){
$path = FCPATH.$SITE->user_profile_image_src;
unlink_file($path.FOLDER_ORIGINAL.$post_array['originalprofileimage']);
unlink_file($path.FOLDER_LARGE.$post_array['originalprofileimage']);
unlink_file($path.FOLDER_SMALL.$post_array['originalprofileimage']);
unlink_file($path.FOLDER_THUMB.$post_array['originalprofileimage']);
}
}else{
$post_array['profileimage'] = DEFAULT_IMG_NAME;
}
}
$data['error_message'] = $this->mod_users->add_edit_user($post_array,$action);
if($data['error_message'] = 'Record '.$action.' successfully'){
$data['row'] = new stdClass();
$data['row']->status = 1;
}
}else{
$data['msg_class'] = '';
}
}
if($data['id']>0){
$data['action'] = 'update';
$data['heading'] = 'Edit';
$data['row'] = $this->mod_common->get_details($data['id'],'users_details'); ;
$data['status'] = $data['row']->status;
$data['row']->userdetail = $this->mod_common->get_details($data['row']->userid,'users');
$ucomp = $this->mod_common->get_user_comp_by_id($data['row']->userid);
foreach($ucomp as $c)
{
$usercomp[$c['year']][$c['comp_element']] = $c['comp_value'];
}
$data['row']->usercomp = $usercomp;
$uleave = $this->mod_common->get_user_leave_by_id($data['row']->userid);
foreach($uleave as $l)
{
$userleave[$l['leavetype']] = $l['leavecount'];
}
$data['row']->userleave = $userleave;
//print_r($data['row']->usercomp);die();
$data['caddress'] = get_address1($data['row'],'1',$data['id']);
$data['paddress'] = get_address1($data['row'],'6',$data['id']);
get_city_state_country_array($data,array('cityid'=>$data['paddress']->cityid));
get_city_state_country_array1($data,array('cityid'=>$data['caddress']->cityid));
$user_proofs = $this->mod_common->get_cat_array2('pr_user_proofs','userid',$data['row']->userid,'');
foreach($user_proofs as $up)
{
$docproof[$up->documentid]['document_number'] = $up->document_number;
$docproof[$up->documentid]['expiry_date'] = $up->expiry_date;
$docproof[$up->documentid]['doc_file'] = $up->doc_file;
}
$data['docproof'] = $docproof;
$family_profile = $this->mod_common->get_cat_array2('pr_user_family','userid',$data['row']->userid,'');
$data['family_profile'] = $family_profile[0];
$bank_details = $this->mod_common->get_cat_array2('pr_user_bank','userid',$data['row']->userid,'');
$data['bank_details'] = $bank_details[0];
} else
{
get_city_state_country_array($data,array('cityid'=>$data['row']->cityid));
get_city_state_country_array1($data,array('cityid'=>$data['row']->cityid));
}
$data['comp_elem'] = $this->mod_common->get_comp_element_by_func_level($data['row']->userdetail->departmentid,$data['row']->designation_id);
$userlevel = 0;
$comp_struct_elements=$this->mod_common->get_array_frontend_raw('pr_comp_elements','*','');
$data['comp_struct_setting']=$this->mod_common->get_array_frontend('comp_struct','*','');
$comp_cat = array("Standard Elements","Allowances","Deductions from Gross Salary","Variable Salary","Loans and Advances");
foreach($comp_struct_elements as $cse)
{
if($cse->comp_category == 'Standard')
$data['comp_elements2'][0][] = $cse;
else if($cse->comp_category == 'Allowances')
$data['comp_elements2'][1][] = $cse;
else if($cse->comp_category == 'Deductions from Gross')
$data['comp_elements2'][2][] = $cse;
else if($cse->comp_category == 'Variable Salary')
$data['comp_elements2'][3][] = $cse;
else if($cse->comp_category == 'Loans and Advances')
$data['comp_elements2'][4][] = $cse;
else if($cse->comp_category == 'Other Benefits or Perks')
$data['comp_elements2'][5][] = $cse;
else if($cse->comp_category == 'Stocks or Shares')
$data['comp_elements2'][6][] = $cse;
else if($cse->comp_category == 'Direct Pay')
$data['comp_elements2'][7][] = $cse;
}
foreach($data['comp_struct_setting'] as $comp_struct_setting)
{
$data['comp_struct'][] = $comp_struct_setting->optional_element;
}
$data['leaves'] = $this->mod_common->get_leave_types();
$data['departments'] = $this->mod_common->get_cat_array('department',NULL,NULL,'departmentname');
$data['branches'] = $this->mod_common->get_cat_array('office',NULL,NULL,'branchname');
$data['divisions'] = $this->mod_common->get_cat_array('divisions',NULL,NULL,'division_name');
$data['shifts'] = $this->mod_common->get_cat_array2('pr_shifts',NULL,NULL,'');
$data['roles'] = $this->mod_common->get_cat_array('designation','status',"1' AND id > '0",'designation');
$data['uroles'] = $this->mod_common->get_array_frontend('roles');
$data['row']->userlevel = isset($data['row']->userlevel)?$data['row']->userlevel:0;
$data['row']->branchid = isset($data['row']->branchid)?$data['row']->branchid:0;
$data['row']->managerid = $this->mod_common->get_managerids($data['id']);
$data['users'] = get_employees_above_level($data['row']->userlevel,$data['row']->branchid);
$data['last_emp_code'] = $this->mod_users->get_last_emp_code();
$this->data['maincontent'] = $this->load->view('maincontents/add_editUser', $data,true);
$this->load->view('layout', $this->data);
} else {
$data['permission'] = 'Edit Profile of other users';
$this->data['maincontent'] = $this->load->view('maincontents/access_denied', $data,true);
$this->load->view('layout', $this->data);
}
}
查看:add_editUser.php
<?php echo form_open_multipart('users/add_user/'.$id.'#menu1', array('method'=>'post','name'=>'addEditUserForm','id'=>'addEditUserForm'));?>
<div class="tab-content">
<div id="home" class="tab-pane fade in active">
<h3>Personal</h3>
<input type="hidden" name="step" value="1">
<div class="col-md-12">
<div class="col-md-2" style="" class="pull-right">
<div class="control-group col-md-11">
<div class="controls">
<div class="fileupload fileupload-new" data-provides="fileupload">
<div class="fileupload-new thumbnail" style="width: 100px; height: 100px;">
<?php $changeremove = false;
if($row->profileimage!='' && file_exists($SITE->user_profile_image_src.FOLDER_THUMB.$row->profileimage)){
echo img(array('src'=>$SITE->user_profile_image_src.FOLDER_THUMB.$row->profileimage,'width'=>200));
echo form_hidden('originalprofileimage',$row->profileimage);
$changeremove = true;
}else{
echo '<img src="http://www.placehold.it/100x100/EFEFEF/AAAAAA&text=no+image" alt="" />';
}?>
</div>
<div class="fileupload-preview fileupload-exists thumbnail" style="max-width: 100px; max-height: 100px; line-height: 20px;"></div>
<div class="btn-container"> <span class="btn-file"><span class="fileupload-new"><i class="fa fa-upload "></i> Upload Image</span> <span class="fileupload-exists">Change</span>
<?php echo form_upload(array('name'=>'profileimage','id'=>'profileimage','class'=>"default" ));?>
</span> <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a> </div>
</div>
</div>
</div>
</div>
<div class="col-md-10" >
<div class="clearfix"></div>
<div class="row" style="margin-top:5px" >
<div class="col-md-3" >
<div class="control-group col-md-11">
<label >Prefix</label>
<select name="prefix" class="form-control select2">
<option value="Mr." <?=($row->prefix=='Mr.')?"selected='selected'":""?>>Mr.</option>
<option value="Ms." <?=($row->prefix=='Ms.')?"selected='selected'":""?>>Ms.</option>
<option value="Mrs." <?=($row->prefix=='Mrs.')?"selected='selected'":""?>>Mrs.</option>
<option value="Dr." <?=($row->prefix=='Dr.')?"selected='selected'":""?>>Dr.</option>
</select>
</div>
</div>
<div class="col-md-3" >
<div class="control-group col-md-11">
<label>First Name <span class="req_star">*</span></label>
<?php echo form_input(array("name" =>"firstname" ,"id"=>"firstname","class"=>"m-wrap form-control col-md-5 req","value"=>$row->firstname,"required"=>"required"))?>
</div>
</div>
<div class="col-md-3" >
<div class="control-group col-md-11">
<label>Middle Name</label>
<?php echo form_input(array("name" =>"middlename" ,"id"=>"sedang","class"=>"m-wrap form-control col-md-5","value"=>$row->middlename))?>
</div>
</div>
<div class="col-md-3" >
<div class="control-group col-md-11">
<label class="">Last Name <span class="req_star">*</span></label>
<?php echo form_input(array("name" =>"lastname" ,"id"=>"lastname","class"=>"m-wrap form-control col-md-5 req","value"=>$row->lastname,"required"=>"required"))?>
</div>
</div>
</div>
<div class="row" >
<div class="col-md-3" >
<div class="control-group col-md-11">
<label >Birthday <span class="req_star">*</span></label>
<?php echo form_input(array("name" =>"birthday" ,"id"=>"sedang","class"=>"m-wrap form-control col-md-5 datepicker1 req","value"=>$row->birthday,"required"=>"required"))?>
</div>
</div>
<div class="col-md-3" >
<div class="control-group col-md-11">
<label >Anniversary</label>
<?php echo form_input(array("name" =>"anniversary" ,"id"=>"lastname","class"=>"m-wrap form-control col-md-5 datepicker1","value"=>$row->anniversary))?>
</div>
</div>
<div class="col-md-3" >
<div class="control-group col-md-11">
<label>Blood Group</label>
<select name="blood_group"class="select2 form-control">
<option value="A Positive" <?php if($row->blood_group=='A Positive') echo 'selected'; ?>>A Positive</option>
<option value="A Negative" <?php if($row->blood_group=='A Negative') echo 'selected'; ?>>A Negative</option>
<option value="B Positive" <?php if($row->blood_group=='B Positive') echo 'selected'; ?>>B Positive</option>
<option value="B Negative" <?php if($row->blood_group=='B Negative') echo 'selected'; ?>>B Negative</option>
<option value="AB Positive" <?php if($row->blood_group=='AB Positive') echo 'selected'; ?>>AB Positive</option>
<option value="AB Negative" <?php if($row->blood_group=='AB Negative') echo 'selected'; ?>>AB Negative</option>
<option value="O Positive" <?php if($row->blood_group=='O Positive') echo 'selected'; ?>>O Positive</option>
<option value="O Negative" <?php if($row->blood_group=='O Negative') echo 'selected'; ?>>O Negative</option>
<option value="Unknown" <?php if($row->blood_group=='Unknown') echo 'selected'; ?>>I Dont Know</option>
</select>
</div>
</div>
<div class="col-md-3">
<div class="control-group col-md-11">
<label>Gender</label>
<div class="clearfix"></div>
<label><input type="radio" name="gender" value="Male" <?php if($row->gender=='Male') echo 'checked'; ?>> Male</label>
<label><input type="radio" name="gender" value="Female" <?php if($row->gender=='Female') echo 'checked'; ?>> Female</label>
</div>
</div>
</div>
<div class="row" >
<div class="col-md-3" >
<div class="control-group col-md-11">
<label>Email <span class="req_star">*</span></label>
<?php if($row->email=='') { ?>
<?php echo form_input(array("name" =>"email" ,"id"=>"email","class"=>"m-wrap form-control col-md-5 req","value"=>$row->email,"required"=>"required"))?>
<?php } else { ?>
<?php echo form_input(array("name" =>"email" ,"id"=>"email","class"=>"m-wrap form-control col-md-5 req","value"=>$row->email,"readonly"=>"readonly"))?>
<?php } ?>
<input type="hidden" name="username" value="<?php echo $row->email; ?>">
</div>
</div>
<div class="col-md-3" >
<div class=" control-group col-md-11">
<label >Password <?php if($action == 'add') { ?><span class="req_star">*</span><?php } ?></label>
<?php if($action == 'add') { ?>
<?php echo form_password(array("name" =>"password" ,"id"=>"password","class"=>"m-wrap form-control col-md-5 req","value"=>$row->password)); ?>
<?php } else { ?>
<?php echo form_password(array("name" =>"" ,"id"=>"password","class"=>"m-wrap form-control col-md-5","value"=>$row->userdetail->userpass,"readonly"=>"readonly")); ?>
<?php } ?>
</div>
</div>
</div>
<div style="clear:both"></div>
<div class="clearfix"></div><br>
</div>
</div>
<div class="col-md-12">
<div class="col-md-5 profile-info">
<div class="clearfix"></div>
<h4>Permanent Address</h4>
<div class=" control-group col-md-11">
<label class="control-label">Address <span class="req_star">*</span></label>
<div class="controls"> <?php echo form_input(array("name" =>"paddress" ,"id"=>"","class"=>"m-wrap col-md-12 req form-control","style"=>"padding:2px;border:1px solid #ccc","value"=>$paddress->address," ","required"=>"required"))?> </div>
</div>
<div class="clearfix"></div>
<div class="control-group ">
<label class="control-label">Country <span class="req_star">*</span></label>
<div class="controls">
<?php
$options = array();
$options['0']=BLANK_SELECT;
if(count($countries)){
foreach($countries as $val){
$options[$val->id]=$val->country;
}
}
echo form_dropdown('pcountryid', $options, $paddress->countryid,'id="pcountryid" class="select2 req col-md-6 form-control" style="width:380px;" required');
echo form_hidden('originalstateid',$row->stateid);
echo form_hidden('originalcityid',$row->cityid);
?>
</div>
</div>
<div class="clearfix"></div>
<div class=" control-group col-md-11">
<label class="control-label">State <span class="req_star">*</span></label>
<div class="controls">
<?php
$options = array();
$options['0']=BLANK_SELECT;
if(count($states)){
foreach($states as $val){
$options[$val->id]=$val->state;
}
}
echo form_dropdown('pstateid', $options, $paddress->stateid,'id="pstateid" class="col-md-6 req select2 form-control" required ');
?>
</div>
</div>
<div class="clearfix"></div>
<div class=" control-group col-md-11">
<label class="control-label">City <span class="req_star">*</span></label>
<div class="controls">
<?php
$options = array();
$options['0']=BLANK_SELECT;
if(count($cities)){
foreach($cities as $val){
$options[$val->id]=$val->city;
}
}
echo form_dropdown('pcityid', $options, $paddress->cityid,'id="pcityid" class="col-md-6 req select2 form-control" required ');
echo form_hidden('originalpstateid',$row->stateid);
echo form_hidden('originalpcityid',$paddress->cityid);
?>
</div>
</div>
<div class="clearfix"></div>
<div class=" control-group col-md-11">
<label class="control-label">Pin Code <span class="req_star">*</span></label>
<div class="controls">
<?php echo form_input(array("name" =>"ppincode" ,"id"=>"pincode","class"=>"m-wrap col-md-12 form-control req","value"=>$paddress->pincode," ","required"=>"required")); ?>
</div>
</div>
<div class="clearfix"></div>
<div class=" control-group col-md-11">
<label class="control-label">Phone1 <span class="req_star">*</span></label>
<div class="controls">
<?php echo form_input(array("name" =>"pphone1" ,"id"=>"pphone1","class"=>"phonevalid m-wrap col-md-12 form-control req","value"=>$paddress->phone1," ","required"=>"required")); ?>
</div>
</div>
<div class="clearfix"></div>
<div class=" control-group col-md-11">
<label class="control-label">Phone2 </label>
<div class="controls">
<?php echo form_input(array("name" =>"pphone2" ,"id"=>"pphone2","class"=>"phonevalid m-wrap col-md-12 form-control","value"=>$paddress->phone2," ")); ?>
</div>
</div>
<div class=" control-group col-md-11">
<label class="control-label">Mobile <span class="req_star">*</span></label>
<div class="controls">
<?php echo form_input(array("name" =>"pmobile" ,"id"=>"pmobile","class"=>"phonevalid m-wrap col-md-12 form-control req","value"=>$paddress->mobile," ","required"=>"required")); ?>
</div>
</div>
<div class="clearfix"></div>
</div>
<div class="col-md-5 profile-info pull-right">
<div class="clearfix"></div>
<h4>Correspondence Address</h4>
<div class=" control-group col-md-11">
<label class="control-label">Address <span class="req_star">*</span></label>
<div class="controls"> <?php echo form_input(array("name" =>"caddress" ,"id"=>"","class"=>"m-wrap col-md-12 req form-control","style"=>"padding:2px;border:1px solid #ccc","value"=>$caddress->address," ","required"=>"required"))?> </div>
</div>
<div class="clearfix"></div>
<div class="control-group ">
<label class="control-label">Country <span class="req_star">*</span></label>
<div class="controls">
<?php
$options = array();
$options['0']=BLANK_SELECT;
if(count($countries1)){
foreach($countries as $val){
$options[$val->id]=$val->country;
}
}
//echo $caddress->countryid;
echo form_dropdown('ccountryid', $options, $caddress->countryid,'id="countryid" class="select2 form-control req" style="width:380px;" required');
echo form_hidden('originalcstateid',$caddress->stateid);
echo form_hidden('originalccityid',$caddress->cityid);
?>
</div>
</div>
<div class="clearfix"></div>
<div class=" control-group col-md-11">
<label class="control-label">State <span class="req_star">*</span></label>
<div class="controls">
<?php
$options = array();
$options['0']=BLANK_SELECT;
if(count($states1)){
foreach($states1 as $val){
$options[$val->id]=$val->state;
}
}
echo form_dropdown('cstateid', $options, $caddress->stateid,'id="stateid" class="col-md-6 select2 form-control req" required ');
?>
</div>
</div>
<div class="clearfix"></div>
<div class=" control-group col-md-11">
<label class="control-label">City <span class="req_star">*</span></label>
<div class="controls">
<?php
$options = array();
$options['0']=BLANK_SELECT;
if(count($cities1)){
foreach($cities1 as $val){
$options[$val->id]=$val->city;
}
}
echo form_dropdown('ccityid', $options, $caddress->cityid,'id="cityid" class="col-md-6 select2 req form-control" required');
echo form_hidden('originalcstateid',$caddress->stateid);
echo form_hidden('originalccityid',$caddress->cityid);
?>
</div>
</div>
<div class="clearfix"></div>
<div class=" control-group col-md-11">
<label class="control-label">Pin Code <span class="req_star">*</span></label>
<div class="controls">
<?php echo form_input(array("name" =>"pincode" ,"id"=>"pincode","class"=>"m-wrap col-md-12 form-control req","value"=>$caddress->pincode," ","required"=>"required")); ?>
</div>
</div>
<div class="clearfix"></div>
<div class=" control-group col-md-11">
<label class="control-label">Phone1 <span class="req_star">*</span> </label>
<div class="controls">
<?php echo form_input(array("name" =>"cphone1" ,"id"=>"cphone1","class"=>"phonevalid m-wrap col-md-12 form-control req","value"=>$caddress->phone1," ","required"=>"required")); ?>
</div>
</div>
<div class="clearfix"></div>
<div class=" control-group col-md-11">
<label class="control-label">Phone2 </label>
<div class="controls">
<?php echo form_input(array("name" =>"cphone2" ,"id"=>"cphone2","class"=>"phonevalid m-wrap col-md-12 form-control","value"=>$caddress->phone2," ")); ?>
</div>
</div>
<div class=" control-group col-md-11">
<label class="control-label">Mobile <span class="req_star">*</span></label>
<div class="controls">
<?php echo form_input(array("name" =>"cmobile" ,"id"=>"cmobile","class"=>"phonevalid m-wrap col-md-12 form-control req","value"=>$caddress->mobile," ","required"=>"required")); ?>
</div>
</div>
<div class="clearfix"></div>
<script>
$(document).ready(function(){
$("#countryid").trigger("change");
});
</script>
<div class="clearfix"></div><br>
</div>
</div>
</div>
<div class="submit-btn pull-right">
<?php
echo form_hidden('action',$action);
echo form_hidden('id',$id);
?>
<input type="button" id="submituserform" value="Submit" class="btn-info btn button btnNext"></input>
</div>
我只包含部分视图代码,因为它很大。
尝试将 config.php 更改为
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].':8080/Jan182017';
但会产生网址 - http://localhost/Jan182017/users/add_user/#menu1并且所有用户界面都会失真。我想要做的就是在codeigniter应用程序中的每次提交和按钮上添加:8080 到 localhost ,而不会影响应用程序的UI。
答案 0 :(得分:0)
你需要添加Listen&#34; 8080&#34;
中的端口命令:vim /etc/apache2/appache2.conf文件
然后重启apache2
service:命令:apache2 service restart
然后,您将能够打开该端口,然后授予根文件夹
的权限控制器文件夹:$ this-&gt; current_module = $ this-&gt; uri-&gt; segment(2);
查看:form_open(&#39;&#39;,数组(&#39; id&#39; =&gt;&#39; add_template&#39;,&#39; autocomplete&#39; =&gt;& #39;关闭&#39;));
提交表单后,它应重定向到
重定向(base_url(&#39; admin /&#39;。$ this-&gt; current_module));
请检查。