If you can see this image there are main 4 pages. 1. issues.html 2. review issue.php 3.Another page.html 4. anotherpage.html
User inputs the query it goes to DB then I am fetching it on review issue page from DB using mysqli_fetch_array() and in the while loop, i am calling every row data present in DB. Review issue page shows all the issue list present in DB. But I want to send issue 1 data on some page called another page and issue 2 data on another page 2. For that what needs to be done. I ahve used local storage to function these checkboxes. You can see them in image.
This is the code for Review-issue.php
<?php
$result = mysqli_query($conn,$sql);
while($row = mysqli_fetch_array($result,MYSQLI_BOTH))
{
?>
<div class="c-body">
<div class="alert alert-success alert-dismissible" role="alert"> This issue has been reported by <?php echo $row['your_name']; ?> from <?php echo $row['store_name']; ?>
<p> <?php echo $row['issue_title']; ?></p>
<p><?php echo $row['file'] ?></p>
<p>View File </p>
<a class="c-font-slim" href="#">read this important alert message</a>.
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="c-content-panel">
<div class="c-body">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-body">
<div class="form-group">
<label class="col-md-4 control-label">Action</label>
<form action="track.php" method="post">
<div class="col-md-6">
<label class="checkbox-inline">
<input type="checkbox" class="progressbar_chkbox" type="checkbox" id="pending" data-progress="33" value="pending">Pending </label>
<label class="checkbox-inline">
<input type="checkbox" id="inlineCheckbox2" class="progressbar_chkbox" id="read" type="checkbox" data-progress="66" value="option2" value="read"> Read</label>
<label class="checkbox-inline">
<input type="checkbox" id="inlineCheckbox3" class="progressbar_chkbox" id="completed" type="checkbox" data-progress="100" value="option3" name="completed"> Completed </label>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php } ?>
If you have a column in your database to identify which type of issue each record is, then add a conditional that will divide your results set into the two issue types. Then you can include the appropriate form for the issue type.
<?php
if ($row["issue_type"] == 1) {
include "issue1.php";
} elseif ($row["issue_type"] == 2) {
include "issue2.php";
} else {
include "default.php";
}
?>
Related
Quick rundown:
Everything ran perfectly as it should when I had my own custom textarea field to send data
I had a custom text editor widget for inputs, but tried to add CKEditor for more functionality
When I added CKEditor package (https://ckeditor.com/ckeditor-4/download/?undefined-addons=) the editor was there, but when I clicked "Add" button and sent data, the input was doubled and there was a space between inputs (for example - input was:"test" and output was "test<br><br>test"), as if I put <br> tag and multiplied my input somewhere.
When I stopped trying with CKEditor, I went back to original code and my own original custom text editor, which before worked perfectly. However, to my surprise, it now still doubles the input string, but it doesn't put a <br> tag in between.
In DB the string value is normal and not doubled.
I have no idea how this happened, I've been going over the code for a hour or so now, trying to see if I overlooked something, but I even created a separate file with functioning code, before I was trying with CKEditor in case something broke and I could just replace it with old code and try tomorrow, but now it's messed up and I have no idea how and where.
notifications.php
<form class="form-inline" action="/action_page.php">
</form>
</nav>
<div class="container-fluid m-0 p-0">
<div class="row justify-content-center">
<div class="col-md-10">
<?php if (isset($_SESSION['response'])) { ?>
<div class="alert alert-<?= $_SESSION['res_type']; ?> alert-dismissible text-center">
<button type="button" class="close" data-dismiss="alert">×</button>
<b><?= $_SESSION['response']; ?></b>
</div>
<?php } unset($_SESSION['response']); ?>
</div>
</div>
<div class="row">
<div class="">
<?php
$query = 'SELECT * FROM crud';
$stmt = $conn->prepare($query);
$stmt->execute();
$result = $stmt->get_result();
?>
<table class="table table-hover" id="data-table">
<tbody>
<?php while ($row = $result->fetch_assoc()) { ?>
<tr>
<td></td>
<td class="pt-2"><?=
$longString=$row['name'];
$link = $row['id'];
$longStringshortcut = strlen($longString);
//echo substr($longString, 0, 100).'... Read More';
if ($longStringshortcut > 250) {
echo substr($longString, 0, 250).".. <a href='details.php?details=$link'><strong>Preberi več...</strong></a>"; }
else {
echo $longString;
}
?>
Details
Delete
Edit
</td>
</tr>
<?php } ?>
</tbody>
</table>
<div class="col-md-4 p-0">
<h5 class="">Add notification:</h5>
<form action="action.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?= $id; ?>">
<div class="form-group">
<textarea name="name" value="<?= $name; ?>" class="form-control" placeholder="This is the default text" required></textarea>
</div>
<div class="form-group">
<?php if ($update == true) { ?>
<input type="submit" name="update" class="btn btn-success btn-block" value="Change notification">
<?php } else { ?>
<input type="submit" name="add" class="btn btn-primary btn-block" value="Add">
<?php } ?>
</div>
<div class="form-group">
<input type="hidden" name="oldimage" value="<?= $photo; ?>">
<input type="file" name="image" class="custom-file">
<img src="<?= $photo; ?>" width="120" class="img-thumbnail">
</div>
</form>
</div>
</div>
</div>
</div>
action.php
<?php
session_start();
include 'config.php';
$update=false;
$id="";
$name="";
$photo="";
if(isset($_POST['add'])){
$name=$_POST['name'];
$photo=$_FILES['image']['name'];
$upload="uploads/".$photo;
$query="INSERT INTO crud(name,photo)VALUES(?,?)";
$stmt=$conn->prepare($query);
$stmt->bind_param("ss",$name,$upload);
$stmt->execute();
move_uploaded_file($_FILES['image']['tmp_name'], $upload);
header('location:index.php');
$_SESSION['response']="Successfully Inserted to the database!";
$_SESSION['res_type']="success";
}
The problem was with the <?= syntax (echoing), <?php solved it.
using for each loop I have to retrieve data however when adding new record data-repeater-create is taking default value as the last record of data even the element id is different.
<div data-repeater-list="car">
<?php foreach ($user_portfolio as $p_details) {
$p_title = $p_details['portfolio_title'];
$p_desc=$p_details['portfolio_desc'];
$p_expert = $p_details['portfolio_expert_id'];
$p_id = $p_details['portfolio_id'];
?>
<div data-repeater-item>
<div class="form row">
<div class="form-group mb-1 col-sm-12 col-md-12">
<label for="email-addr">Title</label>
<br>
<input type="text" name="port_id" value="<?php if(!empty($p_id)) {echo $p_id; } else { echo "";}?>">
<input type="text" class="form-control" id="portfolio_title<?php echo $p_id;?>" placeholder="Title " name="portfolio_title" value="<?php if(!empty($p_title)) {echo $p_title;} else {echo ""; }?>">
</div>```
below using data-repeater-create i am adding empty field however its taking last record as default value and I able to see in view source
``` <?php } //end of foreach?>
</div>
<div class="form-group overflow-hidden">
<div class="col-12">
<button data-repeater-create class="btn btn-theme" type="button">
<i class="ft-plus"></i> Add
</button>
<button type="submit" class="btn btn-theme">
<i class="la la-check-square-o"></i> Save
</button>
</div>
</div>
</form>```
I am having trouble to post a html form. I am posting one form and getting the post value to my variable and then I am post this form but this form is not posting.
HTML code:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" autocomplete="off">
<div class="widget-box">
<div class="widget-title"> <span class="icon"> <i class="icon-user"></i> </span>
<h5>Amc details</h5>
</div>
<div class="widget-content">
<div class="controls controls-row">
<div class="control-group span3">
<label for="normal" class="control-label">Installation Date<span style="color:red">*</span></label>
<div class="controls">
<input type="text" id="amc-ins-date" data-date="01-02-2016" name="amc-ins-date" data-date-format="dd-mm-yyyy" class="datepicker span12" placeholder="Enter installation date">
</div>
</div>
<div class="control-group span3">
<label for="normal" class="control-label">Start Date<span style="color:red">*</span></label>
<div class="controls">
<input type="text" id="amc-start-date" data-date="01-02-2016" name="amc-start-date" data-date-format="dd-mm-yyyy" placeholder="Enter amc start date" class="datepicker span12 ins-date">
</div>
</div>
<div class="control-group span3">
<label class="control-label">End Date<span style="color:red">*</span></label>
<div class="controls">
<input type="text" id="amc-end-date" data-date="01-02-2016" name="amc-end-date" data-date-format="dd-mm-yyyy" placeholder="Enter amc end date" class="datepicker span12 ins-date">
</div>
</div>
<div class="control-group span3">
<label class="control-label">Amount<span style="color:red">*</span></label>
<div class="controls">
<input type="text" id="amc-amount" name="amc-amount" class="span12" placeholder="Enter amc amount">
</div>
</div>
</div>
</div>
<div class="form-actions">
<input style="float:right" type="submit" name="amc-installation" class="btn btn-success" value="Save">
</div>
</form>
PHP code:
// i have submitted a form here and its posted
// installation details
$mc_serial = $_POST['mc-serial'];
$mc_model = $_POST['mc-model'];
$contract_type = $_POST['contract_type'];
$no_of_copies = $_POST['no-of-copies'];
$spare_part = join(",",$_POST['spare-part']);
$eng_name = $_POST['eng-name'];
$review = $_POST['review'];
// check if the machine already exits
if(IsMachine($mc_serial,$con)){
echo msgIsMachine();
exit();
}
if($contract_type == 'AMC'){
require './forms/amc.php'; // this is the html i have shown above
} elseif ($contract_type == 'ASC') {
require './forms/asc.php';
} elseif ($contract_type == '4C') {
require './forms/4c.php';
} elseif ($contract_type == 'RENTAL') {
require './forms/rental.php';
} elseif ($contract_type == 'WARRANTY') {
require './forms/warranty.php';
}
if(isset($_POST['amc-installation']) && !empty($_POST['amc-installation'])){
echo "posted";
var_dump($_POST);($_POST);
}
The output of var_dump is NULL. I don't get any problem.
You echo the second form (during the script which responds to the submission of the first one), but then immediately check for values returned from it within the same script execution. You have to wait for the user to post the form back before you can check the submitted values. This would be a separate postback, and therefore a separate execution context for the PHP.
So the code to check the values from the second form needs to be in a separate section (or file) which is triggered by the submission of the second form.
There's no $POST in PHP you should use $_POST instead :
if(isset($_POST['amc-installation']) && !empty($_POST['amc-installation'])){
echo "posted";
var_dump($_POST);
}
NOTE : You should place the var_dump($_POST); inside the if statement, so it will be trrigered just after the submit.
Hope this helps.
if(isset($_POST['amc-installation']) && !empty($_POST['amc-installation'])){
echo "posted";
var_dump($_POST);
}
You should use $_POST not $POST.
Hope this will helps you :)
I have two forms. After submitting first form it comes to a second form where i need to get values from first form. Here is the first part of form:
<?php $result2 = getProcessID();?>
<form class="formcss" method="post" action="create2.php" >
<div class="row">
<div class="small-8 large-8 columns">
<label>Process: <small style="color:red;">*</small>
<div class="multiselect">
<div class="selectBox">
<select onclick="showCheckboxes()" class="input input1 name">
<option>-- Select a process -- Add number of people reqired --</option>
</select>
<label class="tool tool1" for="name" style="top:-15px; margin-left:-14px; left:-207px; ">Choose process and number <br> of people required</label>
<div class="overSelect"></div>
</div>
<div class="scrollable" id="checkboxes">
<?php
while ($row = mysql_fetch_array($result2))
{
$row[0] = cleanOutputData($row[0]);
?>
<div class="row">
<div class="small-6 large-6 columns">
<label style="height: 38px;">
<input type='checkbox' style="width:20%;" name='process[]' id=<?php echo $row[0] ?> value=<?php echo $row[0] ?>/><?php echo $row[0] ?>
</label>
</div>
<div class="small-6 large-6 columns">
<label><input type='text'style="margin-left:50%; width:20%;" name='number[]'/>
</label>
</div>
</div>
<?php
}
mysql_free_result($result2);
?>
</div>
</div>
</label>
</div>
</div>
</form>
It seems fine to display the values in the second form except two problems:
1) Only half of the process is displayed
2) I can the number only for first 3 processes, but for other processes it stays an empty field.
Here is my second form:
$_SESSION['process'] = $_POST['process'];
$_SESSION['number'] = $_POST['number'];
$proc=$_SESSION['process'];
$len = count($proc); // getting length of an array
$num=$_SESSION['number'];
<form class="formcss" method="post" action="create.php#err" id="reportform" enctype="multipart/form-data">
<div id="project" class="small-9 large-9 columns">
<label style="font-size: 40px; margin-left:10%;">Project <?php echo $_SESSION["title"]; ?></label>
<label><?php for($y=0;$y<$len;$y++)
{
echo "Process: "."$proc[$y]"."<br />";
echo "People required: "."$num[$y]"."<br />";
?>
<ol>
<li class="placeholder" <?php if (isset($leader)) echo 'value="'.$leader.'"' ?>>Add people here</li>
</ol>
<?php
}
?>
</label>
<br><br><br>
<div class="row">
<input type = "submit" style="margin-left:300px; width:150px;" name ="submit" class="button" value = "Create Project" onclick="userSubmitted = true;"/>
</div>
</div>
</form>
As i said only half of the process is shown, for example, I have 'ANM KEY' process, and when i pass the value and display it on another form it displays only 'ANM'. Also I want to display number of people required for each process, but it works only for first three rows. So how i can get the wholename of the process, and display number of people required. Thank you!
I need to know how can I implement a user level access in my site. I need to hide forms and images when users with level are member...
in my DB I have a USERS TABLE with:
id
nombre
apellido
username
password
level
level is ENUM and have this two selects: administrator and member
I can hide scripts in any page with this type of PHP code:
<?php if(basename($_SERVER['PHP_SELF']) == 'contact.php') { ?>
<script src="js/jquery.js"></script>
<?php } ?>
and works very well, but I don't know how can hide per example this:
<div class="box span6">
<div class="box-header well" data-original-title>
<h2><i class="icon-picture"></i> <?php $translate->__('Save images'); ?></h2>
<div class="box-icon">
<i class="icon-chevron-up"></i>
<i class="icon-remove"></i>
</div>
</div>
<div class="box-content">
<form action="upload.php" method="post" name="image_upload" id="image_upload" enctype="multipart/form-data">
<label><?php $translate->__('Images type'); ?> (gif, jpg, png)</label><br />
<input type="file" size="45" name="uploadfile" id="uploadfile" class="file margin_5_0" onchange="ajaxUpload(this.form);" />
<div id="upload_area" class="corners align_center">
<?php $translate->__('Please select one image'); ?>.
</div>
</form>
</div>
</div>
In google I saw this code but don't work in my partycular case:
<?php if($USERS->level == "administrator"): ?>
<?php endif; ?>
can you help me with my problem?
Hiding js files will not do you much good because an attacker can intercept the javascript file being served to your admin user, build his own mock-up page of your site and have it use that javascript. So make sure to put security and validation in your php code, especially inside your upload.php
Obviously this $USERS->level can be replaced by any variable that you have set.
<?php if($USERS->level == "administrator")
{
?>
<div class="box span6">
<div class="box-header well" data-original-title>
<h2><i class="icon-picture"></i> <?php $translate->__('Save images'); ?></h2>
<div class="box-icon">
<i class="icon-chevron-up"></i>
<i class="icon-remove"></i>
</div>
</div>
<div class="box-content">
<form action="upload.php" method="post" name="image_upload" id="image_upload" enctype="multipart/form-data">
<label><?php $translate->__('Images type'); ?> (gif, jpg, png)</label><br />
<input type="file" size="45" name="uploadfile" id="uploadfile" class="file margin_5_0" onchange="ajaxUpload(this.form);" />
<div id="upload_area" class="corners align_center">
<?php $translate->__('Please select one image'); ?>.
</div>
</form>
</div>
</div>
<?php
}
?>