Jump to content


Photo

Linking Forms


  • Please log in to reply
2 replies to this topic

#1 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 27 September 2006 - 03:54 PM

Ok, so what i need to do is link 2 forms together with Id, i have done something like it before, but not this way.... and Im now just confused.

So firstly what i have is an initial enquiry form. where they can select personal details, for a holiday, and they can select a type, which is either Hotel, Villa or Gold, and when they sumbit this form it goes to a larger form depending on what type they have selected, so if the select golf as the type on the first one, it will go to the golf form when sumbimitted.

Now through both of these forms, i need to have the same reference number through both, which i am using the id from the first form for this.

So basically how do i do this

#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 27 September 2006 - 04:37 PM

When the first form is submitted, you place the id into a session variable...

<?php
sesion_start();
$_SESSION['id'] = $_GET['id'];
?>

Then you create your if statement...

<?php
if ($_GET['type'] == "Hotel"){
   header("Location: hotel.php");
}
else if ($_GET['type'] == "Villa"){
   header("Location: villa.php");
}
else if ($_GET['type'] == "Golf"){
   header("Location: golf.php");
}
?>

Then your golf.php looks something a little like this:

<?php
session_start()
echo <<<HTML
<input type="hidden" name="id" value="{$_SESSION['id']}">
<input type="text" name="details">
HTML;
?>

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 27 September 2006 - 05:40 PM

or
on first form
<input type='hidden' name='id_num' value='".$id_num."' />

on the second form,
<input type='hidden' name='id_num' value='".$_POST["id_num"]."' />
Tell me the problem, I will try tell you the solution




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users