Hi
I am just stucked. Would be great if someone can help me.
I have created form in page1.html. User fill the form and can view it in page2.php where there is also an edit button.
If they need to edit any details, page3.php comes and they they can edit it. There is a confirm button on page3.php.

I have created another page4.php with commands to save the data in mysql.

Where I am stucked is, when user hit submit on page1.html, I need to page2.php to come and at the same time save those details to database using page4.php.
ANd
If user choose to edit, the data will be edited in mysql when confirmed button is pressed on page3.php.

I am giving a short coding for 3 pages:

Page 1: (HTML- FORM)
<html>
<body>
<form action="page2.php" method="post">
Name : <input type="text" name="name"/>
<input type="submit" value="Submit"/>
</form>
</body>
</html>


PAGE 2 (Displaying Input Values)
<html>
<?php session_start();?>
<body>
<form action="page3.php" method="post">
Name :<?php
$name=$_POST;
$_SESSION=$name;
echo $_SESSION; ?>

<input type="Submit" value="Edit">
</form>
</body>
</html>

Page 3 (editing field with prefilled fields)

<html>
<?php session_start();?>
<head>
<?php
$name=$_SESSION;
$discount=$_SESSION;
echo
"<form action=\"page4.php\" method=\"POST\">
Name :<input type=\"text\" name=\"name\" value=\"$name\"/> </br>
<input type=\"submit\" value=\"Confirmed\"/>";
?>
</body>
</html>


THank you ver very much.......

If you are not using any framework and wanted this done fast, then the approach that I would take is as follows:

- each step would have the presentation and the handlers for $_POST in same page.
- you use a session variable to keep track of what page the next page should be.
- every page would submit to itself and then redirect to the 'next page' using something like header()

the reason I would do this is so that when users click back button, they are not asked to resubmit the form they did previously. It's also cleaner to keep tract of next page in a single variable, in my opinion...

I hope that helps!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.