我有一个订阅表单,我遇到了复选框名为" subscribe"的问题。当我注册,检查订阅框并查看我的帐户时,它不会被检查。您可以在提交按钮之前找到复选框。请帮忙。
<?php
$errorMsg = "";
if (isset($_POST['username'])){
include_once "connect_to_mysql_members.php";
// Filter the posted variables
$username = ereg_replace("[^A-Za-z0-9]", "", $_POST['username']); // filter everything but numbers and letters
$firstname = ereg_replace("[^A-Z a-z0-9]", "", $_POST['firstname']); // filter everything but spaces, numbers, and letters
$lastname = ereg_replace("[^A-Z a-z0-9]", "", $_POST['lastname']); // filter everything but spaces, numbers, and letters
$address = ereg_replace("[^A-Z a-z0-9]", "", $_POST['address']); // filter everything but spaces, numbers, and letters
$day = ereg_replace("[^0-9]", "", $_POST['day']); // filter everything but numbers
$month = ereg_replace("[^A-Z a-z0-9]", "", $_POST['month']); // filter everything but spaces, numbers, and letters
$year = ereg_replace("[^0-9]", "", $_POST['year']); // filter everything but numbers
$accounttype = ereg_replace("[^a-z]", "", $_POST['accounttype']); // filter everything but lowercase letters
$email = stripslashes($_POST['email']);
$email = strip_tags($email);
$email = mysql_real_escape_string($email);
$password = ereg_replace("[^A-Za-z0-9]", "", $_POST['password']); // filter everything but numbers and letters
// Check to see if the user filled all fields with
// the "Required"(*) symbol next to them in the join form
// and print out to them what they have forgotten to put in
if((!$username) || (!$firstname) || (!$lastname) || (!$address) || (!$accounttype) || (!$email) || (!$password)){
$errorMsg = "You did not submit the following required information!<br /><br />";
if(!$username){
$errorMsg .= "--- User Name";
} else if(!$firstname){
$errorMsg .= "--- First Name";
} else if(!$lastname){
$errorMsg .= "--- Last Name";
} else if(!$address){
$errorMsg .= "--- Address";
} else if(!$accounttype){
$errorMsg .= "--- Account Type";
} else if(!$email){
$errorMsg .= "--- Email Address";
} else if(!$password){
$errorMsg .= "--- Password";
}
} else {
// Database duplicate Fields Check
$sql_username_check = mysql_query("SELECT id FROM members WHERE username='$username' LIMIT 1");
$sql_email_check = mysql_query("SELECT id FROM members WHERE email='$email' LIMIT 1");
$username_check = mysql_num_rows($sql_username_check);
$email_check = mysql_num_rows($sql_email_check);
if ($username_check > 0){
$errorMsg = "<u>ERROR:</u><br />Your User Name is already in use inside our system. Please try another.";
} else if ($email_check > 0){
$errorMsg = "<u>ERROR:</u><br />Your Email address is already in use inside our system. Please try another.";
} else {
// Add MD5 Hash to the password variable
$hashedPass = md5($password);
// Add user info into the database table, claim your fields then values
$sql = mysql_query("INSERT INTO members (username, firstname, lastname, address, gender, day, month, year, find, subscribe, accounttype, email, password, signupdate)
VALUES('$username','$firstname','$lastname','$address','$gender','$day','$month','$year','$find','$subscribe','$accounttype','$email','$hashedPass', now())") or die (mysql_error());
// Get the inserted ID here to use in the activation email
$id = mysql_insert_id();
// Create directory(folder) to hold each user files(pics, MP3s, etc.)
mkdir("memberFiles/$id", 0755);
// Start assembly of Email Member the activation link
$to = "$email";
// Change this to your site admin email
$from = "admin@webste.com";
$subject = "Complete your registration";
//Begin HTML Email Message where you need to change the activation URL inside
$message = '<html>
<body bgcolor="#FFFFFF">
Hi ' . $username . ',
<br /><br />
Welcome to my website! You must complete this step to activate your account with us.
<br /><br />
Please click here to activate now >>
<a href="http://website.com/activation.php?id=' . $id . '">
ACTIVATE NOW</a>
<br /><br />
Your Login Data is as follows:
<br /><br />
E-mail Address: ' . $email . ' <br />
Password: ' . $password . '
<br /><br />
Thanks!
</body>
</html>';
// end of message
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
$to = "$to";
// Finally send the activation email to the member
mail($to, $subject, $message, $headers);
// Then print a message to the browser for the joiner
print "<br /><br /><br /><h4>OK $firstname, one last step to verify your email identity:</h4><br />
We just sent an Activation link to: $email<br /><br />
<strong><font color=\"#990000\">Please check your email inbox in a moment</font></strong> to click on the Activation <br />
Link inside the message. After email activation you can log in.";
exit(); // Exit so the form and page does not display, just this success message
} // Close else after database duplicate field value checks
} // Close else after missing vars check
} //Close if $_POST
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"/>
<title>Website - Account Registration</title>
<link rel="shortcut icon" href="icon.png" />
<link rel="icon" href="icon.png" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body marginwidth="0" marginheight="0" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
<center>
<div id="pagewrap">
<?php include_once("header.php");?>
<div id="search_bar_bg"></div>
<div id="pagetitle_register" style="margin-top:0px;"></div>
<table border="0" cellpadding="0" cellspacing="0" width="1182">
<tr>
<td valign="top" width="230">
<div id="product_category">
<li><?php echo $toplink1; ?></li>
<li><?php echo $toplink2; ?></li>
</div>
</td>
<td valign="top" width="950">
<div class="preview_inner">
<table width="950" >
<form action="join_form.php" method="post" enctype="multipart/form-data">
<?php echo "$errorMsg"; ?>
<tr>
<td width="131"><div align="left">User Name:</div></td>
<td width="358"><input name="username" type="text" value="<?php echo "$username"; ?>" /></td>
<td width="148"> </td>
<td width="293"> </td>
</tr>
<tr>
<td><div align="left">First Name: </div></td>
<td><input name="firstname" type="text" value="<?php echo "$firstname"; ?>" /></td>
<td><div align="left">Last Name: </div></td>
<td><input name="lastname" type="text" value="<?php echo "$lastname"; ?>" /></td>
</tr>
<tr>
<td>Gender: </td>
<td><select name="gender">
<option value="<?php echo "$gender"; ?>"><?php echo "$gender"; ?></option>
<option value="female">Female</option>
<option value="male">Male</option>
</select></td>
<td><div align="left">Birthday: </div></td>
<td><input id="day" type="tel" maxlength="2" placeholder="DD" width="10px" value="<?php echo "$day"; ?>"/> /
<input id="month" type="tel" maxlength="2" placeholder="MM" width="10px" value="<?php echo "$month"; ?>"/> /
<input id="year" type="tel" maxlength="4" placeholder="YYYY" width="10px" value="<?php echo "$year"; ?>" /></td>
</tr>
<tr>
<td><div align="left">Address: </div></td>
<td>
<input name="address" type="text" width="100" value="<?php echo "$address"; ?>" />
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><div align="left">Email: </div></td>
<td><input name="email" type="text" value="<?php echo "$email"; ?>" /></td>
<td><div align="left">Account Type: </div></td>
<td><select name="accounttype">
<option value="<?php echo "$accounttype"; ?>"><?php echo "$accounttype"; ?></option>
<option value="a">Beauty Addict</option>
<option value="b">Makeup Artist</option>
<option value="c">Skin Expert</option>
</select></td>
</tr>
<tr>
<td><div align="left"> Password: </div></td>
<td><input name="password" type="password" value="<?php echo "$password"; ?>" /> <br />
<font size="-2" color="#006600">(letters or numbers only, no spaces and symbols)</font></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>How did you find us?</td>
<td> <select name="find" id="find">
<option>Store</option>
<option>Magazines</option>
<option>Newspapers</option>
<option>Relatives and friends</option>
<option>Online</option></select></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2"><input type="checkbox" id="subscribe" checked style="width:18px; height:18px;"> Subscribe to newsletter</td>
<td> </td>
<td align="right"><input type="submit" name="Submit" value="Submit Form" /></td>
</tr>
</form>
</table>
</div></td>
</tr>
</table>
<br />
<br /><?php include_once("footer.php");?>
</div>
</center>
</body>
</html>