I have a button that POST data to my site
<form action="https://www.mysite.co.uk/some/index.php" method="POST">
<input type="hidden" name="userid" value="ZUpmenVaN0ZVTTBmejNGZGNwZGFha1NmR0tuSjdaT3VYdjV5cTF4WGtISzRvK0ptOC9vZmQyc3J3T3cwTmplbWZ3alhod0xMYUhlQ2xLSng4WWI4ZEE9PQ2">
<input type="submit" value="Go" style="font-size:14px; padding:20px;">
</form>
I then turn it into usable session
mysite.co.uk/some/index.php
<?php session_start();
<?php
if (isset($_POST['userid'])) {
$_SESSION['userid'] = $_POST['userid'];
$userid = $_SESSION['userid'];
}
if (isset($_SESSION['userid'])) {
echo "You are logged in and have access to these tests.";?>
code here
<?php
} else {
header ('location: ../index.htm');
}
?>
this all works well.
I now want to use this within a countersign project with the same website (this is where it goes wrong)
mysite.co.uk/some/tests/ETray/New/
<?php
$this->load->library('session');
$this->session->set_userdata('user_id', $_POST['userid']);
$userID = $this->session->userdata('user_id');
echo "$userID";
?>
I get error
Message: Undefined index: userid
unless I post direct to this page like
<form action="https://www.mysite.co.uk/some/tests/ETray/New/" method="POST">
<input type="hidden" name="userid" value="ZUpmenVaN0ZVTTBmejNGZGNwZGFha1NmR0tuSjdaT3VYdjV5cTF4WGtISzRvK0ptOC9vZmQyc3J3T3cwTmplbWZ3alhod0xMYUhlQ2xLSng4WWI4ZEE9PQ2">
<input type="submit" value="Go" style="font-size:14px; padding:20px;">
</form>
Then no error and the echo prints out.
Question
how do I get this to echo out on this page with the first form not the second ?
Looks like that error Message: Undefined index: userid
is due to the undefined index of $_POST['userid']
Another one, where does mysite.co.uk/some/tests/ETray/New/
points to?? Is that inside controller or where???