Skip to content

Instantly share code, notes, and snippets.

@tlovett1
Created October 13, 2014 19:24
Show Gist options
  • Save tlovett1/ada6798879280ab99c92 to your computer and use it in GitHub Desktop.
Save tlovett1/ada6798879280ab99c92 to your computer and use it in GitHub Desktop.
<?php
// START INDEX.PHP
$mantras = mysql_fetch_assoc( mysql_query( 'SELECT COUNT(*) as count FROM mantras' ) );
?>
Total mantras: <?php echo $mantras['count']; ?>
<form method="post" action="process.php">
<input type="text" name="mantra">
<input type="submit" value="Submit">
</form>
<?php
// END INDEX.PHP
// START PROCESS.PHP
if ( ! empty($_POST['mantra']) ) {
mysql_query( 'INSERT .... INTO mantras' );
// redirect back to old file
header( 'Location: index.php' );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment