Skip to content

Commit

Permalink
Update some more methods to get the request method of a request
Browse files Browse the repository at this point in the history
  • Loading branch information
cmelbye committed Dec 10, 2008
1 parent 57c43fb commit 0e9d739
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
18 changes: 8 additions & 10 deletions controllers/GameController.php
Expand Up @@ -3,17 +3,15 @@
class GameController extends WebApp_Controller {
protected $step = 1;

public function __construct() {
$this->step = substr( $_SERVER['REQUEST_URI'], 1 );
}

public function get() {
echo $this->step;
public function execute() {
$this->execute();
if( $this->method == 'POST' )
WebApp_Template::render( 'game/result' );

WebApp_Template::render( 'game/form' );
}

public function post() {
echo $this->step;
WebApp_Template::render( 'game/result' );
}
public function get() {}
public function post() {}
}
6 changes: 5 additions & 1 deletion library/WebApp/Controller.php
@@ -1,7 +1,11 @@
<?php

class WebApp_Controller {
public function __construct() {}
protected $method;

public function __construct() {
$this->method = $_SERVER['REQUEST_METHOD'];
}

public function execute() {
switch( $_SERVER['REQUEST_METHOD'] ) {
Expand Down
7 changes: 6 additions & 1 deletion templates/game/form.phtml
@@ -1,6 +1,11 @@
<h2>Form Demo</h2>

<form action="/step2" method="post">
<?php
$step = substr( $_SERVER['REQUEST_URI'], 5 );
$step++;
?>

<form action="/step<?= $step ?>" method="post">
<p>
<label for="info">Information to Send</label><br />
<input type="text" name="info" value="Hello from the get() method!" />
Expand Down

0 comments on commit 0e9d739

Please sign in to comment.