Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form method="POST" action="page_next.php">
- <input name="first" value="">
- <input type="submit" value="Next">
- </form>
- <form method="POST" action="page_last.php">
- <input name="second" value="">
- <input type="submit" value="Next">
- <input type="hidden" name="<?php echo $_POST['first']; ?>"
- </form>
- <form method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
- <input name="last" value="">
- <input type="submit" value="Next">
- <input type="hidden" value="<?php echo $_POST['first']; ?>" name="first">
- <input type="hidden" value="<?php echo $_POST['second']; ?>" name="second">
- <input type="hidden" value="TRUE" name="submitted">
- </form>
- <?php
- if ($_POST['submitted'] == true) {
- // your code for insert to database
- // example:
- $servername = "localhost";
- $username = "username";
- $password = "password";
- $dbname = "myDB";
- $first = $_POST['first'];
- $second = $_POST['second'];
- $last = $_POST['last'];
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "INSERT INTO MyTable (first, second, last)
- VALUES ('$first', '$second', '$last')";
- if ($conn->query($sql) === true) {
- echo "New record created successfully";
- } else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- $conn->close();
- }
- ?>
Add Comment
Please, Sign In to add comment