Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to disable direct access to callback functions?
    primarykey
    data
    text
    <pre><code>&lt;? if ( ! defined('BASEPATH')) exit(); class Registration extends CI_Controller { public function __construct() { parent::__construct(); $this-&gt;load-&gt;model('registration_model'); } public function index() { $this-&gt;load-&gt;library('form_validation'); $this-&gt;form_validation-&gt;set_rules('email', 'E-mail', 'trim|required|valid_email|callback_email_available'); if($this-&gt;form_validation-&gt;run() == FALSE) { $this-&gt;load-&gt;view('registration'); } else { $this-&gt;registration_model-&gt;add_user(); } } # Check E-mail public function email_available($email) { $this-&gt;db-&gt;select('email'); $this-&gt;db-&gt;where('email', $email); $query = $this-&gt;db-&gt;get('users'); $result = $query-&gt;row(); if(!empty($result)) { $this-&gt;form_validation-&gt;set_message('email_available', 'This e-mail belongs to another user.'); return FALSE; } else { return TRUE; } } } ?&gt; </code></pre> <p>I have a registration form with Form Validation. And I have a callback function to validate email uniqueness.</p> <p>All code works fine, but I can directly access to callback function with errors</p> <p>examle.com/registration/email_available</p> <pre><code>A PHP Error was encountered Severity: Warning Message: Missing argument 1 for Registration::email_available() Filename: controllers/registration.php A PHP Error was encountered Severity: Notice Message: Undefined variable: email Filename: controllers/registration.php </code></pre> <p>How can I deny direct access to callback function?</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.
    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