I am trying to create a form in multi steps. what i am trying to do is in the first page user will enter two field i.e title and description which will get saved in the database and then they are redirected to the second page where they need to few more details, but here i want to put a condition that these values should be added in front of the row that has the value of title which was saved in the previous page.
here is what i have done so far
<?php
include('creator_session.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
//necessary data
</head>
<body>
<form class="form-horizontal" role="form" action="insert_page_one.php" enctype="multipart/form-data" method="post">
<div class="row">
<div class="col-md-4 col-md-offset-4"><input class="form-control" value="Project Name" type="text" name="title"></div>
</div>
<div class="row">
<div class="col-md-4 col-md-offset-4"><input class="form-control" value="Project Name" type="text" name="title"></div>
</div>
<div class="row">
<div class="col-md-4 col-md-offset-4"><input class="btn btn-primary" value="Get Started" type="submit" name="submit"></div>
</div>
</form>
<body>
</html>
insert_page_one.php
<?php
include('creator_session.php');
$con=mysqli_connect("xyz.com","xyz","xyz","xyz");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// escape variables for security
$title = mysqli_real_escape_string($con, $_POST['title']);
$category = mysqli_real_escape_string($con, $_POST['category']);
$sql="INSERT INTO creatorproject(title,category) VALUES ('$title','$category')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
header("Location: page_two.php");
mysqli_close($con);
?>
page_two.php
<?php
include('creator_session.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
//necessary data
</head>
<body>
<form class="form-horizontal" role="form" action="creator_page_two.php" enctype="multipart/form-data" method="post">
<div class="form-group">
<label class="col-md-3 control-label">Description</label>
<div class="col-md-8">
<input class="form-control" name="description" value="" type="">
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Project Location:</label>
<div class="col-md-8">
<input class="form-control" name="projectlocation" value="" type="">
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Funding Goal:</label>
<div class="col-md-8">
<input class="form-control" name="funding" value="" type="">
</div>
</div>
<div class="submit">
<input type="submit" value="SAVE">
</div>
</form>
</body>
</html>
creator_page_two.php
<?php
include('creator_session.php');
$con=mysqli_connect("xyz","xyz","xyz","xyz");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// escape variables for security
$description = mysqli_real_escape_string($con, $_POST['description']);
$projectlocation = mysqli_real_escape_string($con, $_POST['projectlocation']);
$funding = mysqli_real_escape_string($con, $_POST['funding']);
$sql = "UPDATE creatorproject SET description='".$description."', projectlocation='".$projectlocation."', funding='".$funding."' WHERE title ='".$title."'";
if (!mysqli_query($con,$sql)) {
die('Error: ' . mysqli_error($con));
}
header("Location: creator_add_project.php");
exit;
mysqli_close($con);
?>
When i run this code it is not inserting values from the second page.. Would appreciate some help and would be grateful if someone could explain the procedure as i am new to this field and would love to learn about it.
P.S- i have also used creator_session that stores the login details of the user as the user have to fill these forms after signing in, therefore the entire login process has been done with the session