Skip to content

Commit

Permalink
Updated files for Verbs chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
lornajane committed Sep 13, 2015
1 parent 2b223a4 commit 10bf36b
Show file tree
Hide file tree
Showing 14 changed files with 318 additions and 55 deletions.
1 change: 1 addition & 0 deletions Chapter2-Verbs/.gitignore
@@ -0,0 +1 @@
vendor/*
5 changes: 5 additions & 0 deletions Chapter2-Verbs/composer.json
@@ -0,0 +1,5 @@
{
"require": {
"guzzlehttp/guzzle": "~6.0"
}
}
238 changes: 238 additions & 0 deletions Chapter2-Verbs/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
2 changes: 1 addition & 1 deletion Chapter2-Verbs/get-form-curl.php
@@ -1,7 +1,7 @@
<?php

$url = 'http://localhost/book/get-form-page.php';
$data = array("category" => "technology", "rows" => 20);
$data = ["category" => "technology", "rows" => 20];

$get_addr = $url . '?' . http_build_query($data);
$ch = curl_init($get_addr);
Expand Down
34 changes: 22 additions & 12 deletions Chapter2-Verbs/get-form-page.php
@@ -1,28 +1,38 @@
<?php
<html>
<head>
<title>GET Form</title>
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css">
</head>
<body>
<div style="margin: 20px">
<h1>A GET Form</h1>

if(empty($_GET)) {

?>
<?php if(empty($_GET)): ?>

<form name="search" method="get">
<form name="search" method="get" class="pure-form pure-form-stacked">
Category:
<select name="category">
<option value="entertainment">Entertainment</option>
<option value="sport">Sport</option>
<option value="technology">Technology</option>
</select> <br />
</select>

Rows per page: <select name="rows">
<option value="10">10</option>
<option value="20">20</option>
<option value="50">50</option>
</select> <br />
</select>

<input type="submit" value="Search" />
<input type="submit" value="Search" class="pure-button pure-button-primary"/>
</form>

<?php
} else {
echo "Wonderfully filtered search results";
}
<?php else: ?>

<p>Wonderfully filtered search results</p>

<?php endif; ?>

</div>
</body>
</html>

2 changes: 1 addition & 1 deletion Chapter2-Verbs/get-form-stream.php
@@ -1,7 +1,7 @@
<?php

$url = 'http://localhost/book/get-form-page.php';
$data = array("category" => "technology", "rows" => 20);
$data = ["category" => "technology", "rows" => 20];

$get_addr = $url . '?' . http_build_query($data);
$page = file_get_contents($get_addr);
Expand Down
10 changes: 10 additions & 0 deletions Chapter2-Verbs/post-form-guzzle.php
@@ -0,0 +1,10 @@
<?php
require "vendor/autoload.php";

$url = 'http://localhost/book/post-form-page.php';
$data = ["email" => "lorna@example.com", "display_name" => "LornaJane"];

$client = new \GuzzleHttp\Client();
$page = $client->post($url, ["form_params" => $data]);
echo $page->getBody();

11 changes: 0 additions & 11 deletions Chapter2-Verbs/post-form-http.php

This file was deleted.

30 changes: 19 additions & 11 deletions Chapter2-Verbs/post-form-page.php
@@ -1,22 +1,30 @@
<?php
<html>
<head>
<title>POST Form</title>
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css">
</head>
<body>
<div style="margin: 20px">
<h1>A POST Form</h1>

if(empty($_POST)) {

?>
<?php if(empty($_POST)): ?>

<form name="user" method="post">
<form name="user" method="post" class="pure-form pure-form-stacked">
Email:
<input type="text" length="60" name="email" /><br />
<input type="text" length="60" name="email" />

Display name:
<input type="text" length="60" name="display_name" /><br />
<input type="text" length="60" name="display_name" />

<input type="submit" value="Go" />
<input type="submit" value="Go" class="pure-button pure-button-primary"/>
</form>

<?php
} else {
<?php else:
echo "New user email: " . filter_input(INPUT_POST,
"email", FILTER_VALIDATE_EMAIL);
}
endif; ?>

</div>
</body>
</html>

0 comments on commit 10bf36b

Please sign in to comment.