Benjamin Oats Benjamin Oats - 8 days ago 8
PHP Question

Pass value to codeigniter and get it

I have a form I am sending the value a that is 999

<script>
var a = "999";
</script>

<form action="tests/ETray/New/" method="POST">
<input id="start-test" type="hidden" name="userid" value="">
<input type="submit" value="Go" style="font-size:14px; padding:20px;">
</form>

<script>
$(document).ready(function(event){
$('#start-test').val(a);
})
</script>


I now want to use that in codeigniter, how do I use this ?

Answer

CodeIgniter is a PHP framework. You can use the $_POST variable or the input class:

$_POST['userid'];
// OR
$this->input->post('userid');

The input class gives you the ability to automatically prevent cross-site scripting attacks.