I have posted code for my index() action from TestsController. To tell you what it does is that I login my username and password on that action. Since if you're only going to input the username and password, they are the only data that can go through $this->request->data. Now I will provide a sample table for reference.
CREATE TABLE Persons
(
uid int NOT NULL AUTO_INCREMENT,
username varchar(50),
password varchar(50),
fullname varchar(100),
age int(3),
PRIMARY KEY (uid)
);
public function index()
{
if($this->request->is('post'))
{
if(!$this->Test->findByUsernameAndPassword($this->request->data('Test.username'), $this->request->data('Test.password')))
{
$this->Session->setFlash("bad");
}
else
{
$mysqli = new mysqli("localhost","root", "", "test");
$query = "SELECT * FROM tests WHERE username='jimmorrison'";
$result = $mysqli->query($query);
$row = $result->fetch_array(MYSQLI_ASSOC);
$this->Session->setFlash($row['uid']); //display the corresponding age using setFlash
//$this->Session->setFlash($this->request->data('Test.age')); (this code does not work)
$result->close();
}
}
}
as you can see this is not how it's coded on CakePHP. But I would like to ask some feedbacks on how I am going to do this on Cake? I am using version 2.3.9