form 2 form

  • buzzby365
  • Proficient
  • Proficient
  • buzzby365
  • Posts: 288

Post 3+ Months Ago

i have a form. the form name is getstarted.php

the action is getstarted.php

the forms basically validates itself, thru a script, then submits the data into a database. no problem there.

what i want to do now is have a form located on a different page transport its data to the getstarted.php form. i have tried to have 2 files. send.htm and recieve.php. the send file i can fill out because its a normal htm form. the action on that form is getstarted.php this will then send the info to getstarted.php. the thing is that because the form getstarted.php has an action that is also getstarted.php the info gets submitted rather than going into the form where other data can be filled in. how do i get the send.htm to submit data to getstarted.php without getstarted submitting?
  • Cafu
  • Student
  • Student
  • Cafu
  • Posts: 97

Post 3+ Months Ago

What is the method on the getstarted.php form? Is it POST?

If so, why don't you use GET as the method on the form in send.htm.

The logic in getstarted.php would then work like this: If I receive data via POST then act as if the getstarted.php form was submitted. If I receive data via GET, act as if the send.htm form was submitted and show the getstarted.php form.

The code might look something like this:


Code: [ Select ]
if (isset($HTTP_POST_VARS)) {

  //getstarted.php submitted - do database stuff

} else if (isset($HTTP_GET_VARS)) {

  //send.htm submitted - show getstarted.php and fill it out

} else {

  //no data submitted, show getstarted.php 

}
  1. if (isset($HTTP_POST_VARS)) {
  2.   //getstarted.php submitted - do database stuff
  3. } else if (isset($HTTP_GET_VARS)) {
  4.   //send.htm submitted - show getstarted.php and fill it out
  5. } else {
  6.   //no data submitted, show getstarted.php 
  7. }
  • buzzby365
  • Proficient
  • Proficient
  • buzzby365
  • Posts: 288

Post 3+ Months Ago

yes, on the getstarted.php i use POST

PHP Code: [ Select ]
if ($_POST['submit'])
 
{
  1. if ($_POST['submit'])
  2.  
  3. {
  • Cafu
  • Student
  • Student
  • Cafu
  • Posts: 97

Post 3+ Months Ago

Ok, then do you see what I am suggesting?

If POST do database stuff
If GET show the form
  • buzzby365
  • Proficient
  • Proficient
  • buzzby365
  • Posts: 288

Post 3+ Months Ago

PHP Code: [ Select ]
if (isset($_POST['submit']))
 
{
 
$user="";
 
$host="localhost";
 
$password="";
 
$database="";
 
//do database stuff
 
}
 
elseif (isset($_POST['sendtoform'])) {
 
echo $_POST['name'];
 
//i am not sure how to get the info from
 
//htm form 1 into this present php form
 
//what line should i use to do it?
 
}
 
else
 
{ //print form
  1. if (isset($_POST['submit']))
  2.  
  3. {
  4.  
  5. $user="";
  6.  
  7. $host="localhost";
  8.  
  9. $password="";
  10.  
  11. $database="";
  12.  
  13. //do database stuff
  14.  
  15. }
  16.  
  17. elseif (isset($_POST['sendtoform'])) {
  18.  
  19. echo $_POST['name'];
  20.  
  21. //i am not sure how to get the info from
  22.  
  23. //htm form 1 into this present php form
  24.  
  25. //what line should i use to do it?
  26.  
  27. }
  28.  
  29. else
  30.  
  31. { //print form


the submit button from the htm for is this:
Code: [ Select ]
<input type="submit" name="sendtoform" value="submit" />


what i am i doing wrong?
  • Cafu
  • Student
  • Student
  • Cafu
  • Posts: 97

Post 3+ Months Ago

Are you saying that isset($_POST['sendtoform']) is not evaluting to true and that echo($_POST['name']); is not being printed out?

Or are you asking where you should go from here?


if you are asking how to get the values submitted into the form, I'd do this:

Code: [ Select ]
$frm = $HTTP_POST_VARS;


then do my input elements on the form like this:

Code: [ Select ]
<input type="text" name="address" value="<?= $frm["address"] ?>">
  • buzzby365
  • Proficient
  • Proficient
  • buzzby365
  • Posts: 288

Post 3+ Months Ago

i managed to do it. i have 2 forms there. the form that is filld in and the blank form that the values are passed to.
PHP Code: [ Select ]
if (isset($_POST['submit']))
 
{//do database stuff, validate, insert etc
 
}
 
elseif (isset($_POST['sendtoform'])) {//blank table below that values are passed to
 
?>
 
<body leftmargin="0" topmargin="0">
  1. if (isset($_POST['submit']))
  2.  
  3. {//do database stuff, validate, insert etc
  4.  
  5. }
  6.  
  7. elseif (isset($_POST['sendtoform'])) {//blank table below that values are passed to
  8.  
  9. ?>
  10.  
  11. <body leftmargin="0" topmargin="0">
  • Cafu
  • Student
  • Student
  • Cafu
  • Posts: 97

Post 3+ Months Ago

That should work fine, but my point was "Why have two forms?" You should be able to do it with one form, and then that one form will be more robust. It would be able to handle many of the problems you have been having with validation because you could choose to have it blank, or fill it out automatically if your validation routine discovers an error.
  • buzzby365
  • Proficient
  • Proficient
  • buzzby365
  • Posts: 288

Post 3+ Months Ago

well its like this. the main php form has 2 blank forms. 1 form that has data passed to it from another file. and one form that is the actual getstartedform.php

both have php validation on it that i am very happy with. its simple but effective. the reason for 2 forms is this: i have an area where ppl can choose kits. beside it i have a quick form allowing ppl to choose the kits as they look and see what the kits do. this lil kit form is linked to the main php form that asks more questions like their personal details and their preferences and so on. they can still navigate to the form via the menu but because we want them to get there as quickly as possible we have made it easily accessible. MARKETING PLOY
  • buzzby365
  • Proficient
  • Proficient
  • buzzby365
  • Posts: 288

Post 3+ Months Ago

using the same technology here how do i pass the value of a checkbox from one form to another. i have managed to do the textfield but i need to do the same for a checkbox.
  • Cafu
  • Student
  • Student
  • Cafu
  • Posts: 97

Post 3+ Months Ago

use an if statement:

Code: [ Select ]
<? if ($color=="blue") { ?>
<input type="checkbox" name="color" value="blue" CHECKED>
<? } else { ?>
<input type="checkbox" name="color" value="blue">
<? } ?>
  1. <? if ($color=="blue") { ?>
  2. <input type="checkbox" name="color" value="blue" CHECKED>
  3. <? } else { ?>
  4. <input type="checkbox" name="color" value="blue">
  5. <? } ?>
  • buzzby365
  • Proficient
  • Proficient
  • buzzby365
  • Posts: 288

Post 3+ Months Ago

i managed to get this code to work.
Code: [ Select ]
<input type="checkbox" name="starterkit2"<? if ($_POST['starterkit']) { echo ' checked="checked"'; } ?>/>


this code does what i want it to do. i had gotten a real complicated code and wanted a simpler/simplified version. i think this is it
cheers anyway

Post Information

  • Total Posts in this topic: 12 posts
  • Users browsing this forum: No registered users and 146 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.