PHP - Custom Alerts System - Need A Hint
Hello everyone.
Maybe this belongs in the Application Design forum but I wasn't too sure so I posted it here. For my current application, I am trying to develop an "Alerts System". The main function of the app is to allow a user to manage "jobs". Jobs can be created and modified with ease, each job carries a ton of information, customer id, date, hour rate, duration, address, state, payment state, payment method, etc. So basically we have the table "jobs" with all these fields and some more. When a job has been changed to "Executed" state, it means the job has been finished and is awaiting payment by the customer, if the payment is already due and the "payment state" has not yet been filled, then an alert should be generated so the manager can quickly take care of it. I have been brainstorming on how to achieve this, this alert system has to query the DB often to check for "Executed" jobs with "payment = 0". Right now there are more than 50k jobs in my DB, and to run this query all the time is unthinkable... I can make it so the query runs when the manager decides to check for Alerts manually, but that defeats the purpose of what I am trying to achieve. This alert system would also be useful for more things: customers with no telephone number information or other sensitive data jobs that have had their final date pass and still haven't been changed to "executed" customers who haven't had any jobs done in the last year so the manager can either run a campaign or take some other action I wonder if such a thing is achievable nowadays without compromising the application's speed too much or taxing the server resources too much. Any suggestions would be very appreciated. Similar TutorialsLets say I have a simple table for Categories; fid forum desc cat 1 General Forum desc here 1 2 Help Forum desc here 2 3 Console Forum desc here 3 Hello! I think I need some creative juice to start my flow and am thankful for any suggestions. I am looking into some advice on how to code in "Category" wise. Lets say if I have forums like this; General Forum Quote General Talk about anything in general to NewbWorld. Suggestions Have any ideas to give to NewbWorld? Anything Goes Talk about anything you want! Help Forum Quote HTML Help If you are having problems with HTML coding post here! PHP Help If you are having problems with PHP coding post here! Instead of me manually coding each Category (General Forum, Help Forum, Console Forum, etc)... I want to be able to have the following coded like so; List Category ---Forum Sub Category ---Forum Sub Category ---Forum Sub Category List Category 2 ---Forum Sub Category ---Forum Sub Category ---Forum Sub Category Right now; I've been coding the "List Category" manually to show "Sub Forums". I would like to know how to do this without manual anymore. I would love to start coding an admin/moderator panel soon. Any help is much appreciated and thankyou for your time! I have a MySQL database that has a list of items which gets updated everyday. The database is truncated everyday and filled back with the recent posts. After it is filled out, I need an automatic system that will send out the emails to users who have provided certain keyword. I have a search query in place that will search through those posts, but I cannot figure out the email alert part. I just want to make something similar to a new job alert... What could be the potential tools that I can use to accomplish this? Currently all my website is in php. Thanks!! How would I go about creating a script to check a date in mysql and if that date is within X days it will send an email alert. My boostrap alerts is not displaying. The codes works if the login details are correct and also works if login details are wrong but refuses to show the error login info. My codes are <?php include 'db.php'; error_reporting(E_ALL | E_WARNING | E_NOTICE); ini_set('display_errors', TRUE); if(isset($_POST['submit'])) { $msg2 ='<div class="bs-example"> <div class="alert alert-warning alert-dismissible fade show"> <strong>Error!</strong> Invalid. Login. <button type="button" class="close" data-dismiss="alert">×</button> </div>'; $username = $_POST['username']; $password = $_POST['password']; $username = mysqli_real_escape_string($connection, $username); $password = mysqli_real_escape_string($connection, $password); //query $query = "SELECT * FROM customer WHERE username = '{$username}'"; $select_user_query = mysqli_query($connection, $query); //select user if(!$select_user_query) { die("QUERY FAILED". mysqli_error($connection)); } else{ //bring in database values while($row = mysqli_fetch_array($select_user_query)) { $db_username = $row['username']; $db_password = $row['password']; $db_email = $row['email']; if($username !== $db_username && $password !== $db_password) { echo "$msg2"; } else if($username == $db_username && $password == $db_password) { date_default_timezone_set("Africa/Lagos"); $time = date('h:i:sa'); $date = date('d/m/Y'); $msg = " <!DOCTYPE html><body>Dear <h2> $db_username , </h2> <h3><font color='purple'>Your Mayor Microfinance Bank Online Bank Account was logged in today,<h2> $date at $time (GMT+1)!!</h2><b>. </font><br> <font color='red'>If You are not the one that Logged it in, Please Visit Your bank immediately or Call our contacts available on our home page</h3></font>.....<br></b><i><font color='blue'>MMFB</font></i> </body></html> $headers = ""; $headers .= "From: Mayor Microfinance Bank(MMFB)<admin@mmfb.com.ng> \r\n"; $headers .= "Reply-To:" . $db_email. "\r\n" ."X-Mailer: PHP/" . phpversion(); $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $send = mail("$db_email","LOGIN SUCCESFUL",$msg,$headers); $_SESSION['login'] = $username; $_SESSION['timestamp']=time(); echo ("<script>location.href='../cpanel'</script>"); } }//end while }//else end }//submit ?>
The following code is under the head section of the html code in the same page as the code above
<!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Customer's Dashboard | Mayor Microfinance Bank</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta content="Online Banking For Microfinance bank Demo" name="description" /> <meta content="MayorTech" name="author" /> <!-- App favicon --> <link rel="shortcut icon" href="assets/images/favicon.ico"> <link href="assets/libs/chartist/chartist.min.css" rel="stylesheet"> <!-- Bootstrap Css --> <link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" /> <!-- Icons Css --> <link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" /> <!-- App Css--> <link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" /> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script> <style> .bs-example{ margin: 20px; } .footer { background-color:cornflowerblue; color:white; } </style> </head> The same issue occurs with sweet alert too. Am new to coding but i cant seem to figure out my errors . thanks in advance I'm sure it's not much, but I'm not understanding something with custom error handlers: I've created a custom error handler, which I initially set when my page loads : set_error_handler(array ( new ErrorHandler(), 'handleError' ));
It seems to catch all internal PHP errors, such as if I: var_dump($non_existing_var); right after the set_error_handler.... Now, I have an object that throws an exception after: set_error_handler(array ( new ErrorHandler(), 'handleError' )); $locale = new \CorbeauPerdu\i18n\Locale(...); // this should throw an exception ... I thought that with an error handler set, I could 'skip' the try/catch for it, but doing so, PHP spits out in its internal log: PHP Fatal error: Uncaught CorbeauPerdu\i18n\LocaleException: ....
My error handler doesn't catch it at all before, thus my page breaks!! If I want it to go through the error handler, I have to init my Locale with a try/catch and use trigger_error() like so: set_error_handler(array ( new ErrorHandler(), 'handleError' )); try { $locale = new \CorbeauPerdu\i18n\Locale(...); // this should throw an exception } catch(Exception $e) { trigger_error($e->getMessage(), E_USER_ERROR); } ... Is this normal ? I thought one of the goals of the error_handler was to catch anything that wasn't dealt with? Thanks for your answers! hello dear PHP-Fans - greetings to you - and a happy new year!! i set up a WAMP-System on my openSuse 11.4 system. In order to learn as much as i can bout PHP i want to do some tests and write some scripts. Well the WAMP is allready up and running. Now i try to give the writing access to the folder mkdir /srv/www/ where the php-scripts should go in... i want to give write permission to all to all files in /srv/www As root I generally: mkdir /srv/www/ chown <webmaster usrername> /srv/www/ /srv/www/ should be readable and traversable by all, but only writeable by it's owner (the user designated as the webmaster.) can i do this like mentioned above,... Love to hear from you greetings db1 I am in the process of learning MySQL and PHP. I have a real-world application that I would like to develop for someone using MySQL and PHP, provided I can end up with the necessary user interface for the application. The user will be launching a web browser to start the application. The application will be developed for two purposes: to record employee information (name, contact info, category of worker such as: cook, dishwasher, server, host) to record the hours worked by each worker for each day and then generate a report that can be sent to the accountant by email or fax Since the interaction will take place in a web browser, what are the possibilities as far as having customization for the text fields (controllable size of text field, larger than the form element), having start and end times with the colon symbol inserted automatically, to name a few. When a text field is inserted via HTML, the rectangle is rather small. Can the default sizes of form elements be enlarged? Hi Everyone. I'm trying to generate a non standard PK in the form of 000111-YU, where 0001 refers to the record number, the 11 refers to the year and the -YU is a set of random letters / numbers. The 0001 can increment throughout the year, but once 2012 occurs, the counter needs to be reset back to 0001. I need this number to be generated and inserted into the table, but I also need to have form fields inserted into the db. for eg. FirstName and LastName are names of textboxes in a form. this is what i have so far, but i keep receiving 'error, insert query failed.' <?php $db="db"; $link = mysql_connect('localhost', 'root', 'pw'); if (! $link) die(mysql_error()); mysql_select_db($db , $link) or die("Couldn't open $db: ".mysql_error()); $query = "INSERT INTO records (IDNumber, FirstName, LastName) SELECT * FROM ( SELECT # id CONCAT( # Sequential number, incremented, zero-padded LPAD((SUBSTR(COALESCE(MAX(IDNumber), '0'), 1, 4) + 1), 4, '0'), # Two-digit year DATE_FORMAT(CURRENT_DATE, '%y'), # Literal hyphen '-', # Two random letters (AA-ZZ) CHAR( FLOOR(65 + RAND() * 26), FLOOR(65 + RAND() * 26) ) ) FROM records WHERE IDNumber LIKE CONCAT('____', DATE_FORMAT(CURRENT_DATE, '%y'), '-__') ) "; mysql_query($query) or die('Error, insert query failed'); ?> Is there a way to use PHP to edit html without having to store it in my DB? For example I would like someone to be able to edit a paragraph on the page, its wrapped in a <div class="editable"> now is there a way to have PHP detect that div and have an textarea to edit it directly without having to store anything in a DB? I hope that makes sense if it doesn't let me know! Thanks Hi all I wonder if people can help me out here. It's a "bespoke" vs "framework" question, so not sure its belongs in here, but I didn't want to post it in the ZEND group, as it may have many more "pro ZEND fans" who read it, and I wanted a general thought. This is all based on the fact that I have a big project coming up and I want to know if I should be sticking with a custom job, or if something like ZEND is the way to go. Basically I have been developing PHP for about 2 years now and I have always thought a custom site written from scratch was the best way to go, not only does it allow you to have the minimal code needed to run the site, therefore reducing load, space and bandwidth, but it also allows you to know exactly how the system works, I guess the downside is that you have to spend more time doing the coding. But I have a few friends who use frameworks, ZEND has been coming up more and more, it's not really my ideal system to use as I prefer coding from scratch (not sure why), but they swear by it, and always tell me its great, its winning awards and none of them code from scratch, one of them even quoted that it "will become the standard for development" - is this true? Apart from being massively bulky and containing tons of files with scripts and functions that you might never ever use, what do people see as a downside to ZEND, If any? Is it best to code from scratch, and if so, why? Or does using something like ZEND much better? I guess if you always use ZEND, then you never really enhance your skill as a coder and never really learn anything new, plus I always think it's kind of cheeky using a pre-built system. Is there a good argument that would say using ZEND is not really a good idea? Or is the general feeling toward ZEND being a good thing? Surely if people know ZEND, they know how to play the security of the site to there advantage and therefore can break the security of other ZEND systems, or at least cause some hacks to a site. Any thoughts would be great Thanks everyone When a user clicks on a topic they are transfered to its post, which is retrieved by the name of the topic as given by the url value. up to now i have just used urlencode. But its trickier when a user adds slashes and dots into the mix. for example the title of the post is testing/testing. The url will go to www.asimpleforum.co.uk/t/testing/testing. How would i get around this since url encode doesnt do the job? I could replace slashes and dots with their own unique symbol but that produces the problem when someone uses one of those symbols that i use to replace in their topic title. I know one site in particular that replaces all dots and slashes with a hyphen (-), but how would you know what to turn the hyphen into when you query the database for that topic? Anyone have any ideas? Hello. I am currently working on a new site (http://sa.cx) that is basically a free domain like this: (example.sa.cx). My main goal is to allow users to set the the full MX, CNAME, A and SOA records. Any ideas on how I could go about this using php? My initial thought would be via cURL. Hi guys, i have a ipn paypal setup where users can buy items from my custom made shop, however in original ipn code, the logged in users should have the same email with paypal to call on ipn which user has bought what, so I have decided to pass a custome variable as <input type="hidden" name="custom" value="<?php echo "$username";"> the hard part is in my ipn how im i going to recieve the username variable? what should i put in my ipn. In ipn code I have example code: $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; but now, can u help me to recieve the username so i can match my mysql query which user has bought what? thanks in advance I'm gonna be perfectly honest, I have no idea what's wrong with this code, I'm not even entirely sure what it all means, I just need to make it work. -.- I get this error: Parse error: syntax error, unexpected '}' in Z:\www\cms\includes\functions.php on line 25 From this code: Code: [Select] <html> <body> <?php include('includes/dbvars.php'); function displayVideos($dbc){ mysqli_connect('DB_HOST', 'DB_USER', 'DB_PW', 'DB_NAME'); //Query $query = "SELECT * FROM videos"; //Execute $result = mysqli_query($dbc, $query) or die ("Error querying database."); While ($row = mysqli_fetch_assoc($result)) { echo '<h2>' . $row['Title'] . '</h2>'; echo '<b>Director</b>:' . $row['Director'] . '<br />'; echo '<b>Description</b>:<br />' . $row['Description']; echo '<hr>'; } mysqli_close($dbc) } ?> </body> </html> Any help very much appreciated hi i am new in here and php coding. i got the following code frm my friend for making a name, address, passout of student searching database. <?php // TAKE THE INFORMATION FROM FORM. $search = $_GET['search']; // IF THERE IS NOT A KEYWORD GIVE A MISTAKE. if (!$search) echo "You didn't enter a keyword."."$text Back to Search Again <a href=searchform.php>Search</a>"; else { echo "<td>You searched for: <strong>$search </strong></td>"; mysql_connect('sql servername','sql server username','password'); mysql_select_db('database name'); $id=@$_GET['id']; //QUERY IS THE CODE WHICH WILL MAKE THE SEARCH IN YOUR DATABASE. //I WROTE AN EXPLANATION ABOUT IT AFTER THE CODE. $query="SELECT * FROM searchform WHERE MATCH(Name, Address, Pass) AGAINST('%$search%' IN BOOLEAN MODE)"; $result1 = MySQL_query($query); if(!$result1) { echo MySQL_error()."<br>$query<br>"; } if(MySQL_num_rows($result1) > 0) { echo "<table width='480' align='center' border='1' cellspacing='0' cellpadding='0'>"; while($result2 = MySQL_fetch_array($result1)) { //A short description from category. $description = $result2['category']; $searchPosition = strpos($description, $search); $shortDescription = substr($description, $searchPosition, 150); // I added a link to results which will send the user to your display page. echo "<tr><td>Name</td><td>Address</td><td>Pass</td></tr>"; echo "<tr><td>{$result2['Name']}</td><td>{$result2['Address']}</td><td>{$result2['Pass']}</td></tr>"; } echo "</table>"; }else { echo "No Results were found.<br>"."$text Back to Search Again <a href=searchform.php>Search</a>"; }echo "<br>"; } ?> every thing is working fine as i wanted. my database structure is below |NAME||ADDRESS||YEAR| |ABC|abc|1980| |XYZ||xyz||1980| but there is a small problem of showing the output result. when i search with 1980 it show 4 column 1st column is showing NAME, ADDRESS, YEAR 2nd column is showing |ABC|abc|1980| again 3rd column is showing NAME, ADDRESS, YEAR 4th column is showing |XYZ||xyz||1980| how i solve to not showing every column the NAME, ADDRESS, YEAR (3rd column)
Hi all,
alt="<?php echo the_title(); ?> keyword keyword"/>
So I need to include this: alt="<?php echo the_title(); ?> keyword keyword"/>
Or this: [show_post_categories show=”title”]
Into this, replacing the site_title in the alt= parts: // LOGO CODE FOR SORTING ALT TEXT <!-- Header logo --> <a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?><?php echo get_bloginfo( 'name' ) && get_bloginfo( 'description' ) ? ' - ' : ''; ?><?php bloginfo( 'description' ); ?>" rel="home"> <?php if(flatsome_option('site_logo')){ $logo_height = get_theme_mod('header_height',90); $logo_width = get_theme_mod('logo_width', 200); $site_title = esc_attr( get_bloginfo( 'name', 'display' ) ); if(get_theme_mod('site_logo_sticky')) echo '<img width="'.$logo_width.'" height="'.$logo_height.'" src="'.get_theme_mod('site_logo_sticky').'" class="header-logo-sticky" alt="'.$site_title.'"/>'; echo '<img width="'.$logo_width.'" height="'.$logo_height.'" src="'.flatsome_option('site_logo').'" class="header_logo header-logo" alt="'.$site_title.'"/>'; if(!get_theme_mod('site_logo_dark')) echo '<img width="'.$logo_width.'" height="'.$logo_height.'" src="'.flatsome_option('site_logo').'" class="header-logo-dark" alt="'.$site_title.'"/>'; if(get_theme_mod('site_logo_dark')) echo '<img width="'.$logo_width.'" height="'.$logo_height.'" src="'.get_theme_mod('site_logo_dark').'" class="header-logo-dark" alt="'.$site_title.'"/>'; } else { bloginfo( 'name' ); } ?> </a> <?php if(get_theme_mod('site_logo_slogan')){ echo '<p class="logo-tagline">'.get_bloginfo('description').'</p>'; } ?>
THIS IS THE WHOLE FUNCTIONS.PHP FILE IN MY CHILD THEME: <?php // Add custom Theme Functions here /** * Change text strings * * @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext */ function custom_related_products_text( $translated_text, $text, $domain ) { switch ( $translated_text ) { case 'Related products' : $translated_text = __( 'More fire & security systems you may like', 'woocommerce' ); break; } return $translated_text; } add_filter( 'gettext', 'custom_related_products_text', 20, 3 ); /* USE SHORTCODES IN WIDGET TITLES AND PAGE TITLES !! */ add_filter('the_title', 'do_shortcode'); add_filter('widget_title', 'do_shortcode'); /* NOT SURE WHY I HAD THIS HERE??... <?php echo do_shortcode("[shortcode]"); ?> */ /* ADD ALT TAG TO GRAVATAR - BLOG-AUTHOR-IMAGE - IMAGES */ function crunchify_gravatar_alt($crunchifyGravatar) { if (have_comments()) { $alt = get_comment_author(); } else { $alt = get_the_author_meta('display_name'); } $crunchifyGravatar = str_replace('alt=\'\'', 'alt=\'Avatar for ' . $alt . '\' title=\'Gravatar for ' . $alt . '\'', $crunchifyGravatar); return $crunchifyGravatar; } add_filter('get_avatar', 'crunchify_gravatar_alt'); // LOGO CODE FOR SORTING ALT TEXT <!-- Header logo --> <a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?><?php echo get_bloginfo( 'name' ) && get_bloginfo( 'description' ) ? ' - ' : ''; ?><?php bloginfo( 'description' ); ?>" rel="home"> <?php if(flatsome_option('site_logo')){ $logo_height = get_theme_mod('header_height',90); $logo_width = get_theme_mod('logo_width', 200); $site_title = esc_attr( get_bloginfo( 'name', 'display' ) ); if(get_theme_mod('site_logo_sticky')) echo '<img width="'.$logo_width.'" height="'.$logo_height.'" src="'.get_theme_mod('site_logo_sticky').'" class="header-logo-sticky" alt="'.$site_title.'"/>'; echo '<img width="'.$logo_width.'" height="'.$logo_height.'" src="'.flatsome_option('site_logo').'" class="header_logo header-logo" alt="'.$site_title.'"/>'; if(!get_theme_mod('site_logo_dark')) echo '<img width="'.$logo_width.'" height="'.$logo_height.'" src="'.flatsome_option('site_logo').'" class="header-logo-dark" alt="'.$site_title.'"/>'; if(get_theme_mod('site_logo_dark')) echo '<img width="'.$logo_width.'" height="'.$logo_height.'" src="'.get_theme_mod('site_logo_dark').'" class="header-logo-dark" alt="'.$site_title.'"/>'; } else { bloginfo( 'name' ); } ?> </a> <?php if(get_theme_mod('site_logo_slogan')){ echo '<p class="logo-tagline">'.get_bloginfo('description').'</p>'; } ?>
I just can't get it to work, keeps throwing errors on save :( Hello, I am wondering how to create a counter that has 5 digits and counts the results from a db field (not just the returned results but the numeric SUM of the values in the field) for display. i.e. if the sum of the field = 347 the counter would read 00347 I have created images for the numbers 0-9 and named them 0.png, 1.png, 2.png etc Also, I may have to sum a value that is stored in the db as serialized data (part of an array). If so how can I do that?? Hi. I was just wondering if it is possible to write custom mysql errors. I have hunted around for some but cant find any. Currently I write my errors like... or die (mysql_error()); How ever I see this as a problem! As Im not the best coder there are bound to be errors in my code. I dont want somebody who knows what they are doing to cause an error and then doing it (mysql_error()) will point them in the right direction to what I have missed. I would rather have my own error saying what line the issue is with. I have tried..... or die (mysql_error(My personal error here)) However this does not work. Please help. Thank you Hi all
I have the following in my .htaccess file
RewriteRule ^([^/]+)/ /$1.php?q=$1 [L,QSA]
and this is great because any PHP page I create, such as 'about.php' can be rewritten as '/about/' - so that is all good.
the problem is, I also want to let users create their own custom URL's for their profiles in the root of the site, such as '/david-jones/' but because 'david-jones' is not actually a real PHP page (but rather a database entry), I cant use a rewrite rule as far as I can see.
Would the best solution be to piggy back the error 404 rewrite rule, so that if an actual PHP page isn't found, it takes them to the 404 error page which actually contains a script to lookup the users details, if the user details are not found, i'd show a "the page cannot be found" message.
Or is there a more elegant way to do this?
Thanks
|