Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Code to make a message be displayed on intranet easily

Featured Replies

We have an internal intranet and basically at the top of the home page I want an optional message to be displayed easily without coding knowledge.

 

Basically we would have index.php and a page called message.php and when someone goes to message.php there is a text box they can enter text into and when the press submit it basically goes to the home page and inserts that message at the top of the page.

 

When the message needs to be removed we go to message.php delete the text in the box and press submit which makes the box on the home page dissapear.

 

I have seen similar things implemented and I was just wondering how it can be done.

 

Anyone that can help its much appreciated! Thanks!!


// message.php would look similar to this (i have included a PDO version aswell as a mysql one not sure what one you require)

<?php
if ($_POST[ 'message']) {
// mysql_*
// $query=m ysql_query( "UPDATE `message` SET `message`='".mysql_real_escape_string($_POST[ 'message']). "' WHERE `place`='homepage'");

// PDO (alter with your variables)// $query=$ db->prepare("UPDATE `message` SET `message`= ? WHERE `place`='homepage'");
// $query->execute(array($_POST['message']));
echo 'Message updated';
}
echo '<form action="#" method="post"><textarea name="message"></textarea><input type="submit" /></form>';
?>

// as for the index page

<?php
// mysql_*
// $query = mysql_query("UPDATE `message` SET `message`='".mysql_real_escape_string($_POST['message'])."' WHERE `place`='homepage'");
// $message = mysql_fetch_object();

// PDO (alter with your variables)
// $query = $db->prepare("UPDATE `message` SET `message`= ? WHERE `place`='homepage'");
// $query->execute(array($_POST['message']));
// $message = $query->fetchObject();
if ($message->message) {
echo '<div class="..." id="...">'.htmlentities($message->message).'</div>';
}
?>

 

Edited by D4Y0

Very good, but it assumes that there is a database. If you have one already, OK, but to set one up just for a message may be overkill.

D4Y0's PDO method is fine, but I'm not sure that all servers will process it unless your's is up to date. Below is an old PHP method that doesn't use a database:

You can do much the same just with PHP, like a news box shown in this tutorial:
http://www.wickham43.net/showform.php#phpnewsbox
where you could put it at the top of your index.php page. It would need a little adaptation. You would only need newsboxdefault.inc because the tutorial has alternatives for newsbox.inc which includes football.inc and tennis.inc from the links on the page. Also, to avoid the person without coding knowledge having to insert text in newsboxdefault.inc you would have a php "include" on that page and another page called message.php which would only need text and the untrained person would only access message.php.

You should also consider password protecting your message.php if lots of people have access to your control panel.

 

OR

 

use a very simple CMS (content management system). https://www.cushycms.com/en is designed for an untrained person to access only a designated part of your page code using a username and password. The person can only type text between html markup you already have on your page, or insert an image filename if the place you have prepared is coded for that. You insert a special class like class="cushycms" into a selected element like h1 or p or div but all the untrained person sees is plain text to edit or a filename to change. You might have to tell the person not to insert 50,000 words or a huge image!

 

If you set up a div box or p tag for the text, and there is no text, it might use up a line space or show a div border, etc.

 

Edit: I've just realised that the cushycms cms would only work for a live internet site, not an intranet.

Edited by Wickham

  • 2 weeks later...
  • Author

I think i will go for the SQL method which is fine we have it installed on our server and i think that is the way i have seen it implemented in the past if someone could tell me how to go about doing that in details.

 

Also, kinda of another question, we are using Windows Server 2008 and IIS as our web server, index.html pages display fine, however index.php files show up an error when trying to load, i think access denied or something similar, i have tried adding index.php as a default page, but its still not working any ideas?

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.