i have developed a submission form with 10 fields.when user submit the form data send in to the MYSQL data base.Now i want to send that data to my client' email address week by week.how to do this cron job. I don't have idea how to write this PHP script. Any one can help me........... Thanks
A short idea for you.add a new field in the database where you can store the time ( time or date ) when the entry was inserted. Then create a a php file that will mail all the entries in the last 7 days. And then run this cronjob every 7 days. I hope you got what i meant. Codebreaker.
The traditional approach to handling form submissions is to just have the script sanitize the entered data and send it immediately to an e-mail address. Is there a reason why your client wants it at the end of each week? Why not have your client setup a special email address for the script to immediately send the data to and he can just go through the in-box at the end of the week or whenever he wants.
You could try something like this: $since_last_week = date('Y-m-d', strtotime('-1 week')); $today = date('Y-m-d'); $sql = 'SELECT * FROM submissions WHERE created_at >= "' . mysqli_real_escape_string($since_last_week) . '" AND created_at < "' . mysqli_real_escape_string($today) . '"'; PHP: Then construct the email within the foreach loop and send it off at the end. Set up your cron so that this executes once per week.