I created a search page with jquery that will display result on same page and I succeed of doing it but the jquery that I made can only show data with index 0 and it will fail if I searched other data with differenct index. I am having Uncaught TypeError: Cannot read property 'StudentNumber' of undefined error in console log.How can I search json object with data matching what is type in the search bar then populate the textbox from db. Please help.... thanks....
$('#btnSearch').click(function(){
var txtValue = $("#txtsearch").val();
$.ajax({
type:"POST",
url:"<?php echo site_url('enrollment/studSearch');?>",
data: {q:txtValue},
dataType: "json",
success: function(data){
//console.log(data.studinfo[0].StudentNumber);
$("#studentnum").val(data.studinfo[0].StudentNumber);
$("#yearLevel").val(data.studinfo[0].YearLevel);
$("#lastname").val(data.studinfo[0].LastName);
$("#firstname").val(data.studinfo[0].FirstName);
$("#middlename").val(data.studinfo[0].MiddleName);
$("#txtTuition").val(data.studinfo[0].TuitionFee);
$("#txtMisc").val(data.studinfo[0].MiscFee);
$("#txtAddFee").val(data.studinfo[0].AdditionalFee);
$("#txtTotal").val(data.studinfo[0].Total);
$("#modeofpayment").val(data.studinfo[0].ModeOfPayment);
$("#payAmount").val(data.studinfo[0].PayableAmount);
},
});
});
my controller:
public function studSearch()
{
$str = $this->input->post('q');
$data['studinfo'] = $this->emodel->search_Student($str);
echo json_encode($data);
}
and the model:
function search_Student($str)
{
$this->db->select('*');
$this->db->from('studentinfo a');
$this->db->join('studFinance b','a.StudentNumber = b.StudentNumber');
$this->db->like('a.StudentNumber',$str);
$this->db->or_like('a.LastName',$str);
$this->db->or_like('a.FirstName',$str);
$query = $this->db->get();
$result = $query->result_array();
return $result;
}
this is the view:
<div id="page-wrapper">
<div id="page-inner">
<div class="row">
<div class="col-lg-12">
<h2>Billing Page</h2>
</div>
</div>
<hr />
<div class="row">
<div class="col-lg-12">
<?php
$attributes = array("class"=>"form- horizontal","id"=>"billform","name"=>"billform",
"autocomplete"=>"off");
echo form_open("enrollment/ebilling",$attributes);
?>
<div class="panel panel-primary">
<div class="panel-heading">
Personal Information
</div>
<div class="panel-body">
<div class="form-group col-lg-12">
<label class="control-label col-xs-2">Search:</label>
<div class="col-xs-3">
<input type="text" id="txtsearch" name="txtsearch" class="form-control"/>
</div>
<button type="button" class="btn btn-success" id="btnSearch" name="btnSearch">Search</button>
</div>
<div class="form-group col-lg-12">
<hr />
<label class="control-label col-xs-2">Student Number:</label>
<div class="col-xs-3">
<input type="text" readonly id="studentnum" name="studentnum" value="<?php echo set_value('studentnum');?>" class="form-control"/>
</div>
</div>
<div class="form-group col-lg-12">
<label class="control-label col-xs-2">Year Level:</label>
<div class="col-xs-3">
<input type="text" readonly id="yearLevel" name="yearLevel" value="<?php echo set_value('yearLevel');?>" class="form-control"/>
</div>
<label class="control-label col-xs-2">Last Name:</label>
<div class="col-xs-3">
<input type="text" id="lastname" name="lastname" value="<?php echo set_value('lastname');?>" readonly class="form-control" />
</div>
</div>
<div class="form-group col-lg-12">
<label class="control-label col-xs-2">First Name:</label>
<div class="col-xs-3">
<input type="text" id="firstname" name="firstname" value="<?php echo set_value('firstname');?>" readonly class="form-control" />
</div>
<label class="control-label col-xs-2">Middle Name:</label>
<div class="col-xs-3">
<input type=-"text" id="middlename" name="middlename" value="<?php echo set_value('middlename');?>" readonly class="form-control" />
</div>
</div>
</div>
</div>
<!-- END OF FIRST PANEL -->
<div class="panel panel-primary">
<div class="panel-heading">
Billing Mode
</div>
<div class="panel-body">
<div class="col-lg-6">
<div class="panel panel-info">
<div class="panel-heading">
Student Account
</div>
<div class="panel-body">
<div class="form-group col-lg-12">
<label class="control-label col-xs-5">Tuition Fee:</label>
<div class="col-xs-7">
<input type="text" id="txtTuition" readonly name="txtTuition" value=" <?php echo set_value('txtTuition');?>" class="form-control"/>
</div>
</div>
<div class="form-group col-lg-12">
<label class="control-label col-xs-5">Miscellaneous Fee:</label>
<div class="col-xs-7">
<input type="text" id="txtMisc" readonly name="txtMisc" value="<?php echo set_value('txtMisc');?>" class="form-control"/>
</div>
</div>
<div class="form-group col-lg-12">
<label class="control-label col-xs-5">Additional Fee:</label>
<div class="col-xs-7">
<input type="text" id="txtAddFee" readonly name="txtAddFee" value="<?php echo set_value('txtAddFee');?>" class="form-control"/>
</div>
</div>
<div class="form-group col-lg-12">
<label class="control-label col-xs-5">Total:</label>
<div class="col-xs-7">
<input type="text" id="txtTotal" readonly name="txtTotal" value="<?php echo set_value('txtTotal');?>" class="form-control"/>
</div>
</div>
</div>
</div>
<!-- END OF FIRST INSIDE PANEL -->
<div class="panel panel-info">
<div class="panel-heading">
Payment
</div>
<div class="panel-body">
<div class="form-group col-lg-12">
<label class="control-label col-xs-5">Mode of Payment:</label>
<div class="col-xs-7">
<input type="text" id="modeofpayment" name="modeofpayment" value="<?php echo set_value('modeofpayment');?>" readonly class="form-control"/>
</div>
</div>
<div class="form-group col-lg-12">
<label class="control-label col-xs-5">Payable Amount:</label>
<div class="col-xs-7">
<input type="text" id="payAmount" name="payAmount" value="<?php echo set_value('payAmount');?>" readonly class="form-control"/>
</div>
</div>
<div class="form-group col-lg-12">
<label class="control-label col-xs-5">Date:</label>
<div class="col-xs-7">
<input type="date" id="pDate" name="pDate" value="<?php echo set_value('pDate');?>" class="form-control"/>
<span class="text-danger"><?php echo form_error('pDate');?></span>
</div>
</div>
<div class="form-group col-lg-12">
<label class="control-label col-xs-5">OR Number:</label>
<div class="col-xs-7">
<input type="text" id="orNum" name="orNum" value="<?php echo set_value('orNum');?>" class="form-control"/>
<span class="text-danger"><?php echo form_error('orNum');?></span>
<input type="hidden" id="balance" name="balance"/>
</div>
</div>
<!-- END OF SECOND INSIDE PANEL -->
</div>
</div>
</div>
<div class="col-lg-6">
<table id="billTable" class="table table-hover table-bordered table-striped">
<thead>
<tr>
<th>OR Number</th>
<th>Amount</th>
<th>Date</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<td>Balance</td>
</tfoot>
</table>
</div>
<!-- END OF TABLE -->
<div class="col-lg-6">
<div class="form-group col-lg-12">
<input type="button" class="btn btn-success" id="btnAddPayment" name="btnAddPayment"
value="Add Payment"/>
<button type="reset" class="btn btn-danger" id="btnReset" name="reset">Reset</button>
</div>
</div>
</div>
</div>
<?php echo form_close();
echo $this->session->flashdata('msg');?>
</div>
</div>
</div>
</div>
Related
I am using Codeigniter 3
and uploading a file using upload library in CodeIgniter whenever I upload the file it's giving me The temporary folder is missing.
I am confusing why it's giving me this error because I uploaded my project on a server its working fine on that server but when I upload same files on another server it's giving me this error I don't why.
Here is my code
HTML
<div class="storecreatewrapper">
<div class="toptext">
<div class="container">
<div class="row">
<div class="col-md-12">
<p>Let's build your store at <span><?php echo PROJECT;?>!</span></p>
</div>
</div>
</div>
</div>
<div class="formwrapper">
<form action="<?php echo site_url('shop/addshop')?>" enctype="multipart/form-data" method="post" accept-charset="utf-8" id="adsp_09">
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="mianstoreform">
<div class="row">
<div class="col-md-12">
<div class="formtopimg">
<img src="<?php echo base_url('assets/images/logos/storepic.png') ?>" >
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="mainbasictxt">
<div class="bsichr"></div>
<div class="basictxt">
<p>Basic Shop Information</p>
</div>
</div>
<div class="form-group">
<?php c_error();?>
</div>
</div>
</div>
<div class="stformfields">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Shop Name <span class="red">*</span></label>
<?php
$shopname = array(
'class' => 'form-control',
'id' => 'shopname',
'placeholder' => 'Shop Name',
'name'=>'shopname'
);
echo form_input($shopname);
?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Shop URL <span class="red">*</span></label>
<?php
$shopurl = array(
'class' => 'form-control',
'id' => 'fohopurl',
'name'=>'shpurl',
'placeholder' => 'Shop URL: www.'.PROJECT.'.com/shops/URL'
);
echo form_input($shopurl);
?>
</div>
</div>
</div>
</div>
<div class="custmhr"></div>
<div class="row">
<div class="col-md-12">
<div class="mainbasictxt">
<div class="bsichr"></div>
<div class="basictxt">
<p>Account Verification Detail</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="frmrads">
<div class="pull-left cusradhead">
Account Type:
</div>
<div class="pull-left">
<div class="radio">
<label>
<input class="act_9" type="radio" name="at" id="individual" value="individual" checked>
Individual Professional.
</label>
</div>
<div class="radio">
<label>
<input class="act_9" type="radio" name="at" id="business" value="business">
Business (Selling On Behalf of a Business Entity).
</label>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="documtslt">
<div class="row">
<div class="col-sm-10 lftcolset">
<div class="form-group">
<select name="dcname" id="dcm_67">
<option selected="select">
Document (Please Select)
</option>
<option value="national id">National ID</option>
<option value="passport">Passport</option>
</select>
</div>
</div>
<div class="col-sm-2 rytcolset">
<input id="file-upload" type="file" name="ushplg" style="display:none"/>
<button type="button" id="upfile1" class="btn cutsltbtn" for="file-upload">Image</button>
</div>
</div>
</div>
</div>
</div>
<div class="docfrmffl">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<?php
$shopurl = array(
'class' => 'form-control',
'id' => 'document_id',
'placeholder' => 'Document ID',
'name'=>'document_id'
);
echo form_input($shopurl);
?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p class="notetxt">
Note: English (a-z,A-Z), digits(0-9), - , spaces.
</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<?php
$shopurl = array(
'class' => 'form-control expiry_date',
'id' => 'datepicker',
'placeholder' => 'Expiry Date',
'name'=>'expiry_date'
);
echo form_input($shopurl);
?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p class="notetxt">
Note: JPEG, PNG or PDF only and 2MB file size.
</p>
</div>
</div>
</div>
<div class="custmhr"></div>
<div class="row">
<div class="col-md-12">
<div class="mainbasictxt">
<div class="bsichr"></div>
<div class="basictxt">
<p>Order Pickup Location</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="frmrads">
<div class="pull-left">
<?php if(is_logedin()): //if logedin ?>
<?php if(
$this->session->userdata('city_id') && $this->session->userdata('area_id') && $this->session->userdata('direction')
):
?>
<div class="radio">
<label>
<input class="loc_09" type="radio" name="location" id="shipping" value="shipping" checked>
Same as my shipping address
</label>
</div>
<?php else: // if loggedin and city area and direction not found. ?>
<div class="radio">
<label>
<input class="loc_09" type="radio" name="location" id="new_address" value="new_address" checked>
Register a new address
</label>
</div>
<?php endif; //checking if shipping addres set or not..?>
<?php else: ?>
<div class="radio">
<label>
<input class="loc_09" type="radio" name="location" id="new_address" value="new_address" checked>
Register a new address
</label>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
<div class="locations">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>City <span class="red">*</span></label>
<select name="city" class="city_9 sada" disabled>
<option value="none" selected="select">City</option>
<?php if($cities->num_rows() > 0):
foreach ($cities->result() as $city):
?>
<option value="<?php echo $city->c_id ?>">
<?php echo $city->city_name ?></option>
<?php endforeach;?>
<?php endif; ?>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Area <span class="red">*</span></label>
<!-- <select name="area" id="area" class="sada" disabled>
<option selected="select">Select Area</option>
</select> -->
<span class="pslare">
</span>
<input type="text" class="form-control caresshx" id="areasped" placeholder="Area" value="">
<input type="hidden" name="area" value="" id="ardix">
<!-- <select name="area" id="area" class="sada" <?php if($shop_info[0]['location'] == 1){ echo 'disabled';}?>>
<option selected="select">Select Area</option>
</select> -->
<ul class="ullist list-unstyled">
</ul>
</div>
</div>
</div>
</div>
<div class="docfrmffl">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<input type="text" class="form-control sada" name="street" id="street" placeholder="Street" disabled>
</div>
<div class="form-group">
<input type="text" name="build_num" class="form-control sada" placeholder="Building Name" disabled id="build_num">
</div>
<div class="form-group">
<?php
$rft = array(
'class'=>'form-control',
'name'=>'rft',
'placeholder'=>'House Number'
);
echo form_input($rft);
?>
</div>
<div class="form-group">
<label>Direction <span class="red">*</span></label>
<textarea class="form-control" name="direction" rows="3" id="flladdrs" placeholder="Direction"></textarea>
</div>
<div class="form-group">
Click here to choose from map
</div>
<div class="form-group tsslid" id="opmap" style="display: none">
<div class="form-group">
<input id="address" type="text" placeholder="Enter an address" class="form-control">
<!-- Cancel -->
</div>
<div class="form-group">
Close map
</div>
<div id="map"></div>
</div>
</div>
</div>
</div>
<div class="custmhr"></div>
<div class="row">
<div class="col-md-12">
<div class="mainbasictxt">
<div class="bsichr"></div>
<div class="basictxt">
<p>Contact Information</p>
</div>
</div>
</div>
</div>
<div class="docfrmffl">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>First Name <span class="red">*</span></label>
<?php if(is_logedin()): ?>
<input type="text" class="form-control" name="fname" placeholder="First Name" value="<?php echo get_session_element('fname');?>" readonly id="fname">
<?php else: ?>
<input type="text" class="form-control" name="fname" placeholder="First Name" id="fname">
<?php endif; ?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Last Name <span class="red">*</span></label>
<?php if(is_logedin()): ?>
<input type="text" name="lname" class="form-control" placeholder="Last Name" value="<?php echo get_session_element('lname');?>" readonly id="lname">
<?php else: ?>
<input type="text" name="lname" class="form-control" placeholder="Last Name" id="lname">
<?php endif; ?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Email <span class="red">*</span></label>
<?php if(is_logedin()): ?>
<input type="text" name="email" class="form-control" placeholder="Email" value="<?php echo get_session_element('email');?>" readonly id="email">
<?php else: ?>
<input type="text" name="email" class="form-control" placeholder="Email" id="email">
<?php endif; ?>
</div>
</div>
</div>
<?php if(!is_logedin()): ?>
<div class="row" class="lng" id="lng">
<div class="col-md-12">
<div class="form-group">
<label>Password <span class="red">*</span></label>
<input type="password" name="pass" id="pass" placeholder="Enter You Password" class="form-control" >
</div>
<div class="form-group">
<label>Confirm Password <span class="red">*</span></label>
<input type="password" id="cnpass" placeholder="Confirm Password" class="form-control" name="cnpass">
</div>
</div>
</div>
<?php endif; ?>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Mobile Phone <span class="red">*</span></label>
<?php if(is_logedin()): ?>
<input type="text" name="mob" class="form-control" placeholder="Mobile Phone" value="<?php echo get_session_element('mobile');?>" id="mob">
<?php else: ?>
<input type="text" name="mob" class="form-control" placeholder="Mobile Phone" id="mob">
<?php endif; ?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>LandLine <span class="red">*</span></label>
<?php if(is_logedin()): ?>
<input type="text" name="landline" class="form-control" placeholder="LandLine" value="<?php echo get_session_element('phone');?>" id="landline">
<?php else: ?>
<input type="text" name="landline" class="form-control" placeholder="LandLine" id="landline">
<?php endif; ?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="agreementtxt">
<input type="checkbox" name="agreement" id="arg_098">
I have read and accepted terms and conditions of the agreement.
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="createbtndv">
<input type="submit" class="btn custmsubmit edupfl" value="Create Store" disabled="disabled" id="btnsb">
</div>
<div class="form-group snofd">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
echo form_close();
?>
</div>
</div>
PHP
$image_path = realpath(APPPATH . '../assets/images/usershop');
$config['upload_path'] = $image_path;
$config['allowed_types'] = 'gif|jpg|png';
$config['file_name'] = random_string('alnum', 16);
$this->load->library('upload', $config);
if (!$this->upload->do_upload('ushplg'))
{
$error = $this->upload->display_errors('<p>','</p>');
c_flash('alert-danger',$error,'shop/open');
}
else
{
$filename = $this->upload->data();
$data['doc_image'] = $filename['file_name'];
}
$add_n_shop = $this->mod_shop->add_new_shop($data);
if ($add_n_shop)
{
c_flash('alert-success','Your shop has been created but review by admin.','user/about');
}
else
{
c_flash('alert-danger','Your shop has not been created.','shop/open');
}
This can also happen when you run out of disk space or there don't have available inodes. In my case I faced this error because PHP session files were using up all the inodes.
The following answer can help you with further investigation:
https://askubuntu.com/a/1107896
I have this error in controller
A PHP Error was encountered
Severity: Notice
Message: Undefined property: dashboardController::$upload
Filename: controllers/dashboardController.php
Line Number: 70
Call to a member function data() on a non-object in
C:\xampp\htdocs\High_tack\application\controllers\dashboardController.php
on line 71
just do as i done it in my project using wamp and codeigniter. I uploaded my pictures directly into the folder named uploads in the project folder.
here is my controller named addproduct,
<?php class Addproduct extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->helper(array('form', 'url'));
}
public function index(){
$this->load->view('addproduct');
}
function save() {
$name_file = $_FILES['pro_filename']['name'];
//$user=$this->session->userdata['logged_in'];
$data=array (
'pro_name'=>$this->input->post('pro_name'),
'pro_code'=>$this->input->post('pro_code'),
'hsn_code'=>$this->input->post('hsn_code'),
'pro_price'=>$this->input->post('pro_price'),
'pro_tax1'=>$this->input->post('pro_tax1'),
'pro_tax2'=>$this->input->post('pro_tax2'),
'pro_tax3'=>$this->input->post('pro_tax3'),
'pro_tax4'=>$this->input->post('pro_tax4'),
'pro_description'=>$this->input->post('pro_description'),
'pro_brand'=>$this->input->post('pro_brand'),
'pro_category'=>$this->input->post('pro_category'),
'pro_scategory'=>$this->input->post('pro_scategory'),
'pro_sscategory'=>$this->input->post('pro_sscategory'),
'pro_qauntity'=>$this->input->post('pro_qauntity'),
'pro_service'=>$this->input->post('pro_service'),
'pro_certificate'=>$this->input->post('pro_certificate'),
'pro_filename'=>$name_file,
'pro_date'=>$this->input->post('pro_date')
);
$this->load->model('base_model');
$this->base_model->save('addproduct',$data);
$this->do_upload();
$this->load->view('addproduct');
}
public function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|gif|jpeg';
$config['max_size'] = 500000;
$config['max_width'] = 200000;
$config['max_height'] = 200000;
$this->load->library('upload', $config);
$this->upload->do_upload('pro_filename');
}
}
here is my view page named addproduct
<div class="panel-body">
<div class="form">
<div class="col-md-12 sign-up text-left">
<div class="form-group ">
<label for="pro_name" class="control-label col-lg-3">Product Name</label>
<div class="col-lg-6">
<input class="form-control " id="pro_name" name="pro_name" type="text" />
</div>
</div><br><br>
<div class="form-group ">
<label for="pro_code" class="control-label col-lg-3">Product Code</label>
<div class="col-lg-6">
<input class="form-control " id="pro_code" name="pro_code" type="text" />
</div>
</div><br><br>
<div class="form-group ">
<label for="hsn_code" class="control-label col-lg-3">HSN Code</label>
<div class="col-lg-6">
<input class="form-control " id="hsn_code" name="hsn_code" type="text" />
</div>
</div><br><br>
<div class="form-group ">
<label for="pro_price" class="control-label col-lg-3">Prize</label>
<div class="col-lg-6">
<input class="form-control " id="pro_price" name="pro_price" type="text" />
</div>
</div><br><br>
<div class="form-group ">
<label for="pro_tax1" class="control-label col-lg-3">Tax 1</label>
<div class="col-lg-6">
<input class="form-control " id="pro_tax1" name="pro_tax1" type="text" />
</div>
</div><br><br>
<div class="form-group ">
<label for="pro_tax2" class="control-label col-lg-3">Tax 2</label>
<div class="col-lg-6">
<input class="form-control " id="pro_tax2" name="pro_tax2" type="text" />
</div>
</div><br><br>
<div class="form-group ">
<label for="pro_tax3" class="control-label col-lg-3">Tax 3</label>
<div class="col-lg-6">
<input class="form-control " id="pro_tax3" name="pro_tax3" type="text" />
</div>
</div><br><br>
<div class="form-group ">
<label for="pro_tax4" class="control-label col-lg-3">Tax 4</label>
<div class="col-lg-6">
<input class="form-control " id="pro_tax4" name="pro_tax4" type="text" />
</div>
</div><br><br>
<div class="form-group ">
<label for="pro_description" class="control-label col-lg-3">Description</label>
<div class="col-lg-6">
<input class="form-control " id="pro_description" name="pro_description" type="text" />
</div>
</div><br><br>
<div class="form-group ">
<label for="pro_brand" class="control-label col-lg-3">Brand</label>
<div class="col-lg-6">
<input class="form-control " id="pro_brand" name="pro_brand" type="text" />
</div>
</div><br><br>
<div class="form-group ">
<label for="pro_category" class="control-label col-lg-3">Category</label>
<div class="col-lg-6">
<input class="form-control " id="pro_category" name="pro_category" type="text" />
</div>
</div><br><br>
<div class="form-group ">
<label for="pro_scategory" class="control-label col-lg-3">Sub Category</label>
<div class="col-lg-6">
<input class="form-control " id="pro_scategory" name="pro_scategory" type="text" />
</div>
</div><br><br>
<div class="form-group ">
<label for="pro_sscategory" class="control-label col-lg-3">S-Sub Category</label>
<div class="col-lg-6">
<input class="form-control " id="pro_sscategory" name="pro_sscategory" type="text" />
</div>
</div><br><br>
<div class="form-group ">
<label for="pro_quantity" class="control-label col-lg-3">Qauntity</label>
<div class="col-lg-6">
<input class="form-control " id="pro_quantity" name="pro_quantity" type="text" />
</div>
</div><br><br>
<div class="form-group ">
<label for="pro_service" class="control-label col-lg-3">Service Alert</label>
<div class="col-lg-6">
<input class="form-control " id="pro_service" name="pro_service" type="text" />
</div>
</div><br><br>
<div class="form-group ">
<label for="pro_certificate" class="control-label col-lg-3">Certificate Alert</label>
<div class="col-lg-6">
<input class="form-control " id="pro_certificate" name="pro_certificate" type="text" />
</div>
</div><br><br>
<div class="form-group ">
<label for="pro_filename" class="control-label col-lg-3">Photo:</label>
<div class="col-lg-6">
<input class="form-control" type="file" name="pro_filename" required/>
</div>
</div><br><br>
<div class="clearfix"></div>
<?php
$today = date("Y-m-d");
?>
<input type="hidden" name="pro_date" value="<?php echo $today ?>">
<div class="form-group">
<div class="col-lg-offset-3 col-lg-6">
<button class="btn btn-primary" type="submit">Save</button>
<button class="btn btn-default" >Cancel</button>
</div>
</div>
<br>
</div>
<br>
</div>
</div>
this is my code in model named base_model
public function save($table, $data) {
return $this->db->insert($table, $data);
}
delete the portion you dont want, if you dont need to upload the image to folder simply change the controller field where the upload occurs
'pro_filename'=>$this->input->post('pro_filename'),
I want to create a login form to log system in php. But I can't do it, below I mentioned my code. I have coded registration form also. It works successfully, but the login form does not works properly. The registration form code is included in the index page. But the login code is include in login.php page.
Help me to solve this problem.
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
×</button>
<h4 style="text-align: center" class="modal-title" id="myModalLabel">
Login & Registration</a></h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-8" style="border-right: 1px dotted #C2C2C2;padding-right: 30px;">
<!-- Nav tabs -->
<ul class="nav nav-tabs">
<li class="active">Login</li>
<li>Registration</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="Login">
<form class="form-horizontal" actoin="login.php" method="post" >
<div class="form-group">
<label class="col-sm-2 control-label">
Username</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="username2" id="username2" placeholder="Username" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">
Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" name="pwd2" id="pwd2" placeholder="Password" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">
User Type</label>
<div class="col-sm-10">
<select class="form-control" name="utype" id="utype">
<option selected disabled>User Type</option>
<option value="Admin">Admin</option>
<option value="Student">Student</option>
<option value="Company">Company</option>
</select>
</div>
</div>
<div class="row">
<div class="col-sm-2">
</div>
<div class="col-sm-10">
<input type="submit" class="btn btn-primary btn-sm" name="buttonsubmit" id="buttonsubmit" value="Login">
Forgot your password?
</div>
</div>
</form>
</div>
<div class="tab-pane" id="Registration">
<form class="form-horizontal" action="index.php" method="post">
<div class="form-group">
<label class="col-sm-2 control-label">
Title</label>
<div class="col-sm-10">
<div class="row">
<div class="col-md-3">
<select class="form-control" id="uutypex" name="uutype">
<option>Mr.</option>
<option>Ms.</option>
<option>Mrs.</option>
</select>
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">
Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="name" id="name" placeholder="Name" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">
User Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="username1" id="username1" placeholder="User Name" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">
Password</label>
<div class="col-sm-10">
<input class="form-control" name="pwd" id="pwd" type="password" placeholder="Password" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">
Birth Date
</label>
<div class="col-sm-10">
<input class="form-control" name="bdate" id="bdate" type="date">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">
Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" name="email" id="email" placeholder="User Name" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">
Mobile
</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="mobile" id="mobile" placeholder="Mobile" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">
University</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="uni" id="uni" placeholder="University" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">
User Type
</label>
<div class="col-sm-10">
<select class="form-control" name="type" id="type">
<option selected disabled>User Type</option>
<option value="Admin">Admin</option>
<option value="Student">Student</option>
<option value="Company">Company</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">
GPA</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="gpa" id="gpa" placeholder="GPA" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">
Address</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="address" id="address" placeholder="Address" />
</div>
</div>
<div class="row">
<div class="col-sm-2">
</div>
<div class="col-sm-10">
<input type="submit" class="btn btn-primary btn-sm" name="buttonregister" id="buttonregister" value="Submit and Save">
<button type="button" class="btn btn-default btn-sm">
Cancel
</button>
</div>
</div>
</form>
</div>
</div>
<div id="OR" class="hidden-xs">
OR</div>
</div>
<div class="col-md-4">
<div class="row text-center sign-with">
<div class="col-md-12">
<h3>
Sign in with
</h3>
</div>
<div class="col-md-12">
<div class="btn-group btn-group-justified">
Facebook <a href="#" class="btn btn-danger">
Google
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
php code
<?php
$conn=mysqli_connect("localhost","root","","internship");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if(isset($_POST['buttonsubmit'])){
$username=$_POST['username2'];
$password=$_POST['pwd2'];
$type=$_POST['utype'];
$result=mysqli_query($conn,'select * from registration where username="'.$username.'" and password="'.$password.'" and usertype="'.$type.'"');
if(mysqli_num_rows($result)==1 && $type=="Student"){
header('Location: student.php');
}
else
?>
<script> alert("Account invalid!!!! Enter valid Username Password and Usertype")</script>
<?php
}
?>
<?php
$conn=mysqli_connect("localhost","root","","internship");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if(isset($_POST['buttonsubmit'])){
$username=$_POST['username2'];
$password=$_POST['pwd2'];
$type=$_POST['utype'];
$result=mysqli_query($conn,'select * from registration where username="'.$username.'" and password="'.$password.'" and usertype="'.$type.'"');
if(mysqli_num_rows($result)==1 && $type=="Student"){
session_start();
$_SESSION['user'] = $result;
header('Location: student.php');
}
else
?>
<script> alert("Account invalid!!!! Enter valid Username Password and Usertype")</script>
<?php
}
Can you post the error that you are getting...?
Plus Your code is not secure. You should use php's hash functions to match passwords and use must use PDO to avoid sql injection.
I'm working on a page for editing user profiles but I want the page am working on to submit to itself when it is submitted and show a message that the profile has been edited successfully. Please how do I do this ?
Here is what am working ?
<div class="row">
<div class="text-center title">Pricing</div>
<div class="text-center desc col-md-8 col-md-push-2">
{{$sitename}}
</div>
<div class="container" style="padding-top: 60px;">
<h1 class="page-header">Edit Profile</h1>
<div class="row">
<!-- left column -->
<form class="form-horizontal" role="form" method="post" action="/profile">
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="text-center">
<img id="ShowImage" src="#"/>
<img src="http://localhost:8234/img/index.png" class="avatar img-circle img-thumbnail" alt="avatar" width="200" height="200">
<h6>Upload a different photo...</h6>
<input type="file" class="text-center center-block well well-sm" name="avatar_path" id="avatar_path" onchange="readURL(this);">
</div>
</div>
<!-- edit form column -->
<div class="col-md-8 col-sm-6 col-xs-12 personal-info">
<div class="alert alert-info alert-dismissable">
<a class="panel-close close" data-dismiss="alert">×</a>
<i class="fa fa-coffee"></i>
This is the <strong>Profile Page</strong>. Use this to <strong>ONLY</strong> change your peronsal details
</div>
<h3>Personal info</h3>
<input class="form-control" value="{{$userInfo['data']['id']}}" type="hidden" name="user_id">
<div class="form-group">
<label class="col-lg-3 control-label">First Name:</label>
<div class="col-lg-8">
<input class="form-control" value="{{$userInfo['data']['first_name']}}" type="text" name="first_name">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Last Name:</label>
<div class="col-lg-8">
<input class="form-control" value="{{$userInfo['data']['last_name']}}" type="text" name="last_name">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Username:</label>
<div class="col-lg-8">
<input class="form-control" value="{{$userInfo['data']['profile']['username']}}" type="text" name="username">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Email Address:</label>
<div class="col-lg-8">
<input class="form-control" value="{{$userInfo['data']['email']}}" type="text" name="email">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Gender</label>
<div class="col-lg-8">
<div class="ui-select">
<select id="gender" class="form-control" name="gender">
<option value="{{$userInfo['data']['profile']['gender']}}" selected>{{$userInfo['data']['profile']['gender']}}</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
<option value="Other">Other</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">City:</label>
<div class="col-lg-8">
<input class="form-control" value="{{$userInfo['data']['profile']['city']}}" type="text" name="city">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">State:</label>
<div class="col-lg-8">
<input class="form-control" value="{{$userInfo['data']['profile']['state']}}" type="text" name="state">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Country:</label>
<div class="col-lg-8">
<input class="form-control" value="{{$userInfo['data']['profile']['country']}}" type="text" name="country">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Mobile:</label>
<div class="col-lg-8">
<input class="form-control" value="{{$userInfo['data']['profile']['mobile']}}" type="text" name="mobile">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Occupation:</label>
<div class="col-lg-8">
<input class="form-control" value="{{$userInfo['data']['profile']['occupation']}}" type="text" name="occupation">
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label"></label>
<div class="col-md-8">
<input class="bkgrnd-blue text-white btn btn-primary" value="Update Profile" type="submit">
<span></span>
Cancel
</div>
</div>
</form>
</div>
</div>
</div>
This solution came from https://laravel.io/forum/01-30-2015-form-submission-to-the-same-page. Hope it helps
I have done a get route to display the page. I then did route a post to post form data.
Then I passed the $data variable to blade where I did an isset to check if it is created which displays the results
Display initial page
public function destinationSearchGet(){
$headData = array('pageTitle' => 'Admin Home - View all destinations');
return view('admin.destination_search', $headData);
}
post data back to the same page and create a new variable
public function destinationSearchPost(){
$headData = array('pageTitle' => 'Admin Home - Search results');
$formData = Request::input('destination');
$data = ParentRegionList::destinationSearch($formData);
return view('admin.destination_search', $headData)->with(compact('data'))
}
use blade to check if it exists
#if (isset($data))
<p>{{dd($data)}}</p>
#endif
I have four textboxes and when you click on the add one button it will add up another set of textboxes. My problem is how can i pass the json data to the action form. Here is my code:
$("#test").click(function(){
var array = $('.experience').map(function() {
var obj = {};
$(this).next().addBack().find('input:text').each(function() {
obj[this.id] = this.value;
});
return obj;
}).get();
$('#json').text(JSON.stringify(array, null, 2));
});
and my form action
<form action="<?php echo base_url().'resume/update'?>" method="post" id="send_form">
<!-- Experience Start -->
<div class="row">
<div class="col-sm-12">
<p> </p>
<h2>Experience</h2>
</div>
</div>
<div class="row experience">
<div class="col-sm-6">
<div class="form-group">
<label for="resume-employer">Employer</label>
<input type="text" class="form-control" name="resumeEmployer" id="resume-employer" value="<?php echo set_value('resumeEmployer'); ?>" id="resume-employer" placeholder="Company name">
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label for="resume-experience-dates">Start/End Date</label>
<input type="text" class="form-control" name="resumeExperienceDates" name="<?php echo set_value('resumeExperienceDates'); ?>" id="resume-experience-dates" placeholder="e.g. April 2010 - June 2013">
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label for="resume-job-title">Job Title</label>
<input type="text" class="form-control" name="resumeJobTitle" id="resume-job-title" value="<?php echo set_value('resumeJobTitle'); ?>" placeholder="e.g. Web Designer">
</div>
</div>
<div class="col-sm-6">
<div class="form-group" id="resume-responsibilities-group">
<label for="resume-responsibilities">Responsibilities (Optional)</label>
<input type="text" class="form-control" name="resumeResponsibilities" id="resume-responsibilities" value="<?php echo set_value('resumeResponsibilities');?>" placeholder="e.g. Developing new websites">
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<hr class="dashed">
</div>
</div>
<div class="row">
<div class="col-sm-12">
<p><a id="add-experience">+ Add Experience</a></p>
<hr>
</div>
</div>
<!-- Experience Start -->
<div class="row text-center">
<div class="col-sm-12">
<p> </p>
<input type="submit" id="test" class="btn btn-primary btn-lg" value="Submit" />
</div>
</div>
</form>
i added a id="test" in the input type="submit button
any help is muchly appreciated. TIA
Use json_encode and json_decode function example in ref link,
json_encode($arr);
var_dump(json_decode($json));
http://php.net/manual/en/function.json-encode.php
var_dump(json_decode($json, true));