1

On my homepage, I have two boxes where new users will input their name in the first box, and their email in the second box (image 1).

Once they register, they will be taken to the registration page (or comreg), where their information will automatically be transferred to the form so they do not have to enter it again (image 2).

I have tried a few mixes but none seem to work in joomla. This is what I have tried so far:

First page

<?php
    session_start();
    if(isset($_POST['input1'])
    {
        $input1 = $_POST['input1'];
        $input2 = $_POST['input2'];
        $_SESSION['sessionInput1'] = $input1;
        $_SESSION['sessionInput2'] = $input2;
    }
?>

Second page

<?php
    session_start();
    //retrieve session value
    if(!is_null($_SESSION['sessionInput1'] && !is_null($_SESSION'sessionInput2'])
    {
        $output1 = $_SESSION['sessionInput1'];            
        $output2 = $_SESSION'sessionInput2'];                 
    }          
?>

image1

image 2

Thanks in advance

2
  • Don't use $_POST or $_SESSION. Instead, have a read through the Joomla documentation. Specifically JInput and JSession
    – Lodder
    Apr 20, 2015 at 19:44
  • Joomla has its own session wrapper you should be using, you can retrieve an instanceodd it using JFactory::getSession(). In addition, based on the code you did include, you are doing this with out using any Joomla core functionality, meaning there are countless reasons why the code could be failing. If you can add more of the current code for both initial page and second page it would greatly help. Apr 21, 2015 at 0:20

2 Answers 2

1

As previouly noted, you should be using JFactory::getSession() to access variables.

It is not possible to remember information from Guest session to Registered user session. They are different sessions.

On the other hand, you can store information in different ways to remember some settings, e.g. browser-side cookies / localstorage. At the end, it is App living in the browser that submits information to the server.

1

As the other posters mentioned, you should definitely be using the JInput and JSession classes that are built into Joomla if for no other reason than to ensure your app is secure.

If you are familiar with the Joomla framework, you would also want to investigate using a plugin event on the render form event. At that point, you could check your session and insert the previously entered email and name into the registration form. It requires a bit of work, but that would be the best way to do this so you aren't hacking the Joomla core / template files and you can upgrade Joomla at any time without concern for losing your changes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.