for some reason my sql insert isn't working???
<?php
//first do a check for each variable typed in by the user. ie. validate each field
$_POST['name'];
$_POST['email'];
$_POST['comment'];
$_POST['question'];
$check = 0;
$today = date('Y-m-d');
$answer = strtolower(trim($_POST['question']));
$name = trim($_POST['name']);
$email = trim($_POST['email']);
$comment = trim($_POST['comment']);
if (empty($name)){
echo "You forgot to include your name?!";
?><br /><a href="http://localhost/engagement/photos-of-james-and-laura.php">Please include your name.</a><?php
return false;
}
if (empty($email)){
echo "You must include a valid email!";
?><br /><a href="http://localhost/engagement/photos-of-james-and-laura.php">Please Include a valid email.</a><?php
return false;
}
if (empty($comment)){
echo "You didn't leave a comment?";
?><br /><a href="http://localhost/engagement/photos-of-james-and-laura.php">Please leave a comment.</a><?php
return false;
}
if (empty($answer)){
echo "You forgot to answer the security question?!";
?><br /><a href="http://localhost/engagement/photos-of-james-and-laura.php">Please answer the security question.</a><?php
return false;
}
if (($answer = "weaver" || $answer = "mcgrath")) {
$check = 1;
} else {
echo "You didn't correctly answer the security question?!";
?><br /><a href="http://localhost/engagement/photos-of-james-and-laura.php">Please try again.</a><?php
}
if (((strlen($name)) > 0) && (strlen($name)) < 26) {
$check = 2;
} else {
echo "Your name is too long.";
?><br /><a href="http://localhost/engagement/photos-of-james-and-laura.php">Please shorten your name.</a><?php
}
$regexp = "/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/";
$emailCheck = $email;
if (preg_match($regexp, $emailCheck)) {
$check = 3;
} else {
echo "You didn't enter a valid email address.";
?><br /><a href="http://localhost/engagement/photos-of-james-and-laura.php">Please enter a valid email!</a><?php
}
if (((strlen($comment)) > 0) && (strlen($comment)) < 255) {
$check = 4;
} else {
echo "Your comment is too long! Please shorten it a bit.";
?><a href="http://localhost/engagement/photos-of-james-and-laura.php">Back to Comment Page</a><?php
}
//all of the variable have been checked and now it's time to enter the info into the database and then send the user back to the
//photography page in order to see their comment.
//connect to the db
$connect = mysql_connect("localhost","root","")
or die("Hey taht didn't work");
//make sure you have the correct db
mysql_select_db("married");
$sql = "INSERT INTO user ('user_name','user_email','user_date','user_comment') VALUES ('name','email','2011-01-01','comment')";
$result = mysql_query($sql);
if (!$result) {
echo (mysql_error());
} else {
echo "Information inserted\n";
}
mysql_close();
//send them back to the photo page so they can see their comment!
//header( 'Location: http://localhost/engagement/photos-of-james-and-laura.php' ) ;
?>
<?php
//first do a check for each variable typed in by the user. ie. validate each field
$_POST['name'];
$_POST['email'];
$_POST['comment'];
$_POST['question'];
$check = 0;
$today = date('Y-m-d');
$answer = strtolower(trim($_POST['question']));
$name = trim($_POST['name']);
$email = trim($_POST['email']);
$comment = trim($_POST['comment']);
if (empty($name)){
echo "You forgot to include your name?!";
?><br /><a href="http://localhost/engagement/photos-of-james-and-laura.php">Please include your name.</a><?php
return false;
}
if (empty($email)){
echo "You must include a valid email!";
?><br /><a href="http://localhost/engagement/photos-of-james-and-laura.php">Please Include a valid email.</a><?php
return false;
}
if (empty($comment)){
echo "You didn't leave a comment?";
?><br /><a href="http://localhost/engagement/photos-of-james-and-laura.php">Please leave a comment.</a><?php
return false;
}
if (empty($answer)){
echo "You forgot to answer the security question?!";
?><br /><a href="http://localhost/engagement/photos-of-james-and-laura.php">Please answer the security question.</a><?php
return false;
}
if (($answer = "weaver" || $answer = "mcgrath")) {
$check = 1;
} else {
echo "You didn't correctly answer the security question?!";
?><br /><a href="http://localhost/engagement/photos-of-james-and-laura.php">Please try again.</a><?php
}
if (((strlen($name)) > 0) && (strlen($name)) < 26) {
$check = 2;
} else {
echo "Your name is too long.";
?><br /><a href="http://localhost/engagement/photos-of-james-and-laura.php">Please shorten your name.</a><?php
}
$regexp = "/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/";
$emailCheck = $email;
if (preg_match($regexp, $emailCheck)) {
$check = 3;
} else {
echo "You didn't enter a valid email address.";
?><br /><a href="http://localhost/engagement/photos-of-james-and-laura.php">Please enter a valid email!</a><?php
}
if (((strlen($comment)) > 0) && (strlen($comment)) < 255) {
$check = 4;
} else {
echo "Your comment is too long! Please shorten it a bit.";
?><a href="http://localhost/engagement/photos-of-james-and-laura.php">Back to Comment Page</a><?php
}
//all of the variable have been checked and now it's time to enter the info into the database and then send the user back to the
//photography page in order to see their comment.
//connect to the db
$connect = mysql_connect("localhost","root","")
or die("Hey taht didn't work");
//make sure you have the correct db
mysql_select_db("married");
$sql = "INSERT INTO user ('user_name','user_email','user_date','user_comment') VALUES ('name','email','2011-01-01','comment')";
$result = mysql_query($sql);
if (!$result) {
echo (mysql_error());
} else {
echo "Information inserted\n";
}
mysql_close();
//send them back to the photo page so they can see their comment!
//header( 'Location: http://localhost/engagement/photos-of-james-and-laura.php' ) ;
?>