Blank Page or Empty Page when seeing update.php - 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.

Related

Adding an additional field breaks my query

When I add an additional field to my query, it fails. I have checked the spelling 20 or more times....I do not know what is wrong.. Please help!!
Working code BELOW
if(isset($_POST['UPDATE_RAW'])) {
extract($_POST);
$sql=mysqli_query($db,"update nma_raw set NMA_System='$nmasystem',NMA_Ticket_Number='$nmaticketnum',Tkt_Priority='$tktpriority',Created_On_Worklist='$createdonworklist',Create_Date='$createdate',Create_Time='$createtime',Days_Old='$daysold',Interval_Onlist='$intervalonlist',Check_Status='$checkstatus',Ticket_Status='$ticketstatus',Relate_Status='$relatestatus',WFA_TR_Num='$wfatrnum',Recent_WFA_Dispatch_Status='$recentwfadispatchstatus',Last_Owner='$lastowner',Entity_Status='$entitystatus',Entity='$entity',First_Cond_Type='$firstcondtype',Last_Cond_Type='$lastcondtype',State='$st',CLLI='$clli',Check_Active='$checkactive',Check_Jepd='$checkjepd' WHERE ID='$id'");
if($sql) {
echo "<script>alert('Updated SuccessFully');window.location.href='Active_Tkt_Qry_List_Frm_NMA.php';</script>";
}
else {
echo "<script>alert('Some ERRORS');</script>";
}
}
NOT WORKING CODE BELOW!
if(isset($_POST['UPDATE_RAW'])) {
extract($_POST);
$sql = mysqli_query($db,"update nma_raw set NMA_System='$nmasystem',NMA_Ticket_Number='$nmaticketnum',Tkt_Priority='$tktpriority',Created_On_Worklist='$createdonworklist',Create_Date='$createdate',Create_Time='$createtime',Days_Old='$daysold',Interval_Onlist='$intervalonlist',Check_Status='$checkstatus',Ticket_Status='$ticketstatus',Relate_Status='$relatestatus',WFA_TR_Num='$wfatrnum',Recent_WFA_Dispatch_Status='$recentwfadispatchstatus',Last_Owner='$lastowner',Entity_Status='$entitystatus',Entity='$entity',First_Cond_Type='$firstcondtype',Last_Cond_Type='$lastcondtype',State='$st',CLLI='$clli',Check_Active='$checkactive',Check_Jepd='$checkjepd', Resolved_Date='$resolved_date' WHERE ID='$id'");
if($sql) {
echo "<script>alert('Updated SuccessFully');window.location.href='Active_Tkt_Qry_List_Frm_NMA.php';</script>";
}
else {
echo "<script>alert('Some ERRORS');</script>";
}
}
HERE IS A PICTURE OF MY DB SCHEMA
enter image description here
HERE IS THE TOTAL PHP FILE
<?php include_once "header.php";?>
<section class="content">
<div class="page-body clearfix">
<?php
$id=$_REQUEST['id'];
$sql=mysqli_query($db,"SELECT NMA_RAW.*, NMA_RAW.Check_Status, NMA_RAW.Resolved_Date, NMA_RAW.Filtered_Date FROM NMA_RAW WHERE (((NMA_RAW.Check_Status)='OK') AND ((NMA_RAW.Resolved_Date) Is Null) AND ((NMA_RAW.Filtered_Date) Is Null)) AND NMA_RAW.ID = $id;");
$row = mysqli_fetch_array($sql);
?>
<div class="panel panel-default">
<div class="panel-heading">NMA Active Ticket Form</div>
<div class="panel-body">
<form class="form-horizontal" action="" method="post">
<div class="form-group">
<div class="col-sm-4">
<label>NMA System</label>
<input type="text" id="nma_system" class="form-control" placeholder="NMA System" value="<?= $row['NMA_System']; ?>" name="nmasystem">
</div>
<div class="col-sm-4">
<label>NMA Ticket Number</label>
<input type="text" id="nma_ticket_number" class="form-control" placeholder="NMA Ticket Number" value="<?= $row['NMA_Ticket_Number']; ?>" name="nmaticketnum">
</div>
<div class="col-sm-4">
<label>Ticket Priority</label>
<input type="text" id="ticket_priority" class="form-control" placeholder="Ticket Priority" value="<?= $row['Tkt_Priority']; ?>" name="tktpriority">
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<label>Created On Worklist</label>
<input type="text" id="created_on_work_list" class="form-control" placeholder="Created On Worklist" value="<?= $row['Created_On_Worklist']; ?>" name="createdonworklist">
</div>
<div class="col-sm-4">
<label>Created Date</label>
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-calendar"></i>
</span>
<input type="date" id="created_date" class="form-control" placeholder="Created Date" value="<?= $row['Create_Date']; ?>" name="createdate">
</div>
</div>
<div class="col-sm-4">
<label>Created time</label>
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-calendar"></i>
</span>
<input type="time" id="created_time" class="form-control" placeholder="Created Time" value="<?= $row['Create_Time']; ?>" name="createtime">
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<label>Days Old</label>
<input type="text" id="days_old" class="form-control" placeholder="Days old" value="<?= $row['Days_Old']; ?>" name="daysold">
</div>
<div class="col-sm-4">
<label>Check</label>
<input type="text" id="check" class="form-control" placeholder="Check" value="<?= $row['Check_Status']; ?>" name="checkstatus">
</div>
<div class="col-sm-4">
<label>Ticket Status</label>
<input type="text" id="ticket_status" class="form-control" placeholder="Ticket Status" value="<?= $row['Ticket_Status']; ?>" name="ticketstatus">
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<label>Interval</label>
<input type="text" id="interval" class="form-control" placeholder="Interval" value="<?= $row['Interval_Onlist']; ?>" name="intervalonlist">
</div>
<div class="col-sm-4">
<label>Related Status</label>
<input type="text" id="relate_status" class="form-control" placeholder="Relate Status" value="<?= $row['Relate_Status']; ?>" name="relatestatus">
</div>
<div class="col-sm-4">
<label>WFA TR Num</label>
<input type="text" id="wfa_tr_num" class="form-control" placeholder="WF TR Num" value="<?= $row['WFA_TR_Num']; ?>" name="wfatrnum">
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<label>Recent WFA Dispatch Status</label>
<input type="text" id="recent_wfa_dispatch_status" class="form-control" placeholder="Recent WFA Dispatch Status"
value="<?= $row['Recent_WFA_Dispatch_Status']; ?>" name="recentwfadispatchstatus">
</div>
<div class="col-sm-4">
<label>Entity Status</label>
<input type="text" id="entity_status" class="form-control" placeholder="Intity Status" value="<?= $row['Entity_Status']; ?>" name="entitystatus">
</div>
<div class="col-sm-4">
<label>Entity</label>
<input type="text" name="entity" id="entity" class="form-control" placeholder="Entity" value="<?= $row['Entity']; ?>" name="entity">
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<label>Last Owner</label>
<input type="text" id="last_owner" class="form-control" placeholder="Last Owner" value="<?= $row['Last_Owner']; ?>" name="lastowner">
</div>
<div class="col-sm-4">
<label>First Cond Type</label>
<input type="text" id="first_cond_type" class="form-control" placeholder="First Cond Type" value="<?= $row['First_Cond_Type']; ?>" name="firstcondtype">
</div>
<div class="col-sm-4">
<label>Last Cond Type</label>
<input type="text" id="last_cond_type" class="form-control" placeholder="Last Cond Type" value="<?= $row['Last_Cond_Type']; ?>" name="lastcondtype">
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<label>State</label>
<input type="text" id="state" class="form-control" placeholder="State" value="<?= $row['State']; ?>" name="st">
</div>
<div class="col-sm-4">
<label>Check Active</label>
<input type="text" id="check_active" class="form-control" placeholder="Check Active" value="<?= $row['Check_Active']; ?>" name="checkactive">
</div>
<div class="col-sm-4">
<label>Check Jepd</label>
<input type="text" name="check_jepd" id="check_jepd" class="form-control"placeholder="Check Jepd" value="<?= $row['Check_Jepd']; ?>" name="checkjepd">
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<label>CLLI</label>
<input type="text" id="clli" class="form-control" placeholder="CLLI" value="<?= $row['CLLI']; ?>" name="clli">
</div>
<div class="col-sm-4">
<label>Resolved Date</label>
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-calendar"></i>
</span>
<input type="date" id="resolved_date" class="form-control" placeholder="Resolved_Date" value="<?= $row['Resolved_Date']; ?>" name="resolved_date">
</div>
</div>
<div class="col-sm-4">
<label>Filtered Date</label>
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-calendar"></i>
</span>
<input type="date" id="filtered_date" class="form-control" placeholder="Filtered Date" value="<?= $row['Filtered_Date']; ?>" name="filtereddate">
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<label>Filtered By</label>
<input type="text" id="filtered_by" class="form-control" placeholder="Filtered by" value="<?= $row['Filtered_By']; ?>" name="filteredby">
</div>
<div class="col-sm-4">
<label>Restored Date</label>
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-calendar"></i>
</span>
<input type="date" id="restored_date" class="form-control" placeholder="Restored_Date" value="<?= $row['Restored_Date']; ?>" name="restoreddate">
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-4 ">
<label class="text-bold"> NMA Comments subform </label>
</div>
<div class="col-sm-4">
</div>
</div>
<hr>
<div class="form-group">
<?php
$io = mysqli_query($db,"select * from NMA_Comments where NMA_Tkt_Num='$row[NMA_Ticket_Number]'");
$tr=mysqli_fetch_assoc($io);
?>
<div class="col-sm-4">
<label>NMA Ticket Number</label>
<input type="text" name="NMA_Ticket_Number" id="nma_ticket_number" class="form-control" placeholder="NMA Ticket Number" value="<?php echo $tr['NMA_Tkt_Num']; ?>" >
</div>
<div class="col-sm-4">
<label>NMA Notes</label>
<textarea type="text" name="NMA_Notes" id="nma_notes" class="form-control" placeholder="NMA Notes"><?php echo $tr['NMA_Notes']; ?></textarea>
</div>
<div class="col-sm-4">
<label>NMA Note Date</label>
<input type="text" name="NMA_Ticket_Date" id="nma_ticket_number" class="form-control" placeholder="NMA Ticket Number" value="<?php echo $tr['NMA_Note_Date']; ?>">
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<button class="btn btn-primary" name="UPDATE_RAW"> Save and Close</button>
</div>
<div class="col-sm-4">
<button class="btn btn-success" name="MOVE_TO_RESOLVED"> Resolved and Close</button>
</div>
<div class="col-sm-4">
<button class="btn btn-danger" name="MOVE_TO_INHIBITS"> Inhibit and Close</button>
</div>
</div>
</form>
</div>
</div>
</div>
</section>
<?php
if(isset($_POST['UPDATE_RAW'])){
extract($_POST);
//print_r($_POST);
$sql=mysqli_query($db,"update nma_raw set NMA_System='$nmasystem',NMA_Ticket_Number='$nmaticketnum',Tkt_Priority='$tktpriority',Created_On_Worklist='$createdonworklist',Create_Date='$createdate',Create_Time='$createtime',Days_Old='$daysold',Interval_Onlist='$intervalonlist',Check_Status='$checkstatus',Ticket_Status='$ticketstatus',Relate_Status='$relatestatus',WFA_TR_Num='$wfatrnum',Recent_WFA_Dispatch_Status='$recentwfadispatchstatus',Last_Owner='$lastowner',Entity_Status='$entitystatus',Entity='$entity',First_Cond_Type='$firstcondtype',Last_Cond_Type='$lastcondtype',State='$st',CLLI='$clli',Check_Active='$checkactive',Check_Jepd='$checkjepd', Resolved_Date='$resolved_date' WHERE ID='$id'");
if($sql){
echo"<script>alert('Updated SuccessFully');window.location.href='Active_Tkt_Qry_List_Frm_NMA.php';</script>";
}
else{
echo"<script>alert('Some ERRORS');</script>";
}
}
?>
<?php
if(isset($_POST['MOVE_TO_INHIBITS'])){
extract($_POST);
//$print_r($_POSt);
$sql=mysqli_query($db,"INSERT INTO nma_main_table SELECT * FROM nma_raw where ID='$id'");
if($sql){
echo"<script>alert('Updated SuccessFully');window.location.href='Active_Tkt_Qry_List_Frm_NMA.php';</script>";
}
else{
echo"<script>alert('Some ERRORS');</script>";
}
// sql to delete a record
$sql=mysqli_query($db,"DELETE FROM nma_raw WHERE ID='$id'");
if ($sql){
echo "Record Inhibited successfully";
} else {
echo "<script>alert('Error in deletion');</script>";
}
}
?>
<?php
if(isset($_POST['MOVE_TO_RESOLVED'])){
extract($_POST);
//$print_r($_POSt);
$sql=mysqli_query($db,"INSERT INTO nma_main_table SELECT * FROM nma_raw where ID='$id'");
if($sql){
echo"<script>alert('Updated SuccessFully');window.location.href='Active_Tkt_Qry_List_Frm_NMA.php';</script>";
}
else{
echo"<script>alert('Some ERRORS');</script>";
}
// sql to delete a record
$sql=mysqli_query($db,"DELETE FROM nma_raw WHERE ID='$id'");
if ($sql){
echo "Record Resolved successfully";
} else {
echo "<script>alert('Error in deletion');</script>";
}
}
?>
<?php include_once "footer.php";?>
If the error you're getting is Incorrect date value: '' for column 15daytkt.nma_raw.Resolved_Date (as you've mentioned in the comments) :
It looks like you are passing an empty string to the Resolved_Date column, and it's invalid. Please make sure you're actually passing a valid date string in this format 2019-11-15. Usually, the HTML form inputs with the date type return this format.
You can verify this case by setting the value to NULL if it's empty. Try changing the query as below:
$sql = mysqli_query($db,"update nma_raw set NMA_System='$nmasystem', Resolved_Date=NULLIF($resolved_date, '') WHERE ID='$id'");
Note the NULLIF($resolved_date, '') part. It will basically set the value to null if it is empty.
Hope it helps.

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

How to get bootstrap contact form working with php?

I want to add a contact form on my page but I've never worked with PHP before. I need help, please?
I'm working with the form below:
<a name="Contact"></a>
<div class="contact">
<div class="container">
<div class="row">
<div class="col-lg-8">
<h1 class="page-header text-center">Get in touch!</h1>
<form class="form-horizontal" role="form" method="post" action="index.php">
<div class="form-group">
<label for="name" class="col-sm-2 control-label">Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="name" name="name" placeholder="First & Last Name" value="<?php echo htmlspecialchars($_POST['name']); ?>">
<?php echo "<p class='text-danger'>$errName</p>";?>
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="email" name="email" placeholder="example#domain.com" value="<?php echo htmlspecialchars($_POST['email']); ?>">
<?php echo "<p class='text-danger'>$errEmail</p>";?>
</div>
</div>
<div class="form-group">
<label for="message" class="col-sm-2 control-label">Message</label>
<div class="col-sm-10">
<textarea class="form-control" rows="4" name="message"><?php echo htmlspecialchars($_POST['message']);?></textarea>
<?php echo "<p class='text-danger'>$errMessage</p>";?>
</div>
</div>
<div class="form-group">
<label for="human" class="col-sm-2 control-label">2 + 3 = ?</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="human" name="human" placeholder="Your Answer">
<?php echo "<p class='text-danger'>$errHuman</p>";?>
</div>
</div>
<div class="form-group">
<div class="col-sm-10 col-sm-offset-2">
<input id="submit" name="submit" type="submit" value="Send" class="btn btn-primary">
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-sm-offset-2">
<?php echo $result; ?>
</div>
</div>
</form>
</div>
For for some reason, it's not displaying properly. This is how it looks:
screenshot of contact form

How to not allow an error message to occupy space in the DOM if error is not displayed?

I have a simple Login page where I show a error message on failed authentication. I have a div with some classes applied , and inside it I display the error message through a <label.../>.
Now when the page is loaded for the first time, there is obviously no error message and thus there is an blank space left.
What I want is if there is no error message, the div should occupy no space or should be hidden and should only show if there is any text(error message) inside the div.
Here is my HTML :
<form id="login-form" action="authenticate.php" method="post" role="form" style="display: block;">
<div class="form-group">
<input type="text" name="login_email" id="login_email" tabindex="1" class="form-control" placeholder="Email" value="">
</div>
<div class="form-group">
<input type="password" name="login_password" id="login_password" tabindex="2" class="form-control" placeholder="Password">
</div>
<div class="form-group text-center">
<label style="color:red"><?php if(isset($error)) echo $error; ?></label>
</div>
<div class="form-group text-center">
<input type="checkbox" tabindex="3" class="" name="remember" id="remember">
<label for="remember"> Remember Me</label>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<input type="submit" name="login-submit" id="login-submit" tabindex="4" class="form-control btn btn-login" value="Log In">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-lg-12">
<div class="text-center">
Forgot Password?
</div>
</div>
</div>
</div>
</form>
PHP code :
<?php
if(isset($_GET['login_error'])){
if($_GET['login_error']== 'true'){
$error = "Email and/or Password was incorrect! Please try again!";
}
}
?>
Change it so that it calls out all the HTML in the php function. Like this
<?php
if(isset($_GET['login_error'])){
if($_GET['login_error']== 'true'){
$error = '<div class="form-group text-center">';
$error .= '<label style="color:red">Email and/or Password was incorrect! Please try again!</label>';
$error .= '</div>';
}
}
?>
<form id="login-form" action="authenticate.php" method="post" role="form" style="display: block;">
<div class="form-group">
<input type="text" name="login_email" id="login_email" tabindex="1" class="form-control" placeholder="Email" value="">
</div>
<div class="form-group">
<input type="password" name="login_password" id="login_password" tabindex="2" class="form-control" placeholder="Password">
</div>
<!-- ERROR MESSAGE IS HERE -->
<?php if(isset($error)) echo $error; ?>
<div class="form-group text-center">
<input type="checkbox" tabindex="3" class="" name="remember" id="remember">
<label for="remember"> Remember Me</label>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<input type="submit" name="login-submit" id="login-submit" tabindex="4" class="form-control btn btn-login" value="Log In">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-lg-12">
<div class="text-center">
Forgot Password?
</div>
</div>
</div>
</div>
</form>
Change the content of the if statement to include the entire element, like so:
<?php if(isset($error)) { ?>
<div class="form-group text-center">
<label style="color:red"><?php echo $error; ?></label>
</div>
<?php } ?>

Categories