jwk811 Posted August 26, 2006 Share Posted August 26, 2006 I've been looking around for a while on how to get data from a form to be used in more than one page. Now, I found this website that gave this php feature called feild_forwarder that forwards all data submitted in a form to another form. Does this only work if the first form is posted to the next form or could it still work if it was redireced to it or something. Here where I got all this information:[url=http://www.tutorialized.com/tutorial/Multi-page-Forms-with-PHP/735]http://www.tutorialized.com/tutorial/Multi-page-Forms-with-PHP/735[/url] and at the bottom if you click back there is another page. Check this out if you can and tell me what this is all about if you can because I don't get it. Quote Link to comment https://forums.phpfreaks.com/topic/18692-feild-forwarder/ Share on other sites More sharing options...
blacknight Posted August 26, 2006 Share Posted August 26, 2006 have you thought of sessions or cookies? Quote Link to comment https://forums.phpfreaks.com/topic/18692-feild-forwarder/#findComment-80604 Share on other sites More sharing options...
Iceman512 Posted August 26, 2006 Share Posted August 26, 2006 Hi jwk811,This method will work, but it has disadvantages. What happens if the user accidently closes or refreshes their browser? Oops!I don't know whether this is what you want, but you could use [color=blue][b]mySQL[/b][/color] to solve your problem. It's a little complicated, but you could do the following:1. Create the page containing the form. [b]eg: [color=red]login.html[/color][/b]2. Set the action of the form to your submit page [b]eg: [color=red]/includes/login.php[/color][/b]3. On the [b]login.php[/b] page, make a simple refresh, such as: [code]<?phpheader("Refresh: 2; url=http://www.your-site.com/next_form.php");?>[/code]This page ([b]login.php[/b]) will enter the data into your [color=blue][b]mySQL[/b][/color] database and redirect the user to the next form automatically after 2 seconds.4. Create your next form, retrieving the info just entered from the db and displaying it onto the page.The user will see the data they just entered.6. You can then set the action of the form to update or create a new form using the updated data.This method will be slower than others, but it's pretty bulletproof and has many advantages. Such as; you have the form data in a database, so you can manipulate or use it in any way later on.Hope this help you!Iceman Quote Link to comment https://forums.phpfreaks.com/topic/18692-feild-forwarder/#findComment-80658 Share on other sites More sharing options...
jwk811 Posted August 26, 2006 Author Share Posted August 26, 2006 Thanks Iceman but complicated must be way to complicated from where I'm at now. That's an option and I think I'm going to try it out because that seems exactly what I need, but how does this work. You said just do the refresh method and then what? How will I get the information in my database and what will come up on the next page? Can I just take any information out from the database. I am VERY new to this and haven't dealt with it before. Someone please help. And black night I have thought of sessions or cookies but they as well as this seem a bit too complicated and I'm trying my best to learn all this. Any help will be great! Quote Link to comment https://forums.phpfreaks.com/topic/18692-feild-forwarder/#findComment-80779 Share on other sites More sharing options...
jwk811 Posted August 26, 2006 Author Share Posted August 26, 2006 The feild forwarder would only work if the action of the form was to the next form you wanted to attach the information from right? I going to need it either way for a little part and going to need something else like iceman or blacknight was saying before. Say if I take data submitted in a form to the next page and catch it all in that form (which is going to be a verification form) as a hidden feild and once they confirm that I want that information emailed to me, but how to you get hidden feilds to come up in an email? Quote Link to comment https://forums.phpfreaks.com/topic/18692-feild-forwarder/#findComment-80789 Share on other sites More sharing options...
jwk811 Posted August 27, 2006 Author Share Posted August 27, 2006 ??? Quote Link to comment https://forums.phpfreaks.com/topic/18692-feild-forwarder/#findComment-81248 Share on other sites More sharing options...
Iceman512 Posted August 28, 2006 Share Posted August 28, 2006 Hey jwk811,Sorry for not replying sooner, been out of action for a few days. Anyway, to answer you plight, take a look at the following links for an excellent grounding in PHP MySQL:[color=blue]http://www.w3schools.com/php/default.asphttp://www.phpbuddy.com/http://www.freewebmasterhelp.com/tutorials/phpmysqlhttp://www.php-mysql-tutorial.com/[/color]It will be easier if you could just copy the code for your problem from somewhere, but I assure you, it will be well worth it to learn a little php first. It will certainly pay off later and save you many headaches.[b]Moving on:[/b]Anyway, as I was saying, you use a MySQL INSERT query on page 1, which is your form. Using this query, you put the form data into the database when the user submits the form.You then redirect the user to the second form page (using that 'refresh' code), where you grab the data from the database and echo it back to the page, example:[code]<?php$con = mysql_connect("dbhost","dbuser","dbpass");if (!$con) { die('Could not connect to the database: ' . mysql_error()); }if(isset($_POST['id'])){$id = $_POST['id'];mysql_select_db("dbname", $con);$result = mysql_query("SELECT * FROM dbname WHERE id='$id';");while($row = mysql_fetch_array( $result )) {{?><table align="center" width="800"><tr><td><form action="Update/Form/Page" method="POST"><input type="hidden" name="id" value="<?php echo $row['id']; ?>">Author:<input type="text" name="author" value="<?php echo $row['author']; ?>"><br />Date: <input type="text" name="date" value="<?php echo $row['date']; ?>"><br />Body:<textarea name="body"><?php echo $row['body']; ?></textarea><br /><br /><table align="center" width="800"><tr><td align="center"><input type="submit" value="Update Form"></td></tr></table></form></td></tr></table><?php } }}?>[/code]When the user submits this form, it will update the existing info with the new stuff entered by the user.Obviously, it needs some adjusting, but it's a good example to study.Don't worry, keep with it & you'll soon figure it out!Post again if you have problems,Iceman Quote Link to comment https://forums.phpfreaks.com/topic/18692-feild-forwarder/#findComment-81764 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.