Created
October 8, 2012 02:32
-
-
Save BaylorRae/3850422 to your computer and use it in GitHub Desktop.
Source code for (continued): http://baylorrae.com/the-basics-of-creating-a-cms-with-php/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array( | |
'url' => '...', | |
'title' => '...', | |
'author' => '...', | |
'id' => 123 // the new item | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if( $stmt->execute($_POST['website'] + array('id' => $_GET['id'])) ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // this goes in index.php ?> | |
<!-- output: <a href="__URL__">__TITLE</a> by: __AUTHOR__ --> | |
from: <?php echo $website->author ?> | | |
<a href="edit.php?id=<?php echo $website->id ?>">Edit</a> | | |
<a href="delete.php?id=<?php echo $website->id ?>">Delete</a> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* delete.php | |
*/ | |
include 'global.php'; | |
// the id wasn't passed | |
if( !isset($_GET['id']) ) { | |
header("Location: index.php"); | |
} | |
// prepare the query to find the website by id | |
$stmt = $dbh->prepare("DELETE FROM `websites` WHERE `id` = :id"); | |
// execute the query with the current id | |
if( $stmt->execute(array('id' => $_GET['id'])) ) { | |
header("Location: index.php"); | |
} | |
echo "failed to delete the item"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment