Hi
I tried the following code and it is now working as required.
Although I'm sure there must be another way to acheive this involving less code.
Hopefully manage to sort it out once I get a bit more confidence with PHP.
Many thanks for your help.
require_once('../../Connections/abe.php');
ob_start();
error_reporting(E_ALL);
if(isset($_GET['report']) && isset($_GET['name']))
{
$connect = mysql_connect("local", "online", "password");
$connected = mysql_select_db("abonline", $connect);
$username = $_GET['name'];
$report = $_GET['report'];
$adminuser = 'Administrator';
if($connected or die(mysql_error()))
{
$query = mysql_query("SELECT * FROM users WHERE name = '$username' OR name = '$adminuser'") or die(mysql_error());
//$query = mysql_query("SELECT * FROM users WHERE name = '$username'") or die(mysql_error());
$result[0] = mysql_fetch_assoc($query);
$to = $result[0]['user_email'];
$first_name = $result[0]['name'];
$from = 'michael@lothian.gov.uk';
$subject = 'Staff computer problem reported:' . ' ' . strtoupper($username);
$msg = "Dear $first_name,\r\n\r\n$report";
if(mail($to, $subject, $msg, 'From:' . $from))
echo "Message sent.";
else
echo "Error! Message not sent.";
}
if($second_user = mysql_fetch_assoc($query))
{
$result[1] = $second_user;
$to = $result[1]['user_email'];
$first_name = $result[1]['name'];
$from = 'michael@lothian.gov.uk';
$subject = 'Staff computer problem reported:' . ' ' . strtoupper($username);
$msg = "Dear $first_name,\r\n\r\n$report";
if(mail($to, $subject, $msg, 'From:' . $from))
echo "Message sent.";
else
echo "Error! Message not sent.";
}
}
Best regards maxwell