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!
Related
So I am making a project where you can order food at school cafeteria, I already have a project where you can make a order with the menu and the student, and time.
But now I want that the student can order at it's own and not select any student so for the order it takes the currently logged in student. Sorry for bad english and thanks for every answer, i appreciate it.
[enter image description here](https://i.stack.imgur.com/NFz6G.png)
So Schueler is student and Menu is menu
uhrzeit is time
Now I want that there is no student to select, it takes the session id to make a order.
This is my order/create.php file
<?php
$title = "Menü reservieren";
include '../layouts/top.php';
session_start();
if(!isset($_SESSION['schuelerid'])) {
die('Bitte zuerst einloggen');
}
//Abfrage der Nutzer ID vom Login
$userid = $_SESSION['schuelerid'];
$email = $_SESSION['email'];
echo "Hallo Schueler: ".$userid;
echo " ".$email;
require_once('../../models/Bestellungen.php');
// create new/empty model, contains all input-values and error-messages
$r = new Bestellungen();
if (!empty($_POST)) {
$r->setMenu(isset($_POST['menu']) ? $_POST['menu'] : '');
$r->setUhrzeit(isset($_POST['uhrzeit']) ? $_POST['uhrzeit'] : 0);
$r->setSchueler(isset($_POST['schueler']) ? $_POST['schueler'] : 0);
// redirect to view-page after successfull saving
if ($r->save()) {
header("Location: view.php?id=" . $r->getId());
exit();
}
}
?>
<div class="container">
<div class="row">
<h2><?= $title ?></h2>
</div>
<form class="form-horizontal" action="create.php" method="post">
<div class="row">
<div class="col-md-1"></div>
<div class="col-md-2">
<div class="form-group required">
<label class="control-label">Schueler *</label>
<select style="width: 200px" name="schueler">
<option selected></option>
<?php
require_once "../../models/Schueler.php";
foreach (Schueler::getAll() as $g){
?>
<option value='<?=$g->getId()?>'><?=$g->getName()?></option>
<?php
}
?>
</select>
<?php if (!empty($r->getErrors()['schueler'])): ?>
<div class="help-block"><?= $r->getErrors()['schueler'] ?></div>
<?php endif; ?>
</div>
</div>
<div class="col-md-2">
<div class="form-group required ">
<label class="control-label">Menu *</label>
<select name="menu" style="width: 200px">
<option selected></option>
<?php
require_once "../../models/Menu.php";
foreach (Menu::getAll() as $z){
?>
<option value='<?=$z->getId()?>'><?=$z->getName()?></option>
<?php
}
?>
</select>
<?php if (!empty($r->getErrors()['menu'])): ?>
<div class="help-block"><?= $r->getErrors()['menu'] ?></div>
<?php endif; ?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-2">
<div class="form-group required ">
<label class="control-label">Uhrzeit *</label>
<input type="datetime-local" class="form-control" name="uhrzeit" value="">
<?php if (!empty($r->getErrors()['uhrzeit'])): ?>
<div class="help-block"><?= $r->getErrors()['uhrzeit'] ?></div>
<?php endif; ?>
</div>
</div>
<div class="col-md-1"></div>
</div>
<div class="row">
<div class="form-group">
<button type="submit" name="submit" class="btn btn-success">Erstellen</button>
<a class="btn btn-default" href="view.php">Abbruch</a>
</div>
</div>
</form>
</div> <!-- /container -->
<?php
include '../layouts/bottom.php';
?>
I want to make a list of four questions and four options for each question. I have successfully fetched the questions with foreach loop but, radio buttons do not seem to work with foreach loop.
Eg: I chose one answer form the first question and jump to second, but if I select an answer for the second question, the selected option of the first questions gets deselected. I have tried changing values of options, that did not work, I tried using for loop inside the foreach loop and even that did not work.
Following is my code:
<form method="post" action="process/quiz.php">
<?php
$quizList = $quiz->getQuiz(4);
if($quizList){
foreach($quizList as $list){
?>
<div class="row rowpadding">
<div class="col-md-8 col-md-offset-2" id="panel1">
<div class="panel panel-default">
<div class="panel-heading">
<h5 class="panel-title">
<?php echo $list->title; ?>
</h5>
</div>
<div class="panel-body two-col">
<div class="row">
<div class="col-md-6">
<div class="frb frb-danger margin-bottom-none">
<input type="radio" id="radio-button-1" name="ans1" value="<?php echo $list->option_A ?>">
<label for="radio-button-1">
<span class="frb-title"><?php echo $list->option_A ?> </span>
<span class="frb-description"></span>
</label>
</div>
</div>
<div class="col-md-6">
<div class="frb frb-danger margin-bottom-none">
<input type="radio" id="radio-button-2" name="ans2" value="<?php echo $list->option_B ?>">
<label for="radio-button-2">
<span class="frb-title"><?php echo $list->option_B ?></span>
<span class="frb-description"></span>
</label>
</div>
</div>
<div class="col-md-6">
<div class="frb frb-danger margin-bottom-none">
<input type="radio" id="radio-button-3" name="ans3" value="<?php echo $list->option_C ?>">
<label for="radio-button-3">
<span class="frb-title"><?php echo $list->option_C ?></span>
<span class="frb-description"></span>
</label>
</div>
</div>
<div class="col-md-6">
<div class="frb frb-danger margin-bottom-none">
<input type="radio" id="radio-button-4" name="ans4" value="<?php echo $list->option_D ?>">
<label for="radio-button-4">
<span class="frb-title"><?php echo $list->option_D ?></span>
<span class="frb-description"></span>
</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
}
}
?>
<div class="panel-footer rowpadding">
<div class="row">
<div class="col-md-6">
<button type="submit" class="btn btn-sm btn-block ">
<span class="fa fa-send"></span>
submit </button>
</div>
</div>
</div>
</form>
Is there anything that I am missing?
Your problem is that you are re-using the names and the IDs of your inputs. Names and IDs have to be unique for the HTML to be valid, and to work as you intend it to. You can have the input-names as HTML arrays instead, and group by that.
Using the $key of the array, you can define a unique name for each your group of answers. We also use this to define the IDs of your elements, since they must be unique.
Changes made are,
Include the $key in the loop
Adding -<?php echo $key; ?> to all instances where you use the ID of the buttons (and the reference in the label), to ensure all IDs are unique
Using name="answer[<?php echo $key; ?>]" instead of ans1, ans2, ans3, ans4. This ensures that only one radio button can be selected per answer, and that you have one array of answers, each element being the answer of one question.
foreach ($quizList as $key=>$list){
?>
<div class="row rowpadding">
<div class="col-md-8 col-md-offset-2" id="panel1-<?php echo $key; ?>">
<div class="panel panel-default">
<div class="panel-heading">
<h5 class="panel-title">
<?php echo $list->title; ?>
</h5>
</div>
<div class="panel-body two-col">
<div class="row">
<div class="col-md-6">
<div class="frb frb-danger margin-bottom-none">
<input type="radio" id="radio-button-1-<?php echo $key; ?>" name="answer[<?php echo $key; ?>]" value="<?php echo $list->option_A ?>">
<label for="radio-button-<?php echo $key; ?>">
<span class="frb-title"><?php echo $list->option_A ?> </span>
<span class="frb-description"></span>
</label>
</div>
</div>
<div class="col-md-6">
<div class="frb frb-danger margin-bottom-none">
<input type="radio" id="radio-button-2-<?php echo $key; ?>" name="answer[<?php echo $key; ?>]" value="<?php echo $list->option_B ?>">
<label for="radio-button-2-<?php echo $key; ?>">
<span class="frb-title"><?php echo $list->option_B ?></span>
<span class="frb-description"></span>
</label>
</div>
</div>
<div class="col-md-6">
<div class="frb frb-danger margin-bottom-none">
<input type="radio" id="radio-button-3-<?php echo $key; ?>" name="answer[<?php echo $key; ?>]" value="<?php echo $list->option_C ?>">
<label for="radio-button-3-<?php echo $key; ?>">
<span class="frb-title"><?php echo $list->option_C ?></span>
<span class="frb-description"></span>
</label>
</div>
</div>
<div class="col-md-6">
<div class="frb frb-danger margin-bottom-none">
<input type="radio" id="radio-button-4-<?php echo $key; ?>" name="answer[<?php echo $key; ?>]" value="<?php echo $list->option_D ?>">
<label for="radio-button-4-<?php echo $key; ?>">
<span class="frb-title"><?php echo $list->option_D ?></span>
<span class="frb-description"></span>
</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
}
Now, when you submit the form, the selected answers will be in an array where the name is answer. So you will have to do something like
foreach ($_POST['answer'] as $key=>$value) {
// $key is the same key from the loop above
// $value is the value of the selected radio button
}
Radio buttons are tied together by name. In your foreach(), you keep repeating the same names for each set of question answers. (You're also repeating the same ID, which is bad form, but won't break your script).
You need to restructure your radio buttons so that each group of buttons (that belong together) have the same name. And that name has to be unique per group.
A simplified example:
<form>
<p>These belong together, and all have the name "gender":</p>
<input type="radio" name="gender" value="male"> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<p>These belong together, and all have the name "team":</p>
<input type="radio" name="team" value="blue"> Blue<br>
<input type="radio" name="team" value="red"> Red<br>
</form>
An even more simplified answer
foreach($quizList as $key => $list){ ?>
<form>
<input type="radio" id="radio-button-1" name="answer[<?php echo $key;?>]" value="<?php echo $list->option_A ?>"> <!-- answer_0 -->
<input type="radio" id="radio-button-1" name="answer[<?php echo $key;?>]" value="<?php echo $list->option_B ?>"> <!-- answer_0 -->
</form>
Then in php you should get something like this:
$_POST['answer'] = [
'0' => 'foo'
//'1' => 'biz' ....
];
With Ajax
One note with numbered keys. IF you use AJAX (if not you can basically ignore this) you may lose numeric indexes when converting to and from JSON, for example imagine we expect this:
$_POST['answer'] = [
'0' => 'foo'
'2' => 'biz' ....
];
When that is encoded in Json it will likly be something like this (where did the keys go)
'{"answer":["foo", "biz"]}`
Then when PHP converts that back we have lost our keys. And we we'll have something like this:
$_POST['answer'] = [
0 => 'foo'
1 => 'biz' ....
];
This is also true of any array function that doesn't preserve keys, sort etc. The easy solution here is to just prefix the key with something like a or _ even. Then they will be strings and translate to objects in the JSON. In PHP you could still match these like this:
if("a$id" == $post_id){}
if(substr($post_id,1) == $id){}
//remove all prefixes
print_r(array_combine(preg_replace('/^a/', '', array_keys($answers)),$answers));
//it feels wrong but if you have to append you can do this
var_dump((int)'2a' == 2); //true so your key would be 2a because how PHP converts strings to ints.
And so on.
Hope it helps!
So the problem is that i have a input type number just like any other regular input type number, but for some reason that am not able to understand it put a "<" sign in front of my numbers.
<div class="child">
<div class="label-form">
<label for="numC">Numero de Contrato:</label>
</div>
<?php while($vector2=mysqli_fetch_array($resultado2)) { ?>
<div class="input">
<?php echo $vector2[0]+1;?>
<input type="hidden" name="NumeroContrato" value="<?php echo $vector2[0]+1;?>">
</div>
</div>
<?php } ?>
<div class="child">
<div class="label-form">
<label for="nMota">Numero da mota</label>
</div>
<div class="input">
<input type="number" id="nMota" name="nMota" placeholder="Bike Number" required>
</div>
</div>
Its the "nMota" input; for example if i put a 1 it receive the information as <1 if i put a 7 it put <7. I have no idea why.
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";
}
?>
I have a two step form. create.php and create2.php. Both pages are forms. After first form is filled user presses "Continue" and proceeds to the second form where i pass and store value from first form in hidden inputs. After filling and submitting second form, i want pop up window which means successful submission of the form and inserting all the data into database. It seems that everything is working fine and all data is in database, however i dont get pop up window, what i get is undefined index warning about my hidden inputs.
Ok here is code for create.php:
<form class="formcss" method="post" action="create2.php" id="reportform" enctype="multipart/form-data">
<fieldset style="background-color:white;">
<legend style="font-size: 20px;">New Project</legend>
<br>
<div class="row">
<div class="small-8 large-8 columns">
<label>Project Code: <small style="color:red;">*</small>
<input type="text" name="code" maxlength="155" id="code" class="input input1 name" onkeyup="limitTextCount('code', 'divcount0', 155, 0);" onkeydown="limitTextCount('code', 'divcount0', 155, 0);" <?php if (isset($code)) echo 'value="'.$code.'"' ?>/>
<label class="tool tool1" for="name" style="margin-top:-8px;">Code of the project</br>e.g. ASD001</label>
</label>
</div>
</div>
<div class="row">
<div class="small-8 large-8 columns">
<label>Project Name: <small style="color:red;">*</small>
<input type="text" name="title" maxlength="155" id="title" class="input input1 name" onkeyup="limitTextCount('title', 'divcount0', 155, 0);" onkeydown="limitTextCount('title', 'divcount0', 155, 0);" <?php if (isset($title)) echo 'value="'.$title.'"' ?>/>
<label class="tool tool1" for="name" style="margin-top:-8px;">Title of the project</br>e.g. Leon</label>
</label>
</div>
</div>
<div class="row">
<div class="small-8 large-8 columns">
<label>Process
<div class="multiselect">
<div class="selectBox">
<select onclick="showCheckboxes()" class="input input1 name">
<option>-- Select an option --</option>
</select>
<div class="overSelect"></div>
</div>
<div class="scrollable" id="checkboxes">
<?php
while ($row = mysql_fetch_array($result))
{
$row[0] = cleanOutputData($row[0]);
?>
<div class="row">
<div class="small-12 large-12 columns">
<label style="height: 37px; width:80%; float:left;">
<input type="checkbox" class="checkbox" style="margin-left:5%; width:15%;" name="process[]" id=<?php echo $row[0] ?> value=<?php echo $row[0]?> /><?php echo $row[0] ?>
</label>
<label style="width:40%; margin-left:60%;"><input type="text" class="field" disabled style="width:40%;" name="numberpl[]" id=<?php echo $row[0] ?> />
</label>
</div>
</div>
<?php
}
mysql_free_result($result);
?>
</div>
</div>
</label>
</div>
</div>
<div class="row">
<div class="small-8 large-8 columns">
<label>Comments
<textarea style="resize:none;" class="input input1 name" name="remark" rows="8" cols="50" maxlength="255" id="remark" onkeyup="limitTextCount('remark', 'divcount5', 255, 0);" onkeydown="limitTextCount('remark', 'divcount5', 255, 0);"><?php if (isset($remark)) echo $remark ?></textarea>
<label class="tool tool1" for="name" style="left:-140px;">Further comments</label>
</label>
</div>
<div class="small-6 large-6 columns">
<label> <?php if (isset($remark)){ echo "<label id='divcount5'></label>"; echo "<script>limitTextCount('remark', 'divcount5', 255, 0);</script>";} else echo "<label id='divcount5'>255 characters remaining</label>";?></label>
</div>
</div>
<div class="row">
<div class="small-8 large-8 columns">
<input type = "submit" name ="submit" style="margin-left:600px; width:150px;" class="button" onclick="userSubmitted = true;" value = "Continue"/>
</div>
</div>
<br/><br/>
</fieldset>
</form>
And for the second form create2.php:
<?php
session_start();
//if user haven't sign in will redirect user to login page
if(empty($_SESSION['login_user'])){
session_destroy();
header("Location: login.php");
}
$proc = isset($_POST['process'])?$_POST['process']:'';
//$proc=$_POST['process'];
$len = count($proc); // getting length of ur array that u need to condition ur loop
$num = isset($_POST['numberpl'])?$_POST['numberpl']:'';
//$num=$_POST['numberpl'];
//$len2 = count($num); // getting length of ur array that u need to condition ur loop
include 'verification/verify_form_details2.php';
require_once('inc/config.php');
//include 'verification/verify_form_details.php';
ob_start();
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "pp";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>
<form class="formcss" method="POST" name="checkoutForm" action="create2.php#err" id="reportform" enctype="multipart/form-data">
<?php
$res = verifyFormFields();
?>
<!-- hidden inputs from first form(create.php) -->
<input type="hidden" name="holdcode" value="<?php echo isset($_POST['code'])?$_POST['code']:'';?>">
<input type="hidden" name="holdtitle" value="<?php echo isset($_POST['title'])?$_POST['title']:'';?>">
<?php
//an array of inputs
for($y=0;$y<$len;$y++)
{
?>
<input type='hidden' name='holdprocess[]' value="<?php echo $proc[$y]?>">
<input type='hidden' name='holdnumber[]' value="<?php echo $num[$y]?>">
<?php
}
?>
<!-- hidden inputs from first form(create.php) -->
<br>
<fieldset style="background-color:white;">
<legend style="font-size: 20px;">Add Stuff</legend>
<br><br><br>
<div class="small-3 large-3 columns">
<label>Choose username</label>
<input placeholder="Search Me" id="box" type="text" />
<div id="myAccordion">
<?php for($i=321; $i<347; $i++)
{
echo "<h3>".chr($i)."</h3>";
echo '<ul class="source">';
$sql = "SELECT username FROM user WHERE username LIKE '".chr($i+32)."%' ";
$result = $conn->query($sql);
if ($result->num_rows > 0)
{
// output data of each row
while($row = $result->fetch_assoc())
{
$name= $row["username"];
echo"<li>". $name ."</li>";
}
} else
{
echo "0 results";
}
echo '</ul>';
}
?>
</div>
</div>
<div id="project" class="small-9 large-9 columns">
<label style="font-size: 40px; margin-left:10%;">Project <?php echo isset($_POST['code'])?$_POST['code']:''; ?></label>
<div class="rowone">
<div id="leader">
<label>Leader:</label>
<div class="ui-widget-content">
<div id="projLeader">
<ol>
<li class="placeholder" name="leader" <?php if (isset($leader)) echo 'value="'.$leader.'"' ?>>Add leader here</li>
<input type="hidden" name="leader" id="hiddenListInput1" />
</ol>
</div>
</div>
</div>
<div id="checker">
<label>Checker:</label>
<div class="ui-widget-content">
<div id="projChecker">
<ol>
<li class="placeholder" name="checker" <?php if (isset($checker)) echo 'value="'.$checker.'"' ?>>Add checker here</li>
<input type="hidden" name="checker" id="hiddenListInput2" />
</ol>
</div>
</div>
</div>
<div id="info">
<label>Information:</label>
<div class="ui-widget-content">
<ol>
<li>Total:</li>
<li>Total:</li>
<li>Total:</li>
<li>Total:</li>
<li>Total:</li>
</ol>
</div>
</div>
</div>
<div class="row">
<input type = "submit" id="savebutton" style="margin-left:300px; width:150px;" name ="submit" class="button" value = "Create Project" onclick="userSubmitted = true;" />
</div>
</div>
<div id="formModal" class="reveal-modal small" data-reveal aria-labelledby="modalTitle" aria-hidden="true" role="dialog" data-options="close_on_background_click:false">
<h2 id="modalTitle">Success!</h2>
<div style="font-weight: 400;font-size: 1.5em; font-family: 'Raleway', Arial, sans-serif;">Your Accident Report was Successfully Submitted!</div>
<div class="right">
Ok
</div>
</div>
<?php
if($counta==1)
{
if($res=="")
{
$testing = JSON_encode($_SESSION['role']);
echo '<script>userSubmitted = true;</script>';
insertRecord();
echo "<script type ='text/javascript'>callShowAlert();</script>";
}
else{
echo "
<br><br><a style='color:red';>
$res
</a>
";
}
}
?>
<script>var testing = JSON.parse('<?= $testing; ?>');</script>
</fieldset>
</form>
Here is what i got after submitting second form:
Notice:
Undefined index: process in C:\xampp\htdocs\Projects\1ver\create2.php
on line 9
Notice:
Undefined index: numberpl in C:\xampp\htdocs\Projects\1ver\create2.php
on line 12
Notice:
Undefined index: code in
C:\xampp\htdocs\Projects\1ver\create2.php on line 256
Notice:
Undefined index: title in
C:\xampp\htdocs\Projects\1ver\create2.php on line 257
Notice:
Undefined index: title in C:\xampp\htdocs\Projects\1ver\create2.php on
line 302
I'm using another php page to insert data into database. I just don't get what can be a problem. Thanks for any help
Since POST array is not available for first time. Therefore, you are getting this error. If you really need to use those post variables, you should apply a condition in this case to avoid these errors.
I'm here adding for one, you can do the same for remaining.
Try this:
<?php echo isset($_POST['code'])?$_POST['code']:''; ?>