flashmessage.php

Gesponsorde koppelingen

PHP script bestanden

  1. flashmessage.php

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
if (!function_exists('getFlashMessage'))
{
    function
getFlashMessage($name)
    {

        unset($_SESSION['flashmessage'][$name]);
    
        // Does the session exists
        if(isset($_SESSION['flashmessage'][$name]))
        {

            // IF the session has an multiple array (multiple messages)
            if(!is-array($_SESSION['flashmessage'][$name]))
            {

                $messageData = array('message' => $_SESSION['flashmessage'][$name]);
            }

            
            $html = '';        // Define an empty variable

            // Loop trough the array and pull out everymessage

            foreach($messageData as $message)
            {

                $html .= $messageArray['message'] . PHP_EOL;
            }

            
            unset($_SESSION['flashmessage']);
            
            return $html;
        }

        else
        {
            // The session doesn't exsist, we're returning a false statement
            return false;
        }
    }
}


if(!function_exists('setFlashMessage'))
{
    function
setFlashMessage($name, $message)
    {

        
            // Do we have an array
            if(is_array($message))
            {

                // Does the key 'message' exists so we can retrieve the message from the array
                if(!array_key_exists('message', $message))
                {

                    // Yes it exists, now get the array value and store it so we can return it
                    foreach($message as $errormessage)
                    {

                        $messageArray[]['message']        = $errormessage;
                    }
                }

                else
                {
                    // We have an array that already specified the message key
                    // Arrays that don't have the message key are skipped

                    foreach($message as $errormessage)
                    {

                        $messageArray[]['message']        = $errormessage['message'];
                    }
                }
            }

            else
            {
                // String givin, place it in the correct array values
                $messageArray        = array('message' => $errormessage);
            }


            // Set the flash SESSION
            $_SESSION['flashmessage'][$name]    = $messageArray;
    }
}

?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.