05-21-2018, 03:31 PM
I am new to sessions but I was trying to carry variables from my custom forms over several pages. My variables are not carrying from page to page. I added the session start function to my header as it was mentioned in an article but I also found info on putting it all in one step above the form:
`<?php
// Start the session
session_start();
?>`
My first page form looks like this:
<pre></pre>
Second form, session is in header as described above:
<pre></pre>
My third page, session start is in the header:
<pre></pre>
What am I doing wrong? Do I need to use the session which userspice uses to accomplish this task. If so how would I do that.
`<?php
// Start the session
session_start();
?>`
My first page form looks like this:
<pre>
Code:
<form method="post" action="form2.php">
<input type="text" name="name">
<input type="text" name="email_address">
<input type="submit" value="Go To Step 2">
</form>
Second form, session is in header as described above:
<pre>
Code:
<?php
//now, let's register our session variables
session_register('name');
session_register('email_address');
//finally, let's store our posted values in the session variables
$_SESSION['name'] = $_POST['name'];
$_SESSION['email_address'] = $_POST['email_address'];
?>
<form method="post" action="form3.php">
<select name="db_name">
<option value="1">Database 1</option>
<option value="2">Database 2</option>
<option value="3">Database 3</option>
</select>
<input type="radio" name="membership_type" value="Free">
<input type="radio" name="membership_type" value="Normal">
<input type="radio" name="membership_type" value="Deluxe">
<input type="checkbox" name="terms_and_conditions">
<input type="submit" value="Go To Step 3">
</form>
My third page, session start is in the header:
<pre>
Code:
<?php
//now, let's register our session variables
session_register('db_name');
session_register('membership_type');
session_register('terms_and_conditions');
$_SESSION['db_name'] = $_POST['db_name'];
$_SESSION['terms_and_conditions'] = $_POST['terms_and_conditions'];
$_SESSION['membership_type'] = $_POST['membership_type'];
?>
<form method="post" action="form_process.php">
<input type="text" name="name_on_card">
<input type="text" name="credit_card_number">
<input type="text" name="credit_card_expiration_date">
<input type="submit" value="Finish">
</form>
What am I doing wrong? Do I need to use the session which userspice uses to accomplish this task. If so how would I do that.