General developer forum

Send processed form data to a new page that displays results

 
Davo
Re: Send processed form data to a new page that displays results
Core developersParticularly helpful MoodlersPlugin developers

Unless you really have a good reason to do this, the more usual way of using forms is to leave the form to submit to the current page. That way, any validation errors can be displayed on the original form, before the data is processed.

 
Average of ratings: -
Picture of Amir Mustafa
Re: Send processed form data to a new page that displays results
 

Hello,

Did you success in sending data to the next page. I am facing similar issue. My current page contains lots of parameters and on form submit all the parameters are lost. Therefore not able to receive data.

Can you please guide me how to send data to the next page.

M CODE:
/* Class :Start */
require_once($CFG->libdir.'/formslib.php');
require_once($CFG->libdir.'/completionlib.php');
require_once($CFG->libdir. '/coursecatlib.php');

class traininginfo_form extends moodleform {

function definition () {
            $mform =$this->_form;
            $mform->addElement('header', 'descriptionhdr', 'Notes');
    $mform->setExpanded('descriptionhdr');

        
       $mform->addElement('text', 'shortname', get_string('shortnamecourse'), 'maxlength="100" size="20"');
$mform->addHelpButton('shortname', 'shortnamecourse');
$mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client');
$mform->setType('shortname', PARAM_TEXT);


$this->add_action_buttons(false, 'submit');
        }
    }

    $ti_form = new traininginfo_form('gradeform.php');    // how to receive data in this new page
    /* if ($ti_form->is_cancelled()) {
        echo '<h1>not received</h1>';
        // Redirect to somewhere if the user clicks cancel
    }

    if ($data = $ti_form->get_data()) {
        echo '<h1>data received</h1>';
        // Do something with the data, then redirect to a new page
    } */

    // You should really output the page header before this
    $ti_form->display();

Thank you for your help in advance.

 
Average of ratings: -
Picture of Amir Mustafa
Re: Send processed form data to a new page that displays results
 

Hello,

I succeeded, it was basic $_REQUEST data;

when we use 

echo '<pre>'; print_r($_REQUEST); in the target page it shows all the data.

Happy me smile

 
Average of ratings: -