Skip to content

Instantly share code, notes, and snippets.

@westonruter
Created April 20, 2010 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westonruter/373129 to your computer and use it in GitHub Desktop.
Save westonruter/373129 to your computer and use it in GitHub Desktop.
HTTP 201 Created redirect test
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST'):
header("Location: http://$_SERVER[HTTP_HOST]/create.php?created", true, 201);
?>
Created <a href='create.php?created'>resource</a>
<?php
exit;
elseif($_SERVER['QUERY_STRING'] == 'created'): ?>
<h1>I am the created resource!</h1>
<?php endif; ?>
<form action=create.php method=post>
<button type=submit>Create a resource</button>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment