I have a simple form asking a user for their membership ID number. On Submit, php code is executed to search for a match in my database of users. When match is found, I need to transfer membership type to populate a field in my 2nd form. How can I do this? Thanks.
you could store the membership type as a different var and then display it if it exists
[php]
/* Checking database code here */
$memtype = $row[‘foo’];
/* Some code here */
if(isset($memtype)){
echo $memtype;
}
[/php]
This is an example of my first form…
<form id="form1" name="form1" method="post" action="some-code.php">
<p>
<label for="">Enter Membership ID</label>
<input name="membership_id" type="text" id="membership_id" tabindex="1" />
</p>
<p>
<label for="button"></label>
<input type="submit" name="button" id="button" value="Submit" />
</p>
</form>
“some-code.php” will search for a database match to membership_id. When found, I need to open the 2nd form and have membership_id assigned to the “membership_type” field in the 2nd form…
<form id="form2" name="form2" method="post" action="some-other-code.php">
<p>
<label for="membership_type">Membership Type</label>
<input type="text" name="membership_type" id="membership_type" tabindex="1" />
</p>
<p>
<label for="membersip_fee">Membersip Fee</label>
<input type="text" name="membersip_fee" id="membersip_fee" tabindex="2" />
</p>
<p>
<label for="button2"></label>
<input type="submit" name="button2" id="button2" value="Submit" />
</p>
</form>
So if I use
[php]
if(isset($memtype)){
echo $memtype;
[/php]
this will assign database value to “membership_type”? I thought echo would just print to screen.
ah, in that case, why not have this?
[php]if(isset($_POST[‘button’])){
/* fetch database information here */
header('Location: ’ . $_SERVER[‘PHP_SELF’] . ‘?form=/variable/’);
}
/* more code */
if(isset($_GET[‘form’])){
$variable = $_GET[‘form’];
/* display form */
}
[/php]
if you want it to be a default value for an input, then this
<input name="membership_id" type="text" id="membership_id" tabindex="1" value="<?= $variable; ?>" />