Note that there are some explanatory texts on larger screens.

plurals
  1. POCode Igniter form validation stops script
    primarykey
    data
    text
    <p>I developed a simple CMS system with Code Igniter locally with XAMPP. It was running and working, but when I deployed it to my server the script stops when I call </p> <pre><code>$this-&gt;form_validation-&gt;run(); </code></pre> <p>in the following code:</p> <pre><code>public function check_login(){ echo $this-&gt;load-&gt;library('form_validation'); $this-&gt;form_validation-&gt;set_rules('username', 'Benutzername', 'required|trim|xss_clean|callback_validate_credentials'); $this-&gt;form_validation-&gt;set_rules('password', 'Passwort', 'required|xss_clean'); echo 'check'; if($this-&gt;form_validation-&gt;run()){ echo 'check:run'; $this-&gt;load-&gt;model('user_model'); $username = $this-&gt;input-&gt;post('username'); $userid = $this-&gt;user_model-&gt;get_userid_by_name($username); $admin = $this-&gt;user_model-&gt;is_user_admin($username); $userdata = array( 'username' =&gt; $username, 'is_admin' =&gt; $admin, 'is_logged_in' =&gt; true, 'user_id' =&gt; $userid ); $this-&gt;session-&gt;set_userdata($userdata); redirect(base_url() . 'blog'); } else { echo 'check:else'; $this-&gt;do_login(); } echo 'check:end'; } </code></pre> <p>The callback function is this one:</p> <pre><code>public function validate_credentials(){ echo 'test'; echo '&lt;pre&gt;'; print_r($_POST); echo '&lt;/pre&gt;'; $this-&gt;load-&gt;model('user_model'); // the script stops here $this-&gt;load-&gt;model('security/pass_hasher'); $username = $this-&gt;input-&gt;post('username'); $password = $this-&gt;input-&gt;post('password'); $hashed_password = $this-&gt;pass_hasher-&gt;hash($password); echo $username . '&lt;br /&gt;'; echo $password . '&lt;br /&gt;'; echo $hashed_password . '&lt;br /&gt;'; print_r($this-&gt;input-&gt;post()); if($this-&gt;user_model-&gt;can_login($username, $hashed_password)){ if($this-&gt;user_model-&gt;is_user_active($username)){ return true; } else { $this-&gt;form_validation-&gt;set_message("validate_credentials", "Benutzeraccount wurde deaktviert!"); return false; } } else { $this-&gt;form_validation-&gt;set_message("validate_credentials", "Benutzername und/oder Passwort ist falsch."); return false; } } </code></pre> <p>For debugging reasons I made some echos. The output is the following:</p> <blockquote> <p>check</p> </blockquote> <p>So the script stops running on the method I mentioned above. Why? I am autoloading <code>form</code> and <code>url</code> in the configs. The Code Igniter enviroment is set to development. And the PHP version on my local machine is 5.4.4 and on the web server is it 5.3.8, both are newer than the required 5.1.6</p> <p>When I manually post data to my <code>validate_credentials()</code> function, I get the following output:</p> <pre><code>test </code></pre> <pre>Array ( [username] => admin [password] => test ) </pre> <p>So the $this->input->post() is not working. But I did not find out why yet.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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