Kan ik GET gebruiken?

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Ventilatiesysteem Productontwikkelaar HBO WO Verwa

Samengevat: Zij bieden flexibele ventilatiematerialen, geluidsdempers, rookgasafvoer producten en industrieslangen. Ben jij een technisch productontwikkelaar? Heb jij ervaring met het ontwikkelen van nieuwe producten? Vaste baan: Technisch Productontwikkelaar HBO WO €3.000 - €4.000 Zij bieden een variëteit aan flexibele ventilatiematerialen, geluiddempers, rookgasafvoer producten, industrieslangen en ventilatieslangen voor de scheepsbouw. Met slimme en innovatieve materialen zorgen wij voor een gezonde en frisse leefomgeving. Deze werkgever is een organisatie die volop in ontwikkeling is met hardwerkende collega's. Dit geeft goede ontwikkelingsmogelijkheden. De branche van dit bedrijf is Techniek en Engineering. Functie: Voor de vacature als Technisch Productontwikkelaar Ede Gld HBO WO ga

Bekijk vacature »

Rick de Jong

Rick de Jong

04/08/2012 23:11:42
Quote Anchor link
Hallo,

Ik vroeg me af of ik hier de GET functie kan gebruiken. Zoja, hoe?

(bijv: xx.php?dag=maandag&uur=4 etc.)

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
<?php

$APPLICATION_ID
= "xxx";
$REST_API_KEY = "xxx";
$MESSAGE = "";

if (!empty($_POST)) {

    $errors = array();
    foreach (array('app' => 'APPLICATION_ID', 'api' => 'REST_API_KEY', 'body' => 'MESSAGE', 'body2' => 'MESSAGE2', 'body3' => 'MESSAGE3') as $key => $var) {
        if (empty($_POST[$key])) {
            $errors[$var] = true;
        }
else {
            $$var = $_POST[$key];
        }
    }


    if (!$errors) {
        $url = 'https://api.parse.com/1/push';
        $data = array(
            'channel' => 'ict',
            'type' => 'ios',
            'data' => array(
                'alert' => $MESSAGE. ': Roosterwijziging voor ' .$MESSAGE2. ', vak: ' .$MESSAGE3,
            ),
        );

        $_data = json_encode($data);
        $headers = array(
            'X-Parse-Application-Id: ' . $APPLICATION_ID,
            'X-Parse-REST-API-Key: ' . $REST_API_KEY,
            'Content-Type: application/json',
            'Content-Length: ' . strlen($_data),
        );


        $curl = curl_init($url);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $response = curl_exec($curl);
    }


 if (!$errors) {
        $url = 'https://api.parse.com/1/push';
        $data = array(
            'channel' => 'ict',
            'type' => 'android',
            'data' => array(
                'alert' => $MESSAGE. ': Roosterwijziging voor ' .$MESSAGE2. ', vak: ' .$MESSAGE3,
            ),
        );

        $_data = json_encode($data);
        $headers = array(
            'X-Parse-Application-Id: ' . $APPLICATION_ID,
            'X-Parse-REST-API-Key: ' . $REST_API_KEY,
            'Content-Type: application/json',
            'Content-Length: ' . strlen($_data),
        );


        $curl = curl_init($url);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $response = curl_exec($curl);
    }


}

?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nl" lang="nl">
<head>
<meta charset="utf-8" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Push Notificaties API</title>
</head>
<body>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
<?php if (isset($response)) {
        echo '<h2>Antwoord van Server</h2>';
        echo '<pre>' . htmlspecialchars($response) . '</pre>';
        echo '<hr>';
    }
elseif ($_POST) {
        echo '<h2>Fout van Server</h2>';
        echo '<pre>';
        var_dump($APPLICATION_ID, $REST_API_KEY, $MESSAGE);
        echo '</pre>';
    }
?>


<form id="parse" action="" method="post" accept-encoding="UTF-8">
<p>
<label for="app">Android Push-server</label><br />
<input type="text" name="app" id="app" value="
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo htmlspecialchars($APPLICATION_ID); ?>
" READONLY>
</p>
<p>
<label for="api">iOS Push-server</label><br />
<input type="text" name="api" id="api" value="
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo htmlspecialchars($REST_API_KEY); ?>
" READONLY>
</p>
<p>
<label for="api">Klas:</label><br />
<input type="text" name="body" id="body" value="
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo htmlspecialchars($MESSAGE); ?>
">
</p>
<p>
<label for="api">Dag:</label><br />
<input type="text" name="body2" id="body2" value="
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo htmlspecialchars($MESSAGE2); ?>
">
</p>
<p>
<label for="api">Vak:</label><br />
<input type="text" name="body3" id="body3" value="
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo htmlspecialchars($MESSAGE3); ?>
">
</p>
<p>
<input type="submit" value="Stuur Push Notificatie">
</p>
</form>
</body>
</html>

bedankt!
Gewijzigd op 04/08/2012 23:12:00 door Rick de Jong
 
PHP hulp

PHP hulp

09/05/2024 03:41:01
 
Obelix Idefix

Obelix Idefix

05/08/2012 08:40:59
Quote Anchor link
Code aub tussen code-tags.

Rick de Jong op 04/08/2012 23:11:42:
Ik vroeg me af of ik hier de GET functie kan gebruiken. Zoja, hoe?
(bijv: xx.php?dag=maandag&uur=4 etc.)


Vanwaar je vraag? Al geprobeerd?
Op zich zou $_GET['dag'] en $_GET['uur'] moeten werken.
Controleer deze waarden wel (uur zal bv altijd een geheel getal tussen 0 en 24 moeten zijn).

if (!empty($_POST)) is niet de meest geschikte manier om te controleren of een formulier verzonden is. Gebruik liever:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
if($_SERVER['REQUEST_METHOD'] === 'POST')

Het gebruik van empty wordt niet door iedereen aanbevolen om te controleren; doorgaans is isset beter.
Gewijzigd op 05/08/2012 08:43:08 door Obelix Idefix
 
Erwin H

Erwin H

05/08/2012 08:50:34
Quote Anchor link
GET is geen functie, maar $_GET is een globale variabele.
 
Eddy E

Eddy E

05/08/2012 11:14:02
Quote Anchor link
CTRL-H op $_POST > $_GET en je weet het?
 
Rick de Jong

Rick de Jong

05/08/2012 15:24:41
Quote Anchor link
Hoe kan ik het formulier laten verzenden als de pagina wordt geopend?
 



Overzicht Reageren

 
 

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.