Question

I am creating an E-mail Reporting System to send scheduled e-mails (daily, weekly, etc.) with the results of certain SQL queries.

I have one HTML & JQuery page, generate.html, containing a form which allows a user to customize the report. The form enables the user to change certain variables of the SQL query to be executed.

These variables are passed to a PHP file, report.php, which contains the queries and handles e-mailing the results.


For Example

A user inputs an e-mail address on the HTML form and submits. report.php receives this variable through $input_email = trim($_REQUEST['input_email']);.

My problem lies in using cron to execute the report.php file on a scheduled basis. I have not tried it, but I am pretty sure that when cron executes report.php, it will see $input_email in the PHP file and not know what to do with it.


I see two solutions

  1. Have cron not execute just report.php, but report.php with the added query string, so it looks like: report.php?input_email=user@email.com
  2. Duplicate the report.php file into a new file, hardcode.php, where all the $variables are replaced with their actual values, and then cron can just execute hardcode.php on it's own


I wish to implement the second solution, but cannot figure out how. I am relatively new to PHP and JQuery. Any help would be greatly appreciated! Thank you.

Was it helpful?

Solution

Why not

  1. insert all values sent into a database
  2. retrieve all values in a new email.php file and run a loop that sends all reports?

That sounds like a solution to me and you can cron the email.php file

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top