Note that there are some explanatory texts on larger screens.

plurals
  1. POCodeIgniter session not setting
    primarykey
    data
    text
    <p>I am using sessions to make a multi-stage form, I want to record the information through each stage using codeIgniter sessions then input the session info all into the database at the end.</p> <p>What I want to do is go from stage 1 in the form, enter a number into an input box, submit it, grab the input number through post and set that number from the post in the session. Then in stage 2 grab the information from the session and simply echo it, then at least I know it's working.</p> <p>I had my code working earlier, but after moving it around and clearing the cache in chrome it suddenly stopped working and I can't see anything that's wrong with. Please note I'm working in chrome, but I've also tried this in firefox and ie. I am loading the session library with config/autoload and have my encryption key set in the config. I have tried closing chrome and reopening it. Any help would be most appreciated!</p> <p>Controller: "scholarshiphistory.php"</p> <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Scholarshiphistory extends CI_Controller { public function __construct(){ parent::__construct(); $this-&gt;load-&gt;model('site_model'); } //stage 1 of multipart form public function addhist_selectstudent(){ $this-&gt;load-&gt;helper('form'); $data = $this-&gt;site_model-&gt;general(); $this-&gt;load-&gt;view('view_addhist_selectstudent',$data); $this-&gt;load-&gt;view('view_footer',$data); //set session info if user submits if($this-&gt;input-&gt;post('studentSearch')){ $this-&gt;session-&gt;set_userdata('studentNationalId', $this-&gt;input-&gt;post('studentSearch')); } } //stage 2 of multipart form public function addhist_scholarshipdetails(){ if (!$this-&gt;session-&gt;userdata('studentNationalId')) { //no session $data["msg"] = "&lt;strong&gt;No session!&lt;/strong&gt;"; } else { //get the userinput from the session $userinput = $this-&gt;session-&gt;userdata('studentNationalId'); $data["msg"] = "ID:". $userinput; } $this-&gt;load-&gt;view("view_addhist_scholarshipdetails",$data); } </code></pre> <p>View: Stage 1 - "view_addhist_selectstudent.php"</p> <pre><code>&lt;?php $formAttributes = array('role' =&gt; 'form', 'style' =&gt; 'width: 600px;'); ?&gt; &lt;?php echo form_open('scholarshiphistory/addhist_scholarshipdetails', $formAttributes); ?&gt; &lt;div class="form-group"&gt; &lt;div class="panel panel-default"&gt; &lt;div class="panel-body"&gt; &lt;div class="form-group"&gt; &lt;label for="studentSearch"&gt;Student:&lt;/label&gt; &lt;input type="text" name="studentSearch" class="form-control" id="studentSearchInput" placeholder="student num" value=""&gt; &lt;br&gt; &lt;span id="searchResult" class="help-block" &gt;&lt;/span&gt; &lt;button id="studentSearchBtn" class="btn btn-default"&gt;Search&lt;/button&gt;&lt;!--search button returns info on user input in span above--&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;button id="studentSubmitBtn" type="submit" class="btn btn-default" &gt;Next&lt;/button&gt; &lt;!--this is the submit button--&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>View: Stage 2 - "view_addhist_scholarshipdetails"</p> <pre><code>&lt;?php echo $msg; ?&gt; </code></pre> <p>When I run the code I get to the view 'view_addhist_scholarshipdetails' and it shows the first branch of the if statement in the function addhist_scholarshipdetails in the controller, i.e "no session".</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload