The temporary folder is missing in codeigniter - php

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

Related

codeigniter profile page edit

I want to make a profile page edit for my project. I try something to profile page. But I gave an error.
How can I do profile page ? The error is:
An uncaught Exception was encountered
Type: ArgumentCountError
Message: Too few arguments to function CProfile_edit::update(), 0 passed in C:\xampp\htdocs\erp\system\core\CodeIgniter.php on line 532 and exactly 1 expected
Filename: C:\xampp\htdocs\erp\application\controllers\CProfile_edit.php
Line Number: 14
Backtrace:
File: C:\xampp\htdocs\erp\index.php
Line: 315
Function: require_once
I gave it always. I use session data for take data from customer table. But I can not profile edit. I take this error.
This is my view:
<section class="panel">
<div class="bio-graph-heading">
<?php echo $this->lang->line('profile_edit_top_text'); ?>
</div>
<div class="panel-body bio-graph-info">
<h1> <?php echo $this->lang->line('profile_edit_text_informations'); ?></h1>
<form class="form-horizontal" role="form" method="post" action="<?php echo base_url("CProfile_edit/update/$user->cosId"); ?>">
<!-- Form -->
<div class="form-group">
<label class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_username'); ?></label>
<div class="col-lg-6">
<input type="text" class="form-control" id="f-name" name="cosUserName" placeholder="<?php echo $this->session->userdata('people_username'); ?>" />
</div>
</div>
<!-- Form -->
<div class="form-group">
<label class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_email'); ?></label>
<div class="col-lg-6">
<input type="email" class="form-control" id="email" name="cosEmail" placeholder="<?php echo $this->session->userdata('people_email'); ?>" />
</div>
</div>
<!-- Form -->
<div class="form-group">
<label class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_firstname'); ?></label>
<div class="col-lg-6">
<input type="text" class="form-control" id="f-name" name="cosName" placeholder="<?php echo $this->session->userdata('people_username'); ?>" />
</div>
</div>
<!-- Form -->
<div class="form-group">
<label class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_lastname'); ?></label>
<div class="col-lg-6">
<input type="text" class="form-control" id="l-name" name="cosSurname" placeholder="<?php echo $this->session->userdata('people_surname'); ?>" />
</div>
</div>
<!-- Form -->
<div class="form-group">
<label class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_phone'); ?></label>
<div class="col-lg-6">
<input type="text" class="form-control" id="f-name" name="cosPho" placeholder="<?php echo $this->session->userdata('people_phone'); ?>" />
</div>
</div>
<!-- Form -->
<div class="form-group">
<label class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_mobile'); ?></label>
<div class="col-lg-6">
<input type="text" class="form-control" id="f-name" name="cosGsm" placeholder="<?php echo $this->session->userdata('people_mobile'); ?>" />
</div>
</div>
<!-- Basic select -->
<div class="form-group">
<label class="control-label col-lg-3"><?php echo $this->lang->line('cprofile_profile_lang'); ?> <span class="text-danger">*</span></label>
<div class="col-lg-9">
<select name="cosLang" class="form-control">
<option value="<?php echo $this->session->userdata('people_lang'); ?>"><?php echo $this->session->userdata('people_lang'); ?></option>
<option value="en">English</option>
<option value="ar">Arabic</option>
</select>
</div>
</div>
<!-- /basic select -->
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<button type="submit" class="btn btn-success">Save</button>
<button type="button" class="btn btn-default">Cancel</button>
</div>
</div>
</form>
</div>
</section>
There is my controller:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class CProfile_edit extends CI_Controller {
public function index()
{
//redirect(base_url('calendar'));
$this->lang->load('content', $this->session->userdata('people_lang'));
$this->load->view('cprofile_edit');
}
public function update($cusId = 1)
{
if (! empty($cusId))
{
$data = array (
"cosUserName" => $this->input->post("cosUserName"),
"cosEmail" => $this->input->post("cosEmail"),
"cosName" => $this->input->post("cosName"),
"cosSurname" => strtoupper($this->input->post("cosSurname")),
"cosPho" => $this->input->post("cosPho"),
"cosGsm" => $this->input->post("cosGsm"),
"cosLang" => $this->input->post("cosLang"),
"cosEditDate" => date('Y-m-d H:i:s')
);
$update = $this->db->where("cusId", $cusId)->update("customer", $data);
if($update)
{
redirect(base_url("cprofile"));
}
else
{
echo "Hata!";
}
}
}
}
?>
Line Number: 14 error: public function update($cusId) {
Edit Your View and use this code.
<section class="panel">
<div class="bio-graph-heading">
<?php echo $this->lang->line('profile_edit_top_text'); ?>
</div>
<div class="panel-body bio-graph-info">
<h1> <?php echo $this->lang->line('profile_edit_text_informations'); ?></h1>
<form class="form-horizontal" role="form" method="post" action="<?php echo base_url("CProfile_edit/update/".$this->session->userdata('people_id')); ?>">
<!-- Form -->
<div class="form-group">
<label class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_username'); ?></label>
<div class="col-lg-6">
<input type="text" class="form-control" id="f-name" name="cosUserName" placeholder="<?php echo $this->session->userdata('people_username'); ?>" />
</div>
</div>
<!-- Form -->
<div class="form-group">
<label class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_email'); ?></label>
<div class="col-lg-6">
<input type="email" class="form-control" id="email" name="cosEmail" placeholder="<?php echo $this->session->userdata('people_email'); ?>" />
</div>
</div>
<!-- Form -->
<div class="form-group">
<label class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_firstname'); ?></label>
<div class="col-lg-6">
<input type="text" class="form-control" id="f-name" name="cosName" placeholder="<?php echo $this->session->userdata('people_username'); ?>" />
</div>
</div>
<!-- Form -->
<div class="form-group">
<label class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_lastname'); ?></label>
<div class="col-lg-6">
<input type="text" class="form-control" id="l-name" name="cosSurname" placeholder="<?php echo $this->session->userdata('people_surname'); ?>" />
</div>
</div>
<!-- Form -->
<div class="form-group">
<label class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_phone'); ?></label>
<div class="col-lg-6">
<input type="text" class="form-control" id="f-name" name="cosPho" placeholder="<?php echo $this->session->userdata('people_phone'); ?>" />
</div>
</div>
<!-- Form -->
<div class="form-group">
<label class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_mobile'); ?></label>
<div class="col-lg-6">
<input type="text" class="form-control" id="f-name" name="cosGsm" placeholder="<?php echo $this->session->userdata('people_mobile'); ?>" />
</div>
</div>
<!-- Basic select -->
<div class="form-group">
<label class="control-label col-lg-3"><?php echo $this->lang->line('cprofile_profile_lang'); ?> <span class="text-danger">*</span></label>
<div class="col-lg-9">
<select name="cosLang" class="form-control">
<option value="<?php echo $this->session->userdata('people_lang'); ?>"><?php echo $this->session->userdata('people_lang'); ?></option>
<option value="en">English</option>
<option value="ar">Arabic</option>
</select>
</div>
</div>
<!-- /basic select -->
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<button type="submit" class="btn btn-success">Save</button>
<button type="button" class="btn btn-default">Cancel</button>
</div>
</div>
</form>
</div>
</section>

I am getting error at this part in EDIT.php and Update.php mysqli_fetch_array() expects parameter 1 to be mysqli_result

EDIT.PHP
<?php
//error_reporting(0);
include("DB.php");
if(isset($_GET['id']))
{
$id=$_GET['id'];
$sql="SELECT * FROM hrmsinfo WHERE emp_id='$id'";
$sqll=mysqli_query($link,$sql);
while($profile=mysqli_fetch_array($link,$sqll))
{
$username=$profile['emp_name'];
$usermail=$profile['emp_email'];
$userdob=$profile['emp_dob'];
$usermobile=$profile['emp_phno'];
$useraddress=$profile['emp_address'];
$userproof=$profile['emp_proof'];
?>
<div class="display">
<form action="UPDATE.php" method="post" name="insertform">
<p>
<div class="form-group">
<div class="row">
<div class="col-xs-3">Name:</div>
<div class="col-xs-4"><input type="text" class="form-control" name="ename" placeholder="Enter Name" value="<?php echo $username; ?>" id="inputid"></div>
</div>
</div>
</p>
<p>
<div class="form-group">
<div class="row">
<div class="col-xs-3">EMAIL:</div>
<div class="col-xs-4"><input type="text" class="form-control" name="eemail" placeholder="Enter Email" value="<?php echo $usermail; ?>" id="inputid"></div>
</div>
</div>
</p>
<p>
<div class="form-group">
<div class="row">
<div class="col-xs-3">Date Of Birth:</div>
<div class="col-xs-5">
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input type="date" class="form-control pull-right" name="edateofbirth" value="<?php echo $userdob; ?>" id="inputid">
</div>
</div>
</div>
</div>
</p>
<p>
<div class="form-group">
<div class="row">
<div class="col-xs-3">Mobile Number:</div>
<div class="col-xs-5">
<input type="text" class="form-control" placeholder="Enter Mobile" name="emobile" value="<?php echo $usermobile; ?>" id="inputid">
</div>
</div>
</div>
</p>
<p>
<div class="form-group">
<div class="row">
<div class="col-xs-3">Address:</div>
<div class="col-xs-5">
<textarea class="form-control" rows="3" placeholder="Enter Address" name="epresentaddress" value="<?php echo $useraddress; ?>" id="inputid"></textarea>
</div>
</div>
</div>
</p>
<p>
<div class="form-group">
<div class="row">
<div class="col-xs-3">Proof:</div>
<div class="col-xs-5">
<input type="text" class="form-control" placeholder="Enter Proof" name="edrivinglicense" value="<?php echo $userproof; ?>" id="inputid">
</div>
</div>
</div>
</p>
<p>
<div class="form-group">
<div class="row">
<div class="col-xs-3"></div>
<div class="col-xs-5">
<input type="submit" name="eupdate" value="Update" id="inputid1" />
</div>
</div>
</div>
</p>
</form>
</div>
<?php } } ?>
UPDATE.PHP
<?php
include('DB.php');
if(isset($_GET['id']))
{
$id=$_GET['id'];
if(isset($_POST['update']))
{
$name=mysqli_real_escape_string($link,$_POST["ename"]);
$email=mysqli_real_escape_string($link,$_POST["eemail"]);
$enpassword=mysqli_real_escape_string($link,$_POST["epassword"]);
$dateofbirth=mysqli_real_escape_string($link,$_POST["edateofbirth"]);
$mobile=mysqli_real_escape_string($link,$_POST["emobile"]);
$presentaddress=mysqli_real_escape_string($link,$_POST["eaddress"]);
$drivinglicense=mysqli_real_escape_string($link,$_POST["edrivinglicense"]);
$updated=mysqli_query("UPDATE `hrmsinfo` SET `emp_name`=[$name],`emp_email`=[$email],`emp_password`=[$enpassword],`emp_dob`=[$dateofbirth],`emp_phno`=[$mobile],`emp_address`=[$presentaddress],`emp_proof`=[$drivinglicense] WHERE emp_id='$id'");
if($result = mysqli_query($link, $updated))
{
$msg="Successfully Updated!!";
header('Location:VIEW.php');
}
else
{
$msg="Unsucessfull!!";
}
}
} //update ends here
?>
MY code keeps popping me error like this:-
mysqli_fetch_array() expects parameter 1 to be mysqli_result
what is wrong with this where am i wrong when i remove id it works can i get the id as parameter call for edit and update help me with this
this is because of the line:-
while($profile=mysqli_fetch_array($link,$sqll)){
Here you need to pass the Query-result-set object only.
So change it to:-
$sqll=mysqli_query($link,$sql);
while($profile=mysqli_fetch_array($sqll)){

Form autocomplete fields populating incorrectly

I've created a form for a site that I'm developing as follows:
<div class="container contacts__container--02">
<? echo $this->Form->create('Email',array('class'=>'contact-form form','url'=>'/sendemail'));?>
<form class="contact-form form contacts__form--02">
<div class="contacts__form__inputs_box--02">
<div class="row">
<div class="col-md-2">
</div>
<div class="col-md-4 contact_item">
<input
type="text"
placeholder="Your name"
value=""
name="data[Email][fullname]"
class="input input--cloud-border input--white"
minlength="3"
required
>
</div>
<div class="col-md-4 contact_item">
<input
type="text"
required placeholder="Your business"
value="" name="data[Email][business]"
class="input input--cloud-border input--white"
>
</div>
</div>
<div class="row">
<div class="col-md-2">
</div>
<div class="col-md-4 contact_item">
<input
type="email"
required placeholder="Your email"
value=""
name="data[Email][email]"
class="input input--cloud-border input--white"
required
>
</div>
<div class="col-md-4 contact_item">
<input
type="text"
placeholder="Your phone"
value=""
name="data[Email][phone]"
class="input input--cloud-border input--white"
>
</div>
</div>
<div class="row">
<div class="col-md-2">
</div>
<div class="col-md-4 contact_item">
<input
type="email"
required placeholder="Your website"
value="" name="data[Email][website]"
class="input input--cloud-border input--white"
>
</div>
<div class="col-md-4 contact_item">
<input
type="text"
placeholder="How did you hear about us?"
value="" name="data[Email][referer]"
class="input input--cloud-border input--white"
>
</div>
</div>
<div class="row">
<div class="col-md-2">
</div>
<div class="col-md-8 contact_item">
<textarea
required placeholder="Your message"
value="" name="data[Email][message]"
class="contacts__form_textarea--02 input input--cloud-border input--white"
></textarea>
</div>
</div>
<div class="row submit_row">
<div class="col-md-2">
</div>
<div class="col-md-8 submit_button">
<div class="g-recaptcha" data-sitekey="<?php echo $siteKey ?>"></div>
</div>
</div>
<div class="row submit_row">
<div class="col-md-2">
</div>
<div class="col-md-8 contact_item">
<a id="sendForm" class="contacts__form_button--02 button button--yellow button--small-radius">send</a>
</div>
</div>
<div class="row">
<div class="col-md-2">
</div>
<div class="col-md-8 contact_item">
<div id="response">
</div>
</div>
</div>
</form>
<? echo $this->Form->end(); ?>
</div>
</div>
But for some reason when I go to fill the form in all the fields, except for phone number are populated with my email address:
How can I set what autocomplete field should be used?
It was interpreting 'Email' as the field name rather than the form array. Changed to 'ContactForm' and it works fine now:
<? echo $this->Form->create('ContactForm',array('class'=>'contact-form form','url'=>'/sendemail'));?>
<form class="contact-form form contacts__form--02">
<div class="contacts__form__inputs_box--02">
<div class="row">
<div class="col-md-2">
</div>
<div class="col-md-4 contact_item">
<input
type="text"
placeholder="Your name"
value=""
name="data[ContactForm][fullname]"
class="input input--cloud-border input--white"
minlength="3"
required
>
</div>
<div class="col-md-4 contact_item">
<input type="text" required placeholder="Your business" value="" name="data[ContactForm][business]" class="input input--cloud-border input--white">
</div>
</div>
<div class="row">
<div class="col-md-2">
</div>
<div class="col-md-4 contact_item">
<input type="email" required placeholder="Your email" value="" name="data[ContactForm][email]" class="input input--cloud-border input--white">
</div>
<div class="col-md-4 contact_item">
<input type="text" placeholder="Your phone" value="" name="data[ContactForm][phone]" class="input input--cloud-border input--white">
</div>
</div>
<div class="row">
<div class="col-md-2">
</div>
<div class="col-md-8 contact_item">
<textarea required placeholder="Your message" value="" name="data[ContactForm][message]" class="contacts__form_textarea--02 input input--cloud-border input--white"></textarea>
</div>
</div>
<div class="row submit_row">
<div class="col-md-2">
</div>
<div class="col-md-8 submit_button">
<div class="g-recaptcha" data-sitekey="<?php echo $siteKey ?>"></div>
</div>
</div>
<div class="row submit_row">
<div class="col-md-2">
</div>
<div class="col-md-8 contact_item">
<a id="sendForm" class="contacts__form_button--02 button button--yellow button--small-radius">send</a>
</div>
</div>
<div class="row">
<div class="col-md-2">
</div>
<div class="col-md-8 contact_item">
<div id="response">
</div>
</div>
</div>
</form>
<? echo $this->Form->end(); ?>

Retrieving json objects from php and display to textfield

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>

How I can use securimage captcha for form submitted on same page ?

I wan to use securimage captcha for my drupal site,
I have one registration form and and I am submitting that form on same page.
Securimage configuration document says that (here) use session_start() on first line of form processor.
I am having both form and form processor on same page so where should I write session_start()?
This is my code
<form id="user_form" action="" method="post">
<div class="form">
<?php if (isset($errors) && count($errors)>0) : ?>
<ul class="error-list">
<?php foreach ($errors as $e) : ?>
<li><?php echo $e; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<div class="form-section">
<div class="col">
<div class="row">
<label class="two-rows">Select your<br />account type <span>*</span></label>
<select name="uf_user_type" style="width:173px;" class="required">
<option value="">None Selected</option>
<option value="<?php print JOB_SEEKER_ROLE; ?>">Job Seeker</option>
<option value="<?php print MASTER_EMPLOYER_ROLE; ?>">Employer</option>
</select>
<div class="cl"> </div>
<em class="status"></em>
</div>
<div class="row">
<label>First Name <span>*</span></label>
<input type="text" class="field required" name="uf_first_name" />
<div class="cl"> </div>
<em class="status"></em>
</div>
<div class="row">
<label>Last Name <span>*</span></label>
<input type="text" class="field required" name="uf_last_name" />
<div class="cl"> </div>
<em class="status"></em>
</div>
<div class="row">
<label>Email <span>*</span></label>
<input type="text" class="field required email-field" name="uf_mail" />
<div class="cl"> </div>
<em class="status"></em>
</div>
<div class="row">
<div class="cl"> </div>
</div>
<div class="row">
<label class="two-rows">Image <span>*</span></label>
<img id="captcha" src="/sites/all/themes/jobnow/site/securimage/securimage_show.php" alt="CAPTCHA Image" height="45" width="160" style="border:1px solid #b9b9b9"/>
<a href="#" onclick="document.getElementById('captcha').src = '/sites/all/themes/jobnow/site/securimage/securimage_show.php?' + Math.random(); return false">
<img src="/sites/all/themes/jobnow/site/securimage/images/refresh.png" height="30" width="30" alt="Reload Image" onclick="this.blur()" align="bottom" border="0">
</a>
</div>
</div>
<div class="col right-col">
<div class="row">
<label class="two-rows">How did you <br />hear about us? <span>*</span></label>
<select name="uf_hear_about_us" style="width:173px;" class="required">
<option value="">None Selected</option>
<option>Colleague/Friend</option>
<option>Search Engine</option>
<option>LinkedIn</option>
<option>Twitter</option>
<option>Facebook</option>
<option>Advertisement</option>
<option>In The News</option>
<option>Trade Show/Organization</option>
<option>Other</option>
</select>
<div class="cl"> </div>
<em class="status"></em>
</div>
<div class="row">
<p class="hint"><?php echo bfstring('hint_register_password'); ?></p>
<label>Password <span>*</span></label>
<input type="password" class="field required" id="pass1" name="uf_password" />
<div class="cl"> </div>
<em class="status"></em>
</div>
<div class="row">
<label class="two-rows">Confirm <br />Password <span>*</span></label>
<input type="password" class="field required" id="pass2" name="uf_password2" />
<div class="cl"> </div>
<em class="status"></em>
</div>
<div class="row">
<label class="labelBlack">
<input type="checkbox" class="check required" name="uf_terms" value="1" <?php if(isset($_POST['uf_terms']) && $_POST['uf_terms'] == 1) print 'checked'; ?> />
</label>
<p>I accept the Terms of Service.</p>
<div class="cl"> </div>
</div>
<div class="row">
<div class="cl"> </div>
</div>
<div class="row">
<label class="two-rows">What code is<br />in the image?<span>*</span></label>
<input type="text" class="field required" name="captcha_code" size="10" maxlength="6" />
<div class="cl"> </div>
<em class="status"></em>
</div>
</div>
<div class="cl"> </div>
</div>
<div>
</div>
<div class="form-actions">
<span class="required-info"><strong>*</strong> required</span>
<input type="submit" class="form-submit" value="Create Account" />
Cancel
<div class="cl"> </div>
</div>
</div>
</form>
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$securimage = new Securimage();
$isSecurImageValid=$securimage->check($_POST['captcha_code']) != false;
if ($validator->validateRules($_POST) && $isSecurImageValid)
{
$new_user = new stdClass();
$new_user->roles = array();
$username_base =strtolower(preg_replace('~(.*)\#.*~', '$1', site_rgpc($_POST['uf_mail'])));
$usernames = array();
}
else
{
$errors = $validator->getErrors();
if(!$isSecurImageValid)
$errors[]="The Security Code wasn't entered correctly.";
}
When I integrated this code on my site its saying your captcha is wrong for each and every attempt.
I am not getting what is the issue ?
Same code is working without session_start() on my another similar site.
Please help me

Categories