Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $server = "localhost";
- $user = "isonuZ";
- $pass = "150NuZ!";
- $db = "test";
- $tb_name = "guestbook";
- $connection = mysql_connect($server, $user, $pass) or die(mysql_error());
- @mysql_select_db($db);
- function validation($var) {
- if(isset($_POST[$var])){
- return $_POST[$var];
- } else {
- die("Didn't work");
- }
- }
- $name = validation("name"); //textbox must be named 'name'
- $email = validation("email"); //textbox must be named email
- $comment = validation("comment"); //textbox must be named comment
- $datetime = date("y-m-d h:i:s"); //date-time
- $query = "INSERT INTO '{$tb_name}'(name, email, comment, datatime) VALUES('{$name}', '{$email}', '{$comment}', '{$datetime}')";
- $result = mysql_query($query) or die(mysql_error());
- if($result) {
- echo "Everything went better than expected!<br /><a href=\"viewguestbook.php\">Dude, you should totally view the guestbook now!</a>";
- } else {
- echo "Something went wrong...";
- }
- mysql_close();
- ?>
Add Comment
Please, Sign In to add comment