Form issue on my website - php

I'm creating a form and when I save it the chosen value in the forum doesn't appear on the good page.
The goal of this form is to create a specific task for an employee, when the form is validated, the task appear on the employee tasks page.
I modified a part of the form, the "Priority" part, I added a dropdown menu instead of a text area.
Here are the codes:
Form PART.
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="taskPriority"><?php echo $priorityField; ?> <sup><?php echo $reqField; ?></sup></label>
<select name="taskPriority" class="form-control" name="taskPriority" required="" value="<?php echo isset($_POST['taskPriority']) ? $_POST['taskPriority'] : ''; ?>" />
<option value="urgent">URGENT</option>
<option value="important">IMPORTANT</option>
<option value="normal">NORMAL</option>
</select>
</div>
<div class="form-group">
<label for="taskDue"><?php echo $taskDueField; ?> <sup><?php echo $reqField; ?></sup></label>
<input type="text" class="form-control" name="taskDue" id="taskDue" required="" value="<?php echo isset($_POST['taskDue']) ? $_POST['taskDue'] : ''; ?>" />
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="addCal" value="1">
<?php echo $addToCalField; ?>
</label>
</div>
<span class="help-block"><?php echo $addToCalFieldHelp; ?></span>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="taskStatus"><?php echo $statusField; ?> <sup><?php echo $reqField; ?></sup></label>
<input type="text" class="form-control" name="taskStatus" required="" value="<?php echo isset($_POST['taskStatus']) ? $_POST['taskStatus'] : ''; ?>" />
</div>
<div class="form-group">
<label for="taskDesc"><?php echo $taskDescField; ?> <sup><?php echo $reqField; ?></sup></label>
<textarea class="form-control" required="" name="taskDesc" rows="5"><?php echo isset($_POST['taskDesc']) ? $_POST['taskDesc'] : ''; ?></textarea>
</div>
</div>
</div>
Salary Task Page PART:
<tr>
<td data-th="<?php echo $taskTitleField; ?>">
<a href="index.php?page=viewTask&taskId=<?php echo $row['empTaskId']; ?>" data-toggle="tooltip" data-placement="right" title="<?php echo $viewTaskTooltip; ?>">
<?php echo clean($row['taskTitle']); ?>
</a>
</td>
<td data-th="<?php echo $createdByField; ?>"><?php echo clean($row['postedBy']); ?></td>
<td data-th="<?php echo $priorityField; ?>"><?php echo clean($row['taskPriority']); ?></td>
<td data-th="<?php echo $statusField; ?>"><?php echo clean($row['taskStatus']); ?></td>
<td data-th="<?php echo $dateCreatedField; ?>"><?php echo $row['startDate']; ?></td>
<td data-th="<?php echo $dateDueField; ?>"><?php echo $row['dueDate']; ?></td>
<td data-th="<?php echo $actionText; ?>">
<a href="index.php?page=viewTask&taskId=<?php echo $row['empTaskId']; ?>">
<i class="fa fa-edit text-info" data-toggle="tooltip" data-placement="left" title="<?php echo $viewTaskTooltip; ?>"></i>
</a>
<a data-toggle="modal" href="#completeTask<?php echo $row['empTaskId']; ?>">
<i class="fa fa-check-square-o text-success" data-toggle="tooltip" data-placement="left" title="<?php echo $markTaskCmpTooltip; ?>"></i>
</a>
<a data-toggle="modal" href="#deleteTask<?php echo $row['empTaskId']; ?>">
<i class="fa fa-trash-o text-danger" data-toggle="tooltip" data-placement="left" title="<?php echo $deleteTaskTooltip; ?>"></i>
</a>
</td>
</tr>
The problem is that the chosen priority (Urgent, Important or Normal) doesn't appear, like on the photo.
Thank you in advance for your help.

Looks like there is more code involved. Inside the "Task Page" you refer to $row. Where is it defined. I think it's a DB result, perhaps you need to add the new property taskPriority there also.
Same for you DB structure.
It would be helpful if you can provide more information.

Related

open Collapse sidebar with same DB id

I'm currently working on the forum section of my website.
I followed the link #CBroe suggest me on the comments and implemented offcanvas for my previous problem and now I have this:
<table class="table is-indent changes" id="newsTable">
<thead>
<th></th>
<th></th>
</thead>
<tbody>
<?php foreach($fetchNews as $data):
echo '<tr class="trNew btnSelect" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasRight" aria-controls="offcanvasRight" id=\''.$data['id'].'\'>' ?>
<td class="cell-60 responsive-hide" style="width: 100px;">
<img class="author width" src="<?php echo '../../resource/img/users_Initials/' . $data['autore'].'.png' ?>">
</td>
<td id="<?php echo $data['id']; ?>">
<input type="hidden" id="idNew" value="<?php echo $data['id']; ?>" data-value="<?php echo $data['id']; ?>">
<div class="content">
<div class="title" id="title"> <?php echo $data['titolo']; ?> </div>
<div class="metas">
<span class="author"><?php echo $data['autore']; ?> - </span>
<span class="data"><?php echo $data['data']; ?></span>
</div>
</div>
<?php endforeach;?>
</td>
</tr>
</tbody>
</table>
And this is the offcanvas the table below open:
<!--PANEL NEWS-->
<?php foreach($fetchNews as $data):?>
<div class="offcanvas offcanvas-end" tabindex="-1" id="offcanvasRight" aria-labelledby="offcanvasRightLabel">
<div class="offcanvas-header">
<h1 id="newsTitolo"><?php echo $data['titolo']??''; ?></h1>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<div class="forum-header">
<img class="author width" src="<?php echo '../../resource/img/users_Initials/' . $data['autore'].'.png' ?>">
<span class="name"><?php echo $data['autore']??''; ?></span>
<span class="time"><?php echo $data['data']??''; ?></span>
</div>
<div class="forum-content">
<div id="newsTesto" class="articolo">
<?php $Parsedown = new Parsedown();
echo $Parsedown->text(file_get_contents('post/'.$data['titolo'].'/'.$data['titolo'].'.txt')??''); ?>
</div>
<p> <?php echo $data['allegato']??'';?></p>
</div>
</div>
</div>
<?php endforeach;?>
<!--END PANEL NEWS-->
What I basically need to do is display the article with the same ID as the title on the table as this example image: table & panel that by clicking on the first title (ahaaa) it opens the corresponding article.
I tried some stuff like adding $data['id'] on both data-bs-target and data-bs-toggle of the and as id of the offcanvas but it didnt work

How to connect two websites together one website just used php while the other used codeigniter 3

I want to connect my websites together like for example I put a link on my other website to got to the other website, I want it to automatically be logged in as I am still logged in on my other website.
aside.php on my main website:
<li class="nav-item">
<a href="https:localhost/academy_lms/login" target="_blank" class="nav-link <?php if($pageid==19){ echo 'active';}?>">
<i class="nav-icon"><i class="fa fa-book"></i></i>
<p>
ACADEMY
</p>
</a>
</li>
login.php on my other website:
<form action="<?php echo site_url('login/validate_login/user'); ?>" method="post" id="sign_up">
<div class="form-group">
<label for="login-ID"><?php echo site_phrase('AgentID'); ?></label>
<div class="input-group">
<span class="input-group-text bg-white" for="AgentID"><i class="fas fa-user"></i></span>
<input type="number" name="AgentID" class="form-control" placeholder="<?php echo site_phrase('AgentID'); ?>" aria-label="<?php echo site_phrase('AgentID'); ?>" aria-describedby="<?php echo site_phrase('AgentID'); ?>" id="login-ID" required>
</div>
</div>
<div class="form-group">
<label for="login-password"><?php echo site_phrase('password'); ?></label>
<div class="input-group">
<span class="input-group-text bg-white" for="password"><i class="fas fa-lock"></i></span>
<input type="password" name="password" class="form-control" placeholder="<?php echo site_phrase('password'); ?>" aria-label="<?php echo site_phrase('password'); ?>" aria-describedby="<?php echo site_phrase('password'); ?>" id="login-password" required>
</div>
<a class="text-muted text-12px fw-500 float-end" href="<?php echo site_url('home/forgot_password'); ?>"><?php echo site_phrase('forgot_password'); ?>?</a>
</div>
<?php if(get_frontend_settings('recaptcha_status')): ?>
<div class="form-group mt-4 mb-0">
<div class="g-recaptcha" data-sitekey="<?php echo get_frontend_settings('recaptcha_sitekey'); ?>"></div>
</div>
<?php endif; ?>
<div class="form-group">
<button type="submit" class="btn red radius-10 mt-4 w-100"><?php echo site_phrase('login'); ?></button>
</div>
<div class="form-group mt-4 mb-0 text-center">
<?php echo site_phrase('do_not_have_an_account'); ?>?
<a class="text-15px fw-700" style="color: #FD6161" href="<?php echo site_url('home/sign_up') ?>"><?php echo site_phrase('sign_up'); ?></a>
</div>
</form>

passing parameter to modal window with data-target is not working

I have designed one page consisting of one modal window which is opening with tag.
I want to pass some parameters to modal window which i will be using to populate table data based on the parameter value.It is working with one parameter but not working with another parameter.
Following is the HTML to open modal window......
<table id="MyTable1" class="table table-sm table-striped table-lightfont paginated">
<thead class="thead-light">
<tr>
<th><?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","GRP_DESC"); ?></th>
<th><?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","MODULE_NAME"); ?></th>
<th><?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","GMA_ACCESS_FLAG"); ?></th>
<th><?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","OPTIONS"); ?></th>
</tr>
</thead>
<tbody>
<?php
if ($_SESSION['$language']="E") {
$groupdata=SelectData("group_module_access,user_group,modules","gma_id,gma_grp_id,grp_desc,gma_module_id,module_name,gma_access_flag","gma_grp_id=grp_id and gma_module_id=module_id","gma_grp_id,gma_id");
}
else {
$groupdata=SelectData("group_module_access,user_group,modules","gma_id,gma_grp_id,grp_bldesc as grp_desc,gma_module_id,module_blname as module_name,gma_access_flag","gma_grp_id=grp_id and gma_module_id=module_id","gma_grp_id,gma_id");
}
foreach ($groupdata as $groupdatalist) {
//$allids[]=$groupdatalist["gma_id"]; ?>
<tr>
<td><?php echo $groupdatalist["grp_desc"];?></td>
<td><?php echo $groupdatalist["module_name"];?></td>
<?php if($groupdatalist["gma_access_flag"]=="N"):?>
<td style="text-align:right;width:10px;"><input type="checkbox" name="accessflag[]" id="accessflag"
value="<?php echo "{$groupdatalist['gma_id']}"?>"/> </td>
<?php else:?>
<td style="text-align:right;width:10px;"><input type="checkbox" checked name="accessflag[]" id="accessflag" width="10px"
value="<?php echo "{$groupdatalist['gma_id']}"?>"/> </td>
<?php endif;?>
<td style="display:none;"><?php echo $groupdatalist["gma_grp_id"];?></td>
<td style="display:none;"><?php echo $groupdatalist["gma_module_id"];?></td>
<td style="display:none;"><input type="text" name="gmaid" id="gmaid" value="<?php echo $groupdatalist["gma_id"];?>"></td>
<!--<td style="display:none"><input type="text" name="allids[]" value="<//?php echo "{$groupdatalist['gma_id']}"?>"/></td>-->
<td>
<span data-toggle="modal" data-target="#myModal-<?php echo $groupdatalist['gma_id'];?>">
<a href="#" class="btn btn-light btn-sm shadow-none"
data-toggle="tooltip" title="<?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","MENUPERMISSION");?>">
<i class="fa fa-pencil-square-o"></i>
</a>
</span>
</td>
</tr>
<?php } ?>
</tbody>
</table>
Here is the modal window HTML.....
<div id="myModal-<?php echo $groupdatalist['gma_grp_id'];?>" class="modal show fade" data-backdrop="static">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h6 class="modal-title">Menu List</h6>
</div>
<div class="modal-body">
<div class="control-container" style="padding:10px;">
<div class="row">
<div class="col-md-12" style="text-align:center">
<label style="color:red">
<?php //session_start();
if (!empty($_SESSION['$SaveMsg'])) { echo $_SESSION['$SaveMsg']; }
unset($_SESSION['$SaveMsg']);
?>
</label>
</div>
</div>
<div class="row">
<div class="col-md-4">
<label><?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","GRP_DESC"); ?>
</label>
</div>
<div class="col-md-8">
<input class="text-control" type="text" name="grpid" id="grpid"
value="" readonly required maxlength="50" style="width:100%;display:none;" autofocus />
<input class="text-control" type="text" name="grpname" id="grpname"
value="" readonly required maxlength="50" style="width:100%" autofocus />
</div>
</div>
<div class="row">
<div class="col-md-4">
<label><?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","MODULE_NAME"); ?>
</label>
</div>
<div class="col-md-8">
<input class="text-control" type="text" name="moduleid" id="moduleid"
value="" readonly required maxlength="50" style="width:100%;display:none" autofocus />
<input class="text-control" type="text" name="modulename" id="modulename"
value="" readonly required maxlength="50" style="width:100%" autofocus />
</div>
</div>
<?php $gmaid= "<script>document.writeln(gmaid);</script>";
echo $gmaid;?>
<!--table starts here -->
<table id="MyTable2" class="table table-sm table-striped table-lightfont paginated">
<thead class="thead-light">
<tr>
<th><?php echo GetBilingualLabels($_SESSION['$language'],"MENUACCESS","MENUNAME"); ?></th>
<!--<th><//?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","MODULE_NAME"); ?></th>-->
<th><?php echo GetBilingualLabels($_SESSION['$language'],"MENUACCESS","ACCESS_FLAG"); ?></th>
<!--<th><//?php echo GetBilingualLabels($_SESSION['$language'],"MENUACCESS","OPTIONS"); ?></th>-->
</tr>
</thead>
<tbody>
</table>
<!-- table ends here -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">
<i class="fa fa-close"></i>
<?php echo GetBilingualLabels($_SESSION['$language'],"BUTTON","CANCEL"); ?>
</button>
<button type="submit" name="updmenuperm" formnovalidate class="btn btn-primary"> <!--onclick="DispMsg(<//?php echo "'".$_SESSION['AlertMsg']."'";?>)"-->
<i class="fa fa-save"></i>
<?php echo GetBilingualLabels($_SESSION['$language'],"BUTTON","SAVE"); ?>
</button>
</div>
</div>
</div>
</div>
</div>
Above code is working perfectly but if i am using another value as parameter it is not opening the modal window at all.
for ex. if i am using $groupdatalist['gma_id'] which is integer value, it is not opening modal window.
Multiple issues here.
First a </div> is missing at the end.
Then you are defining $groupdatalist in a foreach, but trying to use it outside the loop:
<div id="myModal-<?php echo $groupdatalist['gma_grp_id'];?>" class="modal show fade" data-backdrop="static">
If you want one modal per <td> you have to move your modal into the foreach loop.
Finally, you call the modal using $groupdatalist['gma_id']
<span data-toggle="modal" data-target="#myModal-<?php echo $groupdatalist['gma_id'];?>">
but the modal ID is define using a different variable : $groupdatalist['gma_grp_id']:
<div id="myModal-<?php echo $groupdatalist['gma_grp_id'];?>"

editing php page to insert new value to my table

hey I'm Newbie and want to edit php page and adding some extra code so my problem is
I added new column to my table and I want to send data from new input text to my table to new column
I add the input text and now I wand to insert that data in new column
even I didn't find the insert query to editing it
my code is below
<?php include_once 'asset/admin-ajax.php'; ?>
<?php echo message_box('success'); ?>
<?php echo message_box('error'); ?>
<div class="row">
<div class="col-sm-12">
<div class="wrap-fpanel">
<div class="panel panel-default" data-collapsed="0">
<div class="panel-heading">
<div class="panel-title">
<strong><?php echo $this->language->form_heading()[13] ?></strong>
</div>
</div>
<div class="panel-body">
<form id="form" action="<?php echo base_url() ?>admin/employee/save_employee_award/<?php
if (!empty($award_info->employee_award_id)) {
echo $award_info->employee_award_id;
}
?>" method="post" enctype="multipart/form-data" class="form-horizontal">
<div class="panel_controls">
<div class="form-group" id="border-none">
<label for="field-1" class="col-sm-3 control-label"><?php echo $this->language->from_body()[14][0] ?> <span class="required">*</span></label>
<div class="col-sm-5">
<select name="designations_id" class="form-control" onchange="get_employee_by_designations_id(this.value)">
<option value="">اختر تعيين.....</option>
<?php if (!empty($all_department_info)): foreach ($all_department_info as $dept_name => $v_department_info) : ?>
<?php if (!empty($v_department_info)): ?>
<optgroup label="<?php echo $dept_name; ?>">
<?php foreach ($v_department_info as $designation) : ?>
<option value="<?php echo $designation->designations_id; ?>"
<?php
if (!empty($award_info->designations_id)) {
echo $designation->designations_id == $award_info->designations_id ? 'selected' : '';
}
?>><?php echo $designation->designations ?></option>
<?php endforeach; ?>
</optgroup>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
</select>
</div>
</div>
<div class="form-group" id="border-none">
<label for="field-1" class="col-sm-3 control-label"><?php echo $this->language->from_body()[14][1] ?> <span class="required">*</span></label>
<div class="col-sm-5">
<select name="employee_id" id="employee" class="form-control" >
<option value="">اختر موظف...</option>
<?php if (!empty($employee_info)): ?>
<?php foreach ($employee_info as $v_employee) : ?>
<option value="<?php echo $v_employee->employee_id; ?>"
<?php
if (!empty($award_info->employee_id)) {
echo $v_employee->employee_id == $award_info->employee_id ? 'selected' : '';
}
?>><?php echo $v_employee->first_name . ' ' . $v_employee->last_name ?></option>
<?php endforeach; ?>
<?php endif; ?>
</select>
</div>
</div>
<div class="form-group">
<label for="field-1" class="col-sm-3 control-label"><?php echo $this->language->from_body()[14][2] ?> <span class="required">*</span></label>
<div class="col-sm-5">
<input type="text" name="award_name" class="form-control" value="<?php
if (!empty($award_info->award_name)) {
echo $award_info->award_name;
}
?>" />
</div>
</div>
<div class="form-group">
<label for="field-1" class="col-sm-3 control-label"> new column <span class="required">*</span></label>
<div class="col-sm-5">
<input type="text" name="new_column" class="form-control" value="<?php
if (!empty($award_info->new_column)) {
echo $award_info->new_column;
}
?>" />
</div>
</div>
<div class="form-group">
<label for="field-1" class="col-sm-3 control-label"><?php echo $this->language->from_body()[14][3] ?></label>
<div class="col-sm-5">
<input type="text" name="gift_item" class="form-control" value="<?php
if (!empty($award_info->gift_item)) {
echo $award_info->gift_item;
}
?>" />
</div>
</div>
<div class="form-group">
<label for="field-1" class="col-sm-3 control-label"><?php echo $this->language->from_body()[14][4] ?></label>
<div class="col-sm-5">
<input type="text" name="award_amount" class="form-control" value="<?php
if (!empty($award_info->award_amount)) {
echo $award_info->award_amount;
}
?>" />
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"><?php echo $this->language->from_body()[14][5] ?> <span class="required">*</span></label>
<div class="col-sm-5">
<div class="input-group">
<input type="text" name="award_date" placeholder="ادخل الشهر" class="form-control monthyear" value="<?php
if (!empty($award_info->award_date)) {
echo $award_info->award_date;
}
?>" data-format="dd-mm-yyyy">
<div class="input-group-addon">
<i class="entypo-calendar"></i>
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-5">
<button type="submit" id="sbtn" name="sbtn" value="1" class="btn btn-primary"><?php echo $this->language->from_body()[1][12] ?></button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12" data-offset="0">
<div class="panel panel-default">
<div class="panel-heading">
<div class="panel-title">
<span>
<strong><?php echo $this->language->from_body()[14][6] ?></strong>
</span>
</div>
</div>
<!-- Table -->
<table class="table table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th class="col-sm-1">رقم الموظف</th>
<th>اسم الموظف</th>
<th>اسم المكافئة</th>
<th>بند المكافئة</th>
<th>مبلغ الكافئة</th>
<th>الشهر</th>
<th> : اجراء</th>
</tr>
</thead>
<tbody>
<?php if (!empty($all_employee_award_info)):foreach ($all_employee_award_info as $v_award_info): ?>
<tr>
<td><?php echo $v_award_info->employment_id ?></td>
<td><?php echo $v_award_info->first_name . ' ' . $v_award_info->last_name; ?></td>
<td><?php echo $v_award_info->award_name;?></td>
<td><?php echo $v_award_info->gift_item; ?></td>
<td><?php echo $v_award_info->award_amount;?></td>
<td><?php echo date('F y', strtotime($v_award_info->award_date)) ?></td>
<td>
<?php echo btn_edit('admin/employee/employee_award/' . $v_award_info->employee_award_id . '/' . $v_award_info->designations_id); ?>
<?php echo btn_delete('admin/employee/delete_employee_award/' . $v_award_info->employee_award_id); ?>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
anyone for help please
To check the full path of the file copy paste the code at the top of the file and then you can easily go to the directory where the file is located.
<? echo base_url().'admin/employee/save_employee_award/'; exit; ?>

cant upload file in mysql database using php codeigniter [duplicate]

This question already has answers here:
codeigniter upload file error
(2 answers)
Closed 8 years ago.
I want to upload a file in mysql database using php codeigniter. when I upload a file it don't show any error and file doesn't upload.and the value of column file_name in mysql shows as NULL.
Here is my view code :
<div class="box">
<div class="box-header"><span class="title"><?php echo get_phrase('diagnosis_report');?></span></div>
<div class="box-content">
<table cellpadding="0" cellspacing="0" border="0" class="table table-normal ">
<thead>
<tr>
<td><div>#</div></th>
<td><div><?php echo get_phrase('report_type');?></div></td>
<td><div><?php echo get_phrase('document_type');?></div></td>
<td><div><?php echo get_phrase('download');?></div></td>
<td><div><?php echo get_phrase('description');?></div></td>
<td><div><?php echo get_phrase('date');?></div></td>
<td><div><?php echo get_phrase('laboratorist');?></div></td>
<td><div><?php echo get_phrase('option');?></div></td>
</tr>
</thead>
<tbody>
<?php
$count = 1;
$diagnostic_reports = $this->db->get_where('diagnosis_report' , array('prescription_id' => $prescription_id))->result_array();
foreach($diagnostic_reports as $row2):?>
<tr>
<td><?php echo $count++;?></td>
<td><?php echo $row2['report_type'];?></td>
<td><?php echo $row2['document_type'];?></td>
<td style="text-align:center;">
<?php if($row2['document_type'] == 'image'):?>
<div id="thumbs">
<a href="<?php echo base_url();?>uploads/diagnosis_report/<?php echo $row2['file_name'];?>"
style="background-image:url(<?php echo base_url();?>uploads/diagnosis_report/<?php echo $row2['file_name'];?>)" title="<?php echo $row2['file_name'];?>">
</a></div>
<?php endif;?>
<a href="<?php echo base_url();?>uploads/diagnosis_report/<?php echo $row2['file_name'];?>" target="_blank"
class="btn btn-blue"> <i class="icon-download-alt"></i> <?php echo get_phrase('download');?></a>
</td>
<td><?php echo $row2['description'];?></td>
<td><?php echo date('d M,Y', $row2['timestamp']);?></td>
<td><?php echo $this->crud_model->get_type_name_by_id('laboratorist',$row2['laboratorist_id'],'name');?></td>
<td align="center">
<a href="<?php echo base_url();?>index.php?laboratorist/manage_prescription/delete_diagnosis_report/<?php echo $row2['diagnosis_report_id'];?>/<?php echo $prescription_id;?>" onclick="return confirm('delete?')"
rel="tooltip" data-placement="top" data-original-title="<?php echo get_phrase('delete');?>" class="btn btn-red">
<i class="icon-trash"></i>
</a>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
</div>
</div>
<!------DIAGNOSTIC REPORT FOR THIS PRESCRIPTION---->
<!------ADD A DIAGNOSTIC REPORT TO THIS PRESCRIPTION-->
<div class="box">
<div class="box-header"><span class="title"><?php echo get_phrase('add_diagnosis_report');?></span></div>
<div class="box-content">
<?php echo form_open('laboratorist/manage_prescription/create_diagnosis_report' , array('class' => 'form-horizontal validatable'));?>
<div class="padded">
<div class="control-group">
<label class="control-label"><?php echo get_phrase('report_type');?></label>
<div class="controls">
<input type="text" name="report_type" /> <span class="label label-blue">report type can be x-ray, blood-test etc.</span>
</div>
</div>
<div class="control-group">
<label class="control-label"><?php echo get_phrase('document_type');?></label>
<div class="controls">
<select name="document_type" >
<option value="image"><?php echo get_phrase('image');?></option>
<option value="doc" ><?php echo get_phrase('doc');?></option>
<option value="pdf"><?php echo get_phrase('pdf');?></option>
<option value="excel"><?php echo get_phrase('excel');?></option>
<option value="other"><?php echo get_phrase('other');?></option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label"><?php echo get_phrase('upload_document');?></label>
<div class="controls">
<input type="file" name="userfile" />
</div>
</div>
<div class="control-group">
<label class="control-label"><?php echo get_phrase('description');?></label>
<div class="controls">
<textarea name="description" ></textarea>
</div>
</div>
<div class="control-group">
<div class="controls">
<input type="hidden" name="prescription_id" value="<?php echo $prescription_id;?>" />
<button type="submit" class="btn btn-blue"><?php echo get_phrase('add_diagnosis_report');?></button>
</div>
</div>
</div>
</form>
</div>
</div>
and here is my code to upload file in database :
function manage_prescription($param1 = '', $param2 = '', $param3 = '')
{
if ($this->session->userdata('laboratorist_login') != 1)
redirect(base_url() . 'index.php?login', 'refresh');
if ($param1 == 'create_diagnosis_report') {
$data['report_type'] = $this->input->post('report_type');
$data['document_type'] = $this->input->post('document_type');
$data['prescription_id'] = $this->input->post('prescription_id');
$data['description'] = $this->input->post('description');
$data['timestamp'] = strtotime(date('Y-m-d') . ' ' . date('H:i:s'));
$data['laboratorist_id'] = $this->session->userdata('laboratorist_id');
move_uploaded_file($_FILES["userfile"]["tmp_name"] , "uploads/diagnosis_report/".$_FILES["userfile"]["name"]);
$data['file_name'] = $_FILES["userfile"]["name"];
$this->db->insert('diagnosis_report', $data);
$this->session->set_flashdata('flash_message', get_phrase('diagnosis_report_created'));
redirect(base_url() . 'index.php?laboratorist/manage_prescription/edit/' . $this->input->post('prescription_id'), 'refresh');
}
if ($param1 == 'delete_diagnosis_report') {
$this->db->where('diagnosis_report_id', $param2);
$this->db->delete('diagnosis_report');
$this->session->set_flashdata('flash_message', get_phrase('diagnosis_report_deleted'));
redirect(base_url() . 'index.php?laboratorist/manage_prescription/edit/' . $param3, 'refresh');
} else if ($param1 == 'edit') {
$page_data['edit_profile'] = $this->db->get_where('prescription', array(
'prescription_id' => $param2
))->result_array();
}
$page_data['page_name'] = 'manage_prescription';
$page_data['page_title'] = get_phrase('manage_prescription');
$page_data['prescriptions'] = $this->db->get('prescription')->result_array();
$this->load->view('index', $page_data);
}
You have to use form_open_multipart() not form_open() in your view file

Categories