How to proceed an action without opening the page that has the codes ?

hamidelgendy used Ask the Experts™
Hey guys,

i have wrote a script where the client can chose from his settings page whither his invoices get paid automatically or he pays it manually.

If he chose to pay it manually then its fine he will click on the pay button there is no problem.

But what if he chose the invoices to get paid automatically ?

how am i going to proceed the paying code without sending a direct action whither it was $_POST or $_GET or even opening a php page that will read his id and pay the invoice from his own credits ?

in another way on asking this, can i send the server an automated action that gets read every 24 Hours, so that the server side will deal with all this alone without a client side ?

Please guys this is really important. thanks a lot for any help :)
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Juan OcasioApplication Developer

You should have some sort of field in a database that will store this information.  Possible a binary field with either 0 for false or 1 for true.  Field can be called something like auto_pay.  Then you could have a script that runs on a specific day that will automatically process a payment on a specific date.  This script will query the db for all auto_pay set to one and then process the payments.  Perhaps a transactional stores procedure or a trigger that runs a store procedure
PHP has CLI (command line interface), which means it can be run like a regular shell script or a DOS batch file.
And you can make a scheduled job to run the script using crontab in Linux or "scheduled tasks" in Widows.
Jagadishwor DulalSenior Web Developer

Yes I agree jhp333,
You can create cron job which can call a page and the script will be executed in your server for processing.
Most Valuable Expert 2011
Top Expert 2016
The general design idea would include a CRON job or a scheduled task.  In my experience with CRON jobs you need to be careful to verify that they actually get run and that they actually work correctly.  This implies some kind of handshake with another script that is monitoring the CRON job output.  This verification will  be especially important if you are handling money.

CRON jobs typically are started automatically (Chronologically, hence the name), and not from a browser.  That means that your CRON job cannot produce browser output.  One technique I have found to be useful... Use ob_start() at the top of the script, then just write your messages to the regular output stream using echo.  At the end of the script, use ob_get_contents(0 to collect the output stream into a string variable.  You can write this string to a log file or email it to yourself.  That gives you a good way to keep track of the status of the CRON jobs.

Good luck with it, ~Ray

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial