The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sessions over multiple pages
#1
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>
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>
</pre>

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>
</pre>

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>
</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.

  Reply


Messages In This Thread
Sessions over multiple pages - by justawebbie - 05-21-2018, 03:31 PM
RE: Sessions over multiple pages - by Brandin - 07-09-2018, 10:33 PM
Sessions over multiple pages - by Brandin - 05-21-2018, 08:35 PM
Sessions over multiple pages - by Brandin - 05-21-2018, 08:35 PM
RE: Sessions over multiple pages - by justawebbie - 07-09-2018, 09:20 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)