只是为了显示整个代码。以下所有查询都有效。
<?php
$errorMsg = "";
$x1 = "";
$x2 = "";
$x3 = "";
$x4 = "";
$email = "";
$password = "";
$x7= "";
if (isset ($_POST['x1'])){
$x1 = $_POST['x1'];
$x2 = $_POST['x2'];
$x3 = $_POST['x3'];
$x4 = $_POST['x4'];
$email = $_POST['email'];
$password = $_POST['password'];
$x7= $_POST['x7'];
$x1 = stripslashes($x1);
$x2 = stripslashes($x2);
$x3 = stripslashes($x3);
$x4 = stripslashes($x4);
$email = stripslashes($email);
$password = stripslashes($password);
$x7= stripslashes($x7);
$x1 = strip_tags($x1);
$x2 = strip_tags($x2);
$x3 = strip_tags($x3);
$x4 = strip_tags($x4);
$email = strip_tags($email);
$password = strip_tags($password);
$x7= strip_tags($x7);
include_once "scripts/connect_to_mysql.php";
$emailCHecker = mysql_real_escape_string($email);
$emailCHecker = eregi_replace("`", "", $emailCHecker);
$sql_email_check = mysql_query("SELECT email FROM tablename WHERE email='$emailCHecker'");
$email_check = mysql_num_rows($sql_email_check);
if ((!$x1) || (!$x2) || (!$x3) || (!$x4) || (!$email) || (!$password) || (!$x7)) {
$errorMsg = 'following issues are missing<br />';
if(!$x1){
$errorMsg .= ' *x1<br />';
}
if(!$x2){
$errorMsg .= ' *x2<br />';
}
if(!$x3){
$errorMsg .= ' *x3<br />';
}
if(!$x4){
$errorMsg .= ' *x4<br />';
}
if(!$email){
$errorMsg .= ' *email<br />';
}
if(!$x7){
$errorMsg .= ' *x7<br />';
}
} else if ($email_check > 0){
$errorMsg = "Mail already exists";
} else
{
$x1 = mysql_real_escape_string($x1);
$x2 = mysql_real_escape_string($x2);
$x3 = mysql_real_escape_string($x3);
$x4 = mysql_real_escape_string($x4);
$email = mysql_real_escape_string($email);
$password = mysql_real_escape_string($password);
$x1 = eregi_replace("`", "", $x1);
$x2 = eregi_replace("`", "", $x2);
$x3 = eregi_replace("`", "", $x3);
$x4 = eregi_replace("`", "", $x4);
$email = eregi_replace("`", "", $email);
$db_password = md5($password);
$sql = mysql_query("INSERT INTO tablename (x1, x2, x3, x4, sign_up_date, email, password)
VALUES('$x1','$x2','$x3','$x4', now(), '$email','$db_password')")
or die (mysql_error());
$id = mysql_insert_id();
/*mkdir("members/$id", 0755); */
$to = "$email";
$from = "xxx@xxx.xx";
$subject = "activationlink";
$message = "Link for activation";
$headers = "From: $from\r\n";
$headers .= "Content-type: text\r\n";
mail($to, $subject, $message, $headers);
$msgToUser = "text";
/*include_once 'msgToUser.php'; */
exit();
}
} else {
$errorMsg = "Errormessages";
$x1 = "";
$x2 = "";
$x3 = "";
$x4 = "";
$email = "";
$password = "";
$x7 = "";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>XXXX</title>
<link rel="stylesheet" href="css/colorbox.css" />
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery.colorbox.js"></script>
<?php if **a variable or clause will be true: ?>
<script type="text/javascript">
$(document).ready(function(){
$.colorbox({iframe:true, scrolling:false, href:"#$msgToUser.php", innerWidth:"408px", innerHeight:"292px", opacity:0.75, overlayClose:false, escKey:false, });
});
$("#colorboxCloseBtn").click(function() {
$.colorbox.close();
});
$(document).ready(function() {
/* Automatically resize to content
var y = $(document.body).height();
var x = $(document).width();
parent.$.colorbox.resize({innerWidth:x, innerHeight:y});*/
$("#button_cancel").click(function() {
parent.$.colorbox.close();
return false;
})
});
</script>
<?php endif; ?>