Jump to content

Form1 field to auto populate Form2 same domain


AllenHobson

Recommended Posts

Hi Everyone,

 

Please can you guide me to solving my issue:

 

I have Form1 with fields one being the PK in mySQL (called callsign)

Once I submit the data it enters into the DB no issues.

 

I want to be able to take Form1.callsign once submitted, redirect and insert it into Form2.callsign

 

Is this possible? I got the Redirect to work no problem after the data is inserted.

 

I have been looking on Web and here and cant seem to find the answer to populate form2 from form1 field.

 

Can I use a Variable somehow?

 

I know there is an issue with submitting data to a 3rd party for security reasons etc, but I want when entering records on my own domain to autopopulate the next form with this callsign (which is the primary key) This way I get to link all 10 tables together using this key making the entire full record for the member.

 

Any Assistance would be greatly appreciated.

 

Thanks

 

Allen

Link to comment
Share on other sites

Hi Everyone,

 

I thought I better attach the code for better understanding....

 

Thanks in Advance...

 

 

 

First Form

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Personal Details</title></head>

<body>
<form method="post" action="personaldetails_add.php"><font face="Arial">

Call Sign:<br>
  <input name="callsign" size="5" type="text" AUTOCOMPLETE=OFF><br>

Surame:<br>
  <input name="surname" size="30" type="text" AUTOCOMPLETE=OFF><br>

First Name:<br>
  <input name="firstnames" size="30" type="text" AUTOCOMPLETE=OFF><br>

Known as:<br>
  <input name="knownas" size="30" type="text" AUTOCOMPLETE=OFF><br>

RSA ID No.:<br>
  <input name="rsaid" size="13" type="text" AUTOCOMPLETE=OFF><br>

Birth Date:<br>
  <input name="birthdate" size="12" type="text" AUTOCOMPLETE=OFF><br>

</font><br>

<input name="Next" value="Next" type="submit">

</form>
</body>
</html>

 

First php processor

 

<?php
$callsign = $_POST['callsign'];
$surname = $_POST['surname'];
$firstnames = $_POST['firstnames'];
$knownas = $_POST['knownas'];
$rsaid = $_POST['rsaid'];
$birthdate = $_POST['birthdate'];
mysql_connect ("localhost", "jredpixm_testuse", "PHPDevelopment") or die ('I cannot connect to the database because: ' .mysql_error());
mysql_select_db ("jredpixm_test");
$query="INSERT INTO personal_details (callsign, surname, firstnames, knownas, rsaid, birthdate)Values ('$callsign', '$surname', '$firstnames', '$knownas', '$rsaid', '$birthdate')";

mysql_query($query) or die ('Error Inserting Data into Database');

header("Location: contactdetails.html");
die;
?>

 

Second Form

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Contact Details</title>
</head>
<body>

<form method="post" action="contactdetails_add.php"><font face="Arial">

Call Sign:<br>
  <input name="callsign" size="5" type="text" AUTOCOMPLETE=OFF><br>
Company:<br>
<input name="company" size="30" type="text" AUTOCOMPLETE=OFF><br>
Email:<br>
<input name="email" size="50" type="text" AUTOCOMPLETE=OFF><br>
Job Title:<br>
<input name="jobtitle" size="50" type="text" AUTOCOMPLETE=OFF><br>
Business Phone:<br>
<input name="bphone" size="50" type="text" AUTOCOMPLETE=OFF><br>
Home Phone:<br>
<input name="hphone" size="50" type="text" AUTOCOMPLETE=OFF><br>
Mobile Phone:<br>
<input name="mphone" size="50" type="text" AUTOCOMPLETE=OFF><br>
Facsimile Phone:<br>
<input name="fphone" size="50" type="text" AUTOCOMPLETE=OFF><br>
<br>
Home Address:<br>
<input name="haddress" size="50" type="text" AUTOCOMPLETE=OFF><br>
Home City:<br>
<input name="hcity" size="50" type="text" AUTOCOMPLETE=OFF><br>
Home Code:<br>
<input name="hcode" size="50" type="text" AUTOCOMPLETE=OFF><br>
Home Province:<br>
<input name="hprovince" size="50" type="text" AUTOCOMPLETE=OFF><br>
Home Country:<br>
<input name="hcountry" size="50" type="text" AUTOCOMPLETE=OFF><br>
Home Co Ordinates Southings:<br>
<input name="hsouthings" size="50" type="text" AUTOCOMPLETE=OFF><br>
Home Co Ordinates Eastings:<br>
<input name="heastings" size="50" type="text" AUTOCOMPLETE=OFF><br>
<br>
Work Address:<br>
<input name="waddress" size="50" type="text" AUTOCOMPLETE=OFF><br>
Work City:<br>
<input name="wcity" size="50" type="text" AUTOCOMPLETE=OFF><br>
Work Code:<br>
<input name="wcode" size="50" type="text" AUTOCOMPLETE=OFF><br>
Work Province:<br>
<input name="wprovince" size="50" type="text" AUTOCOMPLETE=OFF><br>
Work Country:<br>
<input name="wcountry" size="50" type="text" AUTOCOMPLETE=OFF><br>
<br>

</font><br>

<input name="Next" value="Next" type="submit"></form>

</body>
</html>

 

Second Form php processor

 

<?php>
$callsign = $_POST['callsign'];
$company = $_POST['company'];
$email = $_POST['email'];
$jobtitle = $_POST['jobtitle'];
$bphone = $_POST['bphone'];
$hphone = $_POST['hphone'];
$mphone = $_POST['mphone'];
$fphone = $_POST['fphone'];
$haddress = $_POST['haddress'];
$hcity = $_POST['hcity'];
$hcode = $_POST['hcode'];
$hprovince = $_POST['hprovinc'];
$hcountry = $_POST['hcountry'];
$hsouthings = $_POST['hsouthings'];
$heastings = $_POST['heastings'];
$waddress = $_POST['waddress'];
$wcity = $_POST['wcity'];
$wcode = $_POST['wcode'];
$wprovince = $_POST['wprovince'];
$wcountry = $_POST['wcountry'];

mysql_connect ("localhost", "jredpixm_testuse", "PHPDevelopment") or die ('I cannot connect to the database because: ' .mysql_error());
mysql_select_db ("jredpixm_test");

$query="INSERT INTO contactdetails (callsign, company, email, jobtitle, bphone, hphone, mphone, fphone, haddress, hcity, hcode, hprovince, hcountry, hsouthings, heastings, waddress, wcity, wcode, wprovince, wcountry) Values ('$callsign', '$callsign', '$company', '$email', '$jobtitle', '$bphone', '$hphone', '$mphone', '$fphone', '$haddress', '$hcity', '$hcode', '$hprovince', '$hcountry', '$hsouthings', '$heastings', '$waddress', '$wcity', '$wcode', '$wprovince', '$wcountry')";

mysql_query($query) or die ('Error Inserting Data into Database');

header("Location: contactdetails.html");
die;

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.