Jump to content


Photo

Feild Forwarder


  • Please log in to reply
6 replies to this topic

#1 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 26 August 2006 - 06:43 AM

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:http://www.tutoriali...ms-with-PHP/735 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.


#2 blacknight

blacknight
  • Members
  • PipPipPip
  • Advanced Member
  • 271 posts
  • Locationsaint john

Posted 26 August 2006 - 07:17 AM

have you thought of sessions or cookies?
if at first your fail google will give you a pass

#3 Iceman512

Iceman512
  • Members
  • PipPipPip
  • Advanced Member
  • 81 posts

Posted 26 August 2006 - 10:52 AM

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 mySQL to solve your problem. It's a little complicated, but you could do the following:

1. Create the page containing the form. eg: login.html
2. Set the action of the form to your submit page eg: /includes/login.php
3. On the login.php page, make a simple refresh, such as:
<?php
header("Refresh: 2; url=http://www.your-site.com/next_form.php");
?>
This page (login.php) will enter the data into your mySQL 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

#4 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 26 August 2006 - 04:21 PM

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!

#5 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 26 August 2006 - 04:45 PM

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?

#6 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 27 August 2006 - 08:43 PM

???

#7 Iceman512

Iceman512
  • Members
  • PipPipPip
  • Advanced Member
  • 81 posts

Posted 28 August 2006 - 07:01 PM

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:

http://www.w3schools...php/default.asp
http://www.phpbuddy.com/
http://www.freewebma...orials/phpmysql
http://www.php-mysql-tutorial.com/

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.

Moving on:
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:
<?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
    }
  }
}
?>

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users