- I am trying to create a form for the parents in a school to book after-school care for their children through the school website, which is built using Expression Engine.
- Parents would log-in with their their family ID (a number matching the family record number in the database). Then, on the booking page, they would select from a drop-down list of their own children which child they would like to make the booking for.
On the landing page after parent log-in, I have put the following PHP code:
<?php
$_SESSION['familyid']='{username}';
$_SESSION['family']='{screen_name}';
?>
I did this on a separate page to the booking page because I thought there might be an issue with global variables being parsed last in ExpressionEngine. Then on the booking page, I have:
$con=mysqli_connect("server","database","password");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql = "SELECT ChildID, Child FROM Children WHERE FamilyID = '".$_SESSION['familyid']."'";
$result = $con->query($sql);
$data = mysql_fetch_array($result);
but this does not return any children. If I give the session variable a valid number manually, it works, but I can't get the sql to work where the username has been passed to the variable. Is what I'm trying to do even possible?