andyellen Posted October 26, 2015 Share Posted October 26, 2015 here is my form.php <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content=""> <title>My Post page</title> <link rel="stylesheet" href="css/bootstrap.min.css"> <link rel="stylesheet" href="css/bootstrap-theme.min.css"> <link rel="stylesheet" type="text/css" href="css/style.css"> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <section><!-- Header --> <h1>moriahtalk</h1> <h2>Speak your mind.</h2> <form action="demo.php" method="post"> <textarea required name="text" placeholder="Write Something..." id="text" cols="30" rows="10"></textarea> <input type="submit" name="submit" value="button"> </form> </form> </section> </body> </html> and this is demo.php <?php $servername = "localhost"; $dbusername = "root"; $dbpassword = ""; $dbname = "forms"; $text = $_POST ['text']; // Evaluate the connection $conn = new mysqli ($servername, $dbusername, $dbpassword, $dbname); //check connection if ($conn->connect_error) { die("conection failed: " . $conn->connect_error); } if (empty($text)) { echo " This cannot be blank at all"; die (); } $sql = "INSERT INTO demo (text) VALUES ('$text')"; if ($conn->query($sql) ==TRUE) { echo " Your info has been submitted"; } else { echo "error: " . $sql . "<br>" . $conn->error; } $conn->close(); ?> when i submit data. it stores on the database. But I want to display that date on another page. please tell me how do I do this? also how can I apply bootstrap and CSS to that page Quote Link to comment https://forums.phpfreaks.com/topic/298841-need-to-display-data-form/ Share on other sites More sharing options...
printf Posted October 26, 2015 Share Posted October 26, 2015 Use sessions, or just do a redirect with the date value in your url. Quote Link to comment https://forums.phpfreaks.com/topic/298841-need-to-display-data-form/#findComment-1524376 Share on other sites More sharing options...
andyellen Posted October 26, 2015 Author Share Posted October 26, 2015 how do I do that? can you please show some example using my code? Quote Link to comment https://forums.phpfreaks.com/topic/298841-need-to-display-data-form/#findComment-1524377 Share on other sites More sharing options...
benanamen Posted October 26, 2015 Share Posted October 26, 2015 (edited) how can I apply bootstrap and CSS to that page The Manual is a good place to start. (Bootstrap IS Css) * OP typed "date" but I think he meant data. There is no date in his code. Edited October 26, 2015 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/298841-need-to-display-data-form/#findComment-1524380 Share on other sites More sharing options...
Adam Posted October 26, 2015 Share Posted October 26, 2015 (edited) After saving the data in the database, you need to retrieve the last inserted ID, and then redirect the user to another URL with that ID passed as some kind of parameter. This other URL will then run a script that fetches the information back from the database using the ID passed in the URL, and then display it in some kind of template. Individually they're all relatively simple things to do; just google them separately, and put the pieces together. Edited October 26, 2015 by Adam Quote Link to comment https://forums.phpfreaks.com/topic/298841-need-to-display-data-form/#findComment-1524385 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.