Hosting Solutions
mobile_logo Table of Contents
seal_frontseal_back

Cron Job Automate Social Network Web Site Maintenance Tutorial

Learn to automate PHP MySQL web site maintenance tasks with Cron Jobs. You can set them to execute at any interval you like. In this example we create a PHP cron job that will delete all non-activate users after X days. If you do not clear the database of these users periodically your system will become clogged with non-activated users. once_daily.php <?php require_once("../php_includes/db_conx.php"); // This block deletes all accounts that do not activate after 3 days $sql = "SELECT id, username FROM users WHERE signup<=CURRENT_DATE - INTERVAL 3 DAY AND activated='0'"; $query = mysqli_query($db_conx, $sql); $numrows = mysqli_num_rows($query); if($numrows > 0){ while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) { $id = $row['id']; $username = $row['username']; $userFolder = "../user/$username"; if(is_dir($userFolder)) { rmdir($userFolder); } mysqli_query($db_conx, "DELETE FROM users WHERE id='$id' AND username='$username' AND activated='0' LIMIT 1"); mysqli_query($db_conx, "DELETE FROM useroptions WHERE username='$username' LIMIT 1"); } } ?>
thumb

PHP Videos

Social Network Development

Introduction and Building the Design TemplateDatabase Creation and PHP MySQLi Connection Script TutorialMySQL Database Tables Creation Script LogicEstablish htaccess and phpini for apache web site server configurationCreate the Main JavaScript Module and Insert Other Modules TutorialSign Up Form and Email Activation PHP MySQL JavaScript Programming TutorialLog In Form Log Out Script Cookies Sessions User ProfileCron Job Automate Social Network Web Site Maintenance TutorialForgot Account Password Form Email Script Ajax TutorialFriend Add Block System Ajax TutorialSocial Network Header Logic Dynamic Links Example ScriptFriend Lists and Social Network Notifications TutorialUser Profile Photo File Upload HTML Form PHP Parse Script MySQLPhoto Gallery CMS TutorialConversation System Social Network Ajax PHP MySQL TutorialSend SMS Text Messages to Mobile Phone PHP Tutorial