• We just launched and are currently in beta. Join us as we build and grow the community.

Advertise Here

Advertise Here

Advertise Here

Notification Box in CSS - #1 HTML & PHP

Cracked1

Meme Curator
C Rep
0
0
0
Rep
0
C Vouches
0
0
0
Vouches
0
Posts
88
Likes
32
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 200 XP
Introduction:

This tutorial is on how to make a notification box for your website.

This is the first of two parts, in which we will be creating the HTML and setting the messages.

Notification Box?

When I say a notification box, I mean one of those smooth and sliding information boxes which sometimes appear under certain circumstances on a website at the top of the page. Normally stating that the web page uses 'cookies'.

HTML:

First we want to create the HTML for our page. For the notification box HTML we are going to have a few elements...

.outerBox - The entire width of the page to give a nice background colour
.innerBox - Sets the location of the inner content
.innerBox #information - The notification message.
.innerBox #close - The box the user may click to close the notification box.

  1. <html

    >
  2. <head

    ></

    head

    >
  3. <body

    >
  4. <div

    class

    =

    'outerBox'

    >
  5. <div

    class

    =

    'innerBox'

    >
  6. <p

    id

    =

    'information'

    >

    Info.</

    p

    >
  7. <p

    id

    =

    'close'

    >

    X</

    p

    >
  8. </

    div

    >
  9. </

    div

    >
  10. </

    body

    >
  11. </

    html

    >

The above HTML is now ready to appear as a notification box, however the message would always simply be 'Info.'. Normally this message would be something to do with server side queries such as the user trying to log in typed their information incorrectly, so we are going to output a PHP message there.

PHP:

First we set our PHP area...

  1. <?php
  2. ?>

Next we would execute our queries, and under the certain conditions we want to set a new information/notification message. We will create/set the value of a variable named 'message' for this...

  1. //Execute queries here, etc...
  2. $message

    =

    'That username is not available!'

    ;

Now where we have our notification box HTML we want to first check if the $message variable is set in PHP, if it is, it means we have a message we want to output via a new notification box...

  1. if

    (

    isSet

    (

    $message

    )

    )

    {
  2. //Notification box code in here...
  3. }

Finally we want to change the 'Info.' from the notification box to the PHP message. Here is our final code...

  1. <?php
  2. //Execute queries here, etc...
  3. $message

    =

    'That username is not available!'

    ;
  4. ?>
  5. <html>
  6. <head></head>
  7. <body>
  8. <?php
  9. if

    (

    isSet

    (

    $message

    )

    )

    {
  10. //Notification box code in here...
  11. echo

    "
  12. <div class='outerBox'>
  13. <div class='innerBox'>
  14. <p id='information'>"

    .

    $message

    .

    "</p>
  15. <p id='close'>X</p>
  16. </div>
  17. </div>"

    ;
  18. }
  19. ?>
  20. </body>
  21. </html>

Finished Part 1!


Download
You must upgrade your account or reply in the thread to view the hidden content.
 

452,496

343,269

343,277

Top