Jump to content

Recommended Posts

I am creating a multi-step registration process, and am having some issues. I am aware one way to accomplish this is the sessions. I am still learning php and am not very familiar with how to accomplish this, and google searches aren't helping much. I would like to know how to create the sessions to tore the information, and also recall the stored values for mysql injection after payment is verified. I am somewhat familiar with basic syntax. Any help is appreciated.

Link to comment
https://forums.phpfreaks.com/topic/173296-passing-data-from-one-form-to-another/
Share on other sites

I am creating a multi-step registration process, and am having some issues. I am aware one way to accomplish this is the sessions. I am still learning php and am not very familiar with how to accomplish this, and google searches aren't helping much. I would like to know how to create the sessions to tore the information, and also recall the stored values for mysql injection after payment is verified. I am somewhat familiar with basic syntax. Any help is appreciated.

 

You start the session on any page that requires storing or retrieving data from the session:

 


<?php
session_start();

 

You can then use the $_SESSION array for whatever you need.

 


<?php
//store data
$_SESSION['my_key'] = 'my_value';
//retrieve data
$data = $_SESSION['my_key'] ;
//delete
unset($_SESSION['my_key']);

 

This $_SESSION array is saved on the server, and the cookie that is put in the user's browser identifies them to use the session that belongs to them. If the user doesn't have cookies enabled, then there is sometimes a fallback to the session ID being placed in the URL, but this isn't the best thing to do.

I suck with sessions so what i do is when doing a multi step form is i save the data from each step into a hidden input .

 

here is an example of a multi-step form

 

http://jnerocorp.com/tests/find.php

 

if this is what u are looking for I will help you set it up

Basically sessisons ;

Usage ;

<?php
// file1.php
session_start(); // FIRST LINE  should be this 
.
.
.
$_SESSION['color']='red';
?>

Then ;

<?php
// file2.php let's say
session_start(); // again FIRST LINE should be this where ever you will use session.
.
// codes and stuff.. 
.
.
echo $_SESSION['color'];
?>

So this will print ;

red

That's how you store information and use it.

Also for to destroy the data in the sessions;

<?php
unset($_SESSION['color']);
?>

Without even trying to understand the dynamics of how sessions work in php, all you have to know is that there is an array which you can store data, and that array is $_SESSION. This array is available to you anytime session_start() is placed before any output to the browser. If you don't know how to work with arrays, your chances of using sessions are limited at best.

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.