Python Forum

Full Version: Use Python to change a PHP file on my little webpage
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
On my little, simple webpage I have a PHP login system, because my boss needs a record of attendance from me.

At the moment, I need to change the time, date (the PHP variable $beginclass, see below) by hand.

I read a bit about requests. Could I do this from my laptop?

The login part for MySQL is below. I need to change the date, say : August 21, 2021 10:00:00 for August 28, 2021 10:00:00, that's all.

Would be great if I could do that automatically for all classes with a simple Python program.

Is requests the way to go??

The path to the login.php file looks like: www.mywebpage.com/httpdocs/20BE1cw/

Quote:// MY STUFF HOPE THIS WORKS!!
try{
$timenow = new DateTime('NOW');
// change this each week
$beginclass = new DateTime("August 21, 2021 10:00:00");
if($timenow > $beginclass) {
// attendance will not increase with multiple logins. Before next week, reset 'has_been_inc' to zero from phpmyadmin
// also, if the student comes late, no attendance
$mystmt = $pdo->prepare('UPDATE allstudents20BE1 SET has_been_inc = has_been_inc + 1, logon_time = LOCALTIME() WHERE email = :email AND has_been_inc != 1');
}
elseif($timenow < $beginclass) {
$mystmt = $pdo->prepare('UPDATE allstudents20BE1 SET attendance = attendance + 1, has_been_inc = has_been_inc + 1, logon_time = LOCALTIME() WHERE email = :email AND has_been_inc != 1');
}