If statement within PHP template in wordpress - php

With a WordPress PHP template - I what doing an if statement to check if user is logged in, if he is then I want to show an email form and if he's not I want to ask users to login.
<?php if ( is_user_logged_in() ) {
<div role="tabpanel" class="tab-panel active" id="nomessage">
<div class="row">
<div class="col-lg-12">
<h4>You have to be logged in to send a message</h4>
</div>
</div>
</div>
} else {
<div class="tab-content">
<?php if($classieraToAuthor == 1){?>
<div role="tabpanel" class="tab-pane active" id="message">
<!--ShownMessage-->
<?php if(isset($_POST['submit']) && $_POST['submit'] == 'send_message'){?>
<div class="row">
<div class="col-lg-12">
<?php if($hasError == true){ ?>
<div class="alert alert-warning">
<?php echo $errorMessage; ?>
</div>
<?php } ?>
<?php if($emailSent == true){ ?>
<div class="alert alert-success">
<?php echo $classieraContactThankyou; ?>
</div>
<?php } ?>
</div>
</div>
<?php } ?>
<!--ShownMessage-->
<form method="post" class="form-horizontal" data-toggle="validator" name="contactForm" action="<?php the_permalink(); ?>">
<div class="form-group">
<label class="col-sm-3 control-label" for="name"><?php esc_html_e('Name', 'classiera') ?> :</label>
<div class="col-sm-9">
<input id="name" data-minlength="5" type="text" class="form-control form-control-xs" name="contactName" placeholder="<?php esc_html_e('Type your name', 'classiera') ?>" required>
</div>
</div><!--name-->
<div class="form-group">
<label class="col-sm-3 control-label" for="email"><?php esc_html_e('Email', 'classiera') ?> :</label>
<div class="col-sm-9">
<input id="email" type="email" class="form-control form-control-xs" name="email" placeholder="<?php esc_html_e('Type your email', 'classiera') ?>" required>
</div>
</div><!--Email-->
<div class="form-group">
<label class="col-sm-3 control-label" for="subject"><?php esc_html_e('Subject', 'classiera') ?> :</label>
<div class="col-sm-9">
<input id="subject" type="text" class="form-control form-control-xs" name="subject" placeholder="<?php esc_html_e('Type your subject', 'classiera') ?>" required>
</div>
</div><!--Subject-->
<div class="form-group">
<label class="col-sm-3 control-label" for="msg"><?php esc_html_e('Message', 'classiera') ?> :</label>
<div class="col-sm-9">
<textarea id="msg" name="comments" class="form-control" placeholder="<?php esc_html_e('Type Message', 'classiera') ?>" required></textarea>
</div>
</div><!--Message-->
<?php
$classieraFirstNumber = rand(1,9);
$classieraLastNumber = rand(1,9);
$classieraNumberAnswer = $classieraFirstNumber + $classieraLastNumber;
?>
<div class="form-group">
<div class="col-sm-9">
<p>
<?php esc_html_e("Please input the result of ", "classiera"); ?>
<?php echo $classieraFirstNumber; ?> + <?php echo $classieraLastNumber;?> =
</p>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="humanTest"><?php esc_html_e('Answer', 'classiera') ?> :</label>
<div class="col-sm-9">
<input id="humanTest" type="text" class="form-control form-control-xs" name="humanTest" placeholder="<?php esc_html_e('Your answer', 'classiera') ?>" required>
<input type="hidden" name="humanAnswer" id="humanAnswer" value="<?php echo $classieraNumberAnswer; ?>" />
<input type="hidden" name="classiera_post_title" id="classiera_post_title" value="<?php the_title(); ?>" />
<input type="hidden" name="classiera_post_url" id="classiera_post_url" value="<?php the_permalink(); ?>" />
</div>
</div><!--answer-->
<input type="hidden" name="submit" value="send_message" />
<button class="btn btn-primary btn-block btn-sm sharp btn-style-one" name="send_message" value="send_message" type="submit"><?php esc_html_e( 'Send Message', 'classiera' ); ?></button>
</form>
</div>
};
?>
First, I have added an if statement to check whether the user is logged in or not, if he is the first element is shown where is tells the user it has to be logged in to send a message. Then, if he is logged in a message form is shown instead.
Cannot get it to work, would appreciate all help a lot! Thanks in advance!

You couldn't mix PHP and HTML like this. You're missing to close PHP tag ?> before to write HTML.
EDIT As pointed by #mmm, your test is the inverse of what you want. You have to negate your test using the character !.
Try this :
<?php if ( ! is_user_logged_in() ) : ?>
<div role="tabpanel" class="tab-panel active" id="nomessage">
<div class="row">
<div class="col-lg-12">
<h4>You have to be logged in to send a message</h4>
</div>
</div>
</div>
<?php else: ?>
<!-- other HTML -->
<?php endif; ?>
Or :
<?php if ( is_user_logged_in() ) { ?>
<div role="tabpanel" class="tab-panel active" id="nomessage">
<div class="row">
<div class="col-lg-12">
<h4>You have to be logged in to send a message</h4>
</div>
</div>
</div>
<?php } else { ?>
<!-- other HTML -->
<?php } ?>

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>

The temporary folder is missing in codeigniter

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 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)){

Blank Page or Empty Page when seeing update.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["epresentaddress"] );
$drivinglicense=mysqli_real_escape_string($link,$_POST["edrivinglicense"]);
if(mysqli_query("UPDATE hrmsinfo SET emp_name=$name,emp_email=$email,emp_password=$enpassword,emp‌​_dob=$dateofbirth,em‌​p_phno=$mobile,emp_a‌​ddress=$presentaddress,emp_proof=$drivin‌​glicense WHERE emp_id='$id'")){
$msg="Successfully Updated!!";
header('Location:VIEW.php');
}
else{
$msg="Unsucessfull!!";
}
}
} //update ends here
?>
When ever i try to execute this update code with following edit code it displays blank page help me with it
The below is edit code which executes perfectly but update doesnt work at all help me where am i stuck
<?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($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>
<form action="UPDATE.php" method="post" name="insertform">
<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>
<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>
<div class="form-group">
<div class="row">
<div class="col-xs-3">Password:</div>
<div class="col-xs-3"><input type="password" class="form-control" name="epassword" id="inputid" placeholder="Enter Password" id='input_id'></div>
<div class="col-xs-3"><input type="password" class="form-control" name="epassword" id="inputid" placeholder="Re-Enter Password" id='input_id'></div>
<div class="col-xs-3">
<div class="checkbox"><input type="checkbox"> Auto Generate</div>
</div>
</div>
</div>
<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>
<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>
<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>
<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>
<div class="form-group">
<div class="row">
<div class="col-xs-3"></div>
<div class="col-xs-5">
<input type="submit" name="update" value="Update" id="inputid1" />
</div>
</div>
</div>
</form>
</div>
<?php } } ?>
Please help me with proper guidance where am i stuck here or i am making mistake
as per your code you put one condition i.e.
if(isset($_GET['id']))
{
.....
}
but in html form you are not pass any id field add id field and try your condition will verify and update will work.
just add one field like below.. remaining is same.
<form action="UPDATE.php?id=<?php echo $id; ?>" method="post" name="insertform">
<input type="hidden" name="id" value="<?php echo $id; ?>" >
...............
.................
</form>
Note: In HTML page id of field should be unique.

Datetimepicker in form not transferring date

At the backend of my opencart e-commerce package, there is the possibility to insert vouchers for customers. However, there is standard no possibility to set a start and end date (1 year later) for the voucher. Therefore I have adapted the voucher.tpl template to include this possibility. I have implemented this completely identical as for the coupon.tpl where there is the possibility to enter a start date and end date.
The input field for the start date and end date is using the datetimepicker script. The datepicker is showing up correctly when I click the calendar button (see image 1) and the date is showing up.
The dates are used in a form, but unfortunately the data seem not be transferred with the form when the save button is clicked. I see no difference with the coupon.tpl page where everything is working properly. I spent already many hours in founding the error but did not succeed yet. Could somebody help me on my way?
Thanks,
SabKo
The voucher.tpl has the following code:
<div id="content">
<div class="page-header">
<div class="container-fluid">
<div class="pull-right">
<button type="submit" form="form-voucher" data-toggle="tooltip" title="<?php echo $button_save; ?>" class="btn btn-primary"><i class="fa fa-save"></i></button>
<i class="fa fa-reply"></i>
</div>
<h1><?php echo $heading_title; ?></h1>
<ul class="breadcrumb">
<?php foreach ($breadcrumbs as $breadcrumb) { ?>
<li><?php echo $breadcrumb['text']; ?></li>
<?php } ?>
</ul>
</div>
</div>
<div class="container-fluid">
<?php if ($error_warning) { ?>
<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?php echo $error_warning; ?>
<button type="button" class="close" data-dismiss="alert">×</button>
</div>
<?php } ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-pencil"></i> <?php echo $text_form; ?></h3>
</div>
<div class="panel-body">
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form-voucher" class="form-horizontal">
<div class="tab-content">
<div class="tab-pane active" id="tab-general">
<div class="form-group required">
<label class="col-sm-2 control-label" for="input-code"><span data-toggle="tooltip" title="<?php echo $help_code; ?>"><?php echo $entry_code; ?></span>
</label>
<div class="col-sm-10">
<input type="text" name="code" value="<?php echo $code; ?>" placeholder="<?php echo $entry_code; ?>" id="input-code" class="form-control" />
<?php if ($error_code) { ?>
<div class="text-danger"><?php echo $error_code; ?></div>
<?php } ?>
</div>
</div>
<div class="form-group required">
<label class="col-sm-2 control-label" for="input-from-name"><?php echo $entry_from_name; ?>
</label>
<div class="col-sm-10">
<input type="text" name="from_name" value="<?php echo $from_name; ?>" placeholder="<?php echo $entry_from_name; ?>" id="input-from-name" class="form-control" />
<?php if ($error_from_name) { ?>
<div class="text-danger"><?php echo $error_from_name; ?></div>
<?php } ?>
</div>
</div>
<div class="form-group required">
<label class="col-sm-2 control-label" for="input-to-name"><?php echo $entry_to_name; ?></label>
<div class="col-sm-10">
<input type="text" name="to_name" value="<?php echo $to_name; ?>" placeholder="<?php echo $entry_to_name; ?>" id="input-to-name" class="form-control" />
<?php if ($error_to_name) { ?>
<div class="text-danger"><?php echo $error_to_name; ?></div>
<?php } ?>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="input-amount"><?php echo $entry_amount; ?></label>
<div class="col-sm-10">
<input type="text" name="amount" value="<?php echo $amount; ?>" placeholder="<?php echo $entry_amount; ?>" id="input-amount" class="form-control" />
<?php if ($error_amount) { ?>
<div class="text-danger"><?php echo $error_amount; ?></div>
<?php } ?>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="input-date-start"><?php echo $entry_date_start; ?></label>
<div class="col-sm-3">
<div class="input-group date">
<input type="text" name="date_start" value="<?php echo $date_start; ?>" placeholder="<?php echo $entry_date_start; ?>" data-date-format="YYYY-MM-DD" id="input-date-start" class="form-control" />
<span class="input-group-btn">
<button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button>
</span></div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="input-date-end"><?php echo $entry_date_end; ?></label>
<div class="col-sm-3">
<div class="input-group date">
<input type="text" name="date_end" value="<?php echo $date_end; ?>" placeholder="<?php echo $entry_date_end; ?>" data-date-format="YYYY-MM-DD" id="input-date-end" class="form-control" />
<span class="input-group-btn">
<button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button>
</span></div>
</div>
</div>
<?php if ($voucher_id) { ?>
<div class="tab-pane" id="tab-history">
<div id="history"></div>
</div>
<?php } ?>
</div>
</form>
</div>
</div>
</div>
<script type="text/javascript"><!--
$('.date').datetimepicker({
pickTime: false
});
//--></script>
</div>
The controller page has the following code, so should be able to read the input of the dates:
if (isset($this->request->post['date_start'])) {
$data['date_start'] = $this->request->post['date_start'];
} elseif (!empty($voucher_info)) {
$data['date_start'] = ($voucher_info['date_start'] != '0000-00-00' ? $voucher_info['date_start'] : '');
} else {
$data['date_start'] = date('Y-m-d', time());
}
if (isset($this->request->post['date_end'])) {
$data['date_end'] = $this->request->post['date_end'];
} elseif (!empty($voucher_info)) {
$data['date_end'] = ($voucher_info['date_end'] != '0000-00-00' ? $voucher_info['date_end'] : '');
} else {
$data['date_end'] = date('Y-m-d', strtotime('+1 month'));
}
You're initialize your datetime picker on div with class .date but you have to initialize it on inputs with their classes or ids.
replace this code:
<script type="text/javascript"><!--
$('.date').datetimepicker({
pickTime: false
});
//--></script>
with this one:
<script type="text/javascript"><!--
$('#input-date-start').datetimepicker({
pickTime: false
});
$('#input-date-end').datetimepicker({
pickTime: false
});
//--></script>

Categories