Associate author with submitted article?

<?php
include_once $_SERVER['DOCUMENT_ROOT'] .
		'/includes/magicquotes.inc.php';
include $_SERVER['DOCUMENT_ROOT'] . 
		'/includes/access.inc.php';
		
if (isset($_GET['add']))
  if (!userIsLoggedIn())
{
	  include $_SERVER['DOCUMENT_ROOT'] . '/includes/login.inc.html.php';
	  include $_SERVER['DOCUMENT_ROOT'] . '/includes/db.inc.php';
	  $sql = "SELECT id FROM author 
	        WHERE email = '{$_POST['email']}'"; 
			
	$id = mysqli_query($link, $sql); 
	echo $id;
	  exit();
}
  else
{
    $pagetitle = 'New Article';
	$action = 'addform';
	$text = '';
	$authorid = '';
	$id = '';
	$button = 'Add article';
	
	include 'form.html.php';
	exit();
}
if (isset($_GET['addform']))
{
	include $_SERVER['DOCUMENT_ROOT'] . '/includes/db.inc.php';

	
	$text = mysqli_real_escape_string($link, $_POST['text']);
	
	$sql = "INSERT INTO article SET
			articletext='$text',
			articledate=CURDATE(),
			authorid= ''";
	if (!mysqli_query($link, $sql))
	{
		$error = 'Error adding submitted article: ' . mysqli_error($link);
		include 'error.html.php';
		exit();
	}

	header('Location: .');
	exit();
}
include $_SERVER['DOCUMENT_ROOT'] . '/includes/db.inc.php';

$result = mysqli_query($link, 'SELECT id, articletext FROM article');
if (!$result)
{
	$error = 'Error fetching articles: ' . mysqli_error($link);
	include 'error.html.php';
	exit();
}

while ($row = mysqli_fetch_array($result))
{
	$articles[] = array('id' => $row['id'], 'text' => $row['articletext']);
}

include 'articles.html.php';
?>

could someone please tell me how to associate the current author signed in with the article he/she submits using form.html.php?

How do you keep track of who’s logged in? The answer to your question requires the code you didn’t share.

Carefully read the function userIsLoggedIn() in the include files. If there is no mechanism to remember userID then set a cookie to remember it.

I have tried various methods to all return the same result in my table. There’s a table author with a column id and a table article with a column authorid. The result that I’m shooting for in column auhtorid is the id of the author defined in the id column of the author table

Here’s the access.inc.php with function userIsLoggedIn()

<?php
function userIsLoggedIn()
{
	if (isset($_POST['action']) and $_POST['action'] == 'login')
	{
		if (!isset($_POST['email']) or $_POST['email'] == '' or
			!isset($_POST['password']) or $_POST['password'] == '')
		{
			$GLOBALS['loginError'] = 'Please fill in both fields';
			return FALSE;
		}
		$password = md5($_POST['password'] . 'chainfire db');
		if (databaseContainsAuthor($_POST['email'], $password))
		{	
		include 'db.inc.php';
			session_start();
			$_SESSION['loggedIn'] = TRUE;
			$_SESSION['email'] = $_POST['email']; 
			$_SESSION['password'] = $password;
			return TRUE;
		}
		else
		{
			session_start();
			unset($_SESSION['loggedIn']);
			unset($_SESSION['email']);
			unset($_SESSION['password']);
			$GLOBALS['loginError'] = 'The specified email address or password was incorrect.';
			return FALSE;
		}
	}
	if (isset($_POST['action']) and $_POST['action'] == 'logout')
	{
		session_start();
		unset($_SESSION['loggedIn']);
		unset($_SESSION['email']);
		unset($_SESSION['password']);
		header('Location: ' . $_POST['goto']);
		exit();
	}
	session_start();
	if (isset($_SESSION['loggedIn']))
	{
		return databaseContainsAuthor($_SESSION['email'], $_SESSION['password']);
	}
}
function databaseContainsAuthor($email, $password)
{
	include 'db.inc.php';
	
	$email = mysqli_real_escape_string($link, $email);
	$password = mysqli_real_escape_string($link, $password);
	
	$sql = "SELECT COUNT(*) FROM author
			WHERE email='$email' AND password='$password'";
	$result = mysqli_query($link, $sql);
	
	if (!$result)
	{
		$error = 'Error searching for author.';
		include 'error.html.php';
		exit();
	}
	$row = mysqli_fetch_array($result);
	if ($row[0] > 0)
	{
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}

I’ve tried running a query like

function databaseContainsAuthor($email, $password, &$id)
}
$sql = "SELECT id FROM author WHERE email={$_POST['email']}";
$id = mysqli_query($link, $sql);
{

Then I implemented $_SESSION[‘id’] = $id; under function userIsLoggedIn(). I also gave a variable $id = $_SESSION[‘id’] in the index.php in the query

if (isset($_GET['addform']))
{
	include $_SERVER['DOCUMENT_ROOT'] . '/includes/db.inc.php';

	
	$text = mysqli_real_escape_string($link, $_POST['text']);
	$id = $_SESSION['id']
	$sql = "INSERT INTO article SET
			articletext='$text',
			articledate=CURDATE(),
			authorid= '$id'";

But this returned 0 in authorid where it should have returned the id of the author defined in author table.