Push Notification Message

This is a simple system/program Push Notification in PHP. This simple code creating a message and passes through the receiver. It has a three components where to send the messages, the Student, Teacher, Staff just for the example. Result

Sample Code

Script for executing the message.
  1. <?php
  2. include('connect.php');
  3. function clean($str)
  4. {
  5. $str = @trim($str);
  6. {
  7. $str = stripslashes($str);
  8. }
  9. }
  10. $position = clean($_POST['position']);
  11. $message = clean($_POST['message']);
  12.  
  13. mysql_query("INSERT INTO notificatiion (position, message) VALUES ('$position','$message')");
  14. header("location: notify.php");
  15. ?>
And the Script for recieving the message
  1. <?php
  2. include('../connect.php');
  3. $result = mysql_query("SELECT * FROM notificatiion WHERE position='student'");
  4. while($row = mysql_fetch_array($result))
  5. {
  6. echo '<li>'.$row['message'].'</li>';
  7. }
  8. ?>
And that's all. Just download the source code below if you like and enjoy modifying. I hope you learn.

Comments

Submitted byoleteacher (not verified)on Sat, 09/09/2017 - 05:28

Have been looking for simple and light weight method to send notifications for school project. Did not need anything fancy and your script fits perfectly. Having issue trying to implement way to delete pass messages (or current in case of mistake). How hard would it be to implement into your script? Do you have time to give example? Thanks again, Susan
Submitted byoleteacher (not verified)on Sat, 09/09/2017 - 06:22

Get these errors: Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/xxxx/public_html/pushIT/connect.php on line 6 Warning: Cannot modify header information - headers already sent by (output started at /home/xxxx/public_html/pushIT/connect.php:6) in /home/xxx/public_html/pushIT/notifyexec.php on line 16

Add new comment

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
3 + 8 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.