I have removed most of the code relating to the sessions storage as I just couldn't get it to work. So the code below is what I am currently using as I couldn't find anything that worked
This is my code that currently authoises the user against the userinfo table:
<?php
session_start();
$_SESSION['id'] = $id;
include "mysql.php";
$_POST['username'] = addslashes($_POST['username']); // protects against SQL injection
$_POST['password'] = addslashes($_POST['password']); // same ^^
$password = ($_POST['password']); // encrypt the password
$userrow = mysql_query("SELECT * FROM `userinfo` "
. "WHERE `username` = '" . $_POST['username'] . "'"
. " AND `password` = '" . $password . "';",$mysql);
if(mysql_num_rows($userrow) != "1"){
// no rows found, wrong password or username
echo "<font color='red' face='Tahoma' size='2'><b>Please verify the username and/or password entered!</b></font>";
include "login.php";
} else {
// 1 row found exactly, we have the user!
$_SESSION['id'] = $id;
echo "<font color='red' face='Tahoma' size='2'><b>$id</b></font>";
header("Location: home.php");
}
?>
The form is a basic php file which then uses an external php file to write to the other table. Below is an example of the code of one of th forms:
<?php
$con = mysql_connect("localhost","root","U$3r");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("mydatabase", $con);
$sql="INSERT INTO billing_tracker
(champ
,customer_name
,customer_email_address
,case_number
,id_number
,msisdn
,route_cause
,escalatedto
,province
,comments)
VALUES
('$_POST[champ]'
,'$_POST[customer_name]'
,'$_POST[customer_email_address]'
,'$_POST[case_number]'
,'$_POST[id_number]'
,'$_POST[msisdn]'
,'$_POST[route_cause]'
,'$_POST[escalatedto]'
,'$_POST[province]'
,'$_POST[comments]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "<b><font color='red' face='segoe' size='2'>1 record added</b></font>";
include "billing_tracker.php";
mysql_close($con)
?>