So I am fairly new to php I have some php code that confirms a user has been added into a group and then submits their information into the database but it doesn't seem to be adding all the information
<?php
/* Verifies member being added
*/
require 'db.php';
session_start();
// Make sure join code and email aren't empty
if(isset($_GET['joincode']) && !empty($_GET['joincode']) AND isset($_GET['memberemail']) && !empty($_GET['memberemail']))
{
$joincode = $link->escape_string($_GET['joincode']);
$memberemail = $link->escape_string($_GET['memberemail']);
// Select user with matching email
$result = $link->query("SELECT * FROM logins WHERE Email='$memberemail'");
if ( $result->num_rows !==1 )
{
$_SESSION['message'] = "You need to create an account or the URL is invalid!";
header("location: error.php");
}
else {
$_SESSION['message'] = "You have been added!";
while ($id = $result->fetch_assoc()){
$id['unique_id'];
}
$leagueinfo = $link->query("SELECT * FROM leagues WHERE joincode='$joincode'");
$info = $leagueinfo->fetch_assoc();
$info['league_id'];
$info['league_name'];
$info['start_date'];
$info['end_date'];
$sql = "INSERT INTO leagues (unique_id, league_id, league_name, role, start_date, end_date, joincode) "
. "VALUES ('".$id['unique_id']."','".$info['league_id']."','".$info['league_name']."','MEMBER',
'".$info['start_date']."','".$info['end_date']."','".$joincode."')";
mysqli_query($link,$sql);
// header("location: success.php");
}
}
else {
$_SESSION['message'] = "Invalid parameters provided for account verification!";
header("location: error.php");
}
?>
I've changed the names of the different queries and it's now pulling all information except for the unique_id which echoes out correctly but isn't being added into the database.