I have this code:
<?php
error_reporting(E_ALL);
ini_set('display_errors' ,1);
require "connection.php";
$query= "SELECT client_id, count(client_id) AS rows, array_agg(insurance) AS insurance from vouchers WHERE parsing_date=CURRENT_DATE GROUP BY client_id";
$result = pg_query($conn,$query);
?>
<!DOCTYPE html>
<html>
<head>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
<link href = "http://fonts.googleapis.com/css?family=Roboto:400">
<style>
.responstable {
margin: 1em 0;
width: 100%;
overflow: hidden;
background: #FFF;
color: #024457;
border-radius: 10px;
border: 1px solid #167F92;
word-wrap: break-word;
}
</style>
</head>
<body>
<div class="container-fluid">
<div>
<h1>Clients</h1>
</div>
<table class="responstable" rules='all' style='border-collapse: collapse;'>
<thead>
<tr>
<th>Client id</th>
<th>Number of rows</th>
<th>Insurance</th>
</tr>
</thead>
<?php
while($row = pg_fetch_array($result))
{
$find ='{';
$replace = '' ;
$arr = $row['insurance'];
$insurance3= str_replace($find,$replace,$arr);
$insurance = str_replace('"',' ',$insurance3);
?>
<tbody>
<td><?php echo $row['client_id']; ?></td>
<td><?php echo $row['rows'];?></td>
<td><?php echo $insurance; ?></td>
</tr>
<?php }
?> </tbody>
</table>
</div>
</body>
</html>
This code displays a report of the id, rows and insurance; I want to be able for it to automatically send an email daily to me with the same content and the same style it is shown on the table. I tried this:
<?php
require "connection.php";
if (isset($_REQUEST['email'])) {
$admin_email = "admin@hotmail.com";
$email = "jasmine@hotmail.com"; //my email
$subject = 'Date';
//send email
mail($admin_email, "$subject", $comment, "From:" . $email);
//if "email" variable is not filled out, display the form
?>
<?php
$query= "SELECT client_id, count(client_id) AS rows, array_agg(insurance) AS insurance from vouchers WHERE parsing_date=CURRENT_DATE GROUP BY client_id";
$result = pg_query($conn,$query);
?>
<!DOCTYPE html>
<html>
<head>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
<link href = "http://fonts.googleapis.com/css?family=Roboto:400">
<style>
.responstable {
margin: 1em 0;
width: 100%;
overflow: hidden;
background: #FFF;
color: #024457;
border-radius: 10px;
border: 1px solid #167F92;
word-wrap: break-word;
}
</style>
</head>
<body>
<div class="container-fluid">
<div>
<h1>Clients</h1>
</div>
<table class="responstable" rules='all' style='border-collapse: collapse;'>
<thead>
<tr>
<th>Client id</th>
<th>Number of rows</th>
<th>Insurance</th>
</tr>
</thead>
<?php
while($row = pg_fetch_array($result))
{
$find ='{';
$replace = '' ;
$arr = $row['insurance'];
$insurance3= str_replace($find,$replace,$arr);
$insurance = str_replace('"',' ',$insurance3);
?>
<tbody>
<td><?php echo $row['client_id']; ?></td>
<td><?php echo $row['rows'];?></td>
<td><?php echo $insurance; ?></td>
</tr>
<?php }
?> </tbody>
</table>
</div>
</body>
</html>
<?php
}
?>
However, it doesn't even send me an email at all. I'm not sure what to do or how to fix it. Thanks in advance!
To start with, try testing boolean return value from email()
PHP function, to see if at least mail was accepted for delivery...
Then, you can further investigate...