2011-12-23 28 views
-2
<php 
include 'connect.php'; 

// table name 
$tbl_name="temp_members_db"; 

//Connect to server and select databse. 
$db = mysql_connect($server, $username, $password) or die ("Unable to connect to Database Server."); 
mysql_select_db ($database, $db) or die ("Could not select database."); 

// Random confirmation code 
$confirm_code=md5(uniqid(rand())); 

// values sent from form 
$name=$_POST['name']; 
$email=$_POST['email']; 
$password=$_POST['password']; 
$country=$_POST['country']; 

$name2="SELECT * FROM $tbl_name WHERE name ='$name'"; 
$name=mysql_query($name2); 

$email2="SELECT * FROM $tbl_name WHERE email ='$email'"; 
$email=mysql_query($email2); 

$password2="SELECT * FROM $tbl_name WHERE password ='$password'"; 
$password=mysql_query($password2); 

$country2="SELECT * FROM $tbl_name WHERE country ='$country'"; 
$country=mysql_query($country2); 

// Insert data into database 
$sql="INSERT INTO $tbl_name(confirm_code, name, email, password, country)VALUES('$confirm_code', '$name2', '$email2', '$password2', '$country2')"; 
$result=mysql_query($sql); 

// if suceesfully inserted data into database, send confirmation link to email 
if($result){ 

// ---------------- SEND MAIL FORM ---------------- 

// send e-mail to ... 
$to=$email; 

// Your subject 
$subject="Your confirmation link here"; 

// From 
$header="from: Admin <[email protected]>"; 

// Your message 
$message="Your Comfirmation link \r\n"; 
$message.="Click on this link to activate your account \r\n"; 
$message.="http://www.mindcollar.com/testconfirm.php?passkey=$confirm_code"; 

// send email 
$sentmail = mail($to,$subject,$message,$header); 

} 

// if not found 
else { 
echo "Not found your email in our database"; 
} 

// if your email succesfully sent 
if($sentmail){ 
echo "Your Confirmation link Has Been Sent To Your Email Address."; 
} 
else { 
echo "Cannot send Confirmation link to your e-mail address"; 
} 

?> 

<table width="350" border="0" align="center" cellpadding="0" cellspacing="0"> 
<tr> 
<td><form name="form1" method="post" action="signup_ac.php"> 
<table width="100%" border="0" cellspacing="4" cellpadding="0"> 
<tr> 
<td colspan="3"><strong>Sign up</strong></td> 
</tr> 
<tr> 
<td width="76">Name</td> 
<td width="3">:</td> 
<td width="305"><input name="name" type="text" id="name" size="30"></td> 
</tr> 
<tr> 
<td>E-mail</td> 
<td>:</td> 
<td><input name="email" type="text" id="email" size="30"></td> 
</tr> 
<tr> 
<td>password</td> 
<td>:</td> 
<td><input name="password" type="password" id="password" size="30"></td> 
</tr> 
<tr> 
<td>Country</td> 
<td>:</td> 
<td><input name="country" type="text" id="country" size="30"></td> 
</tr> 
<tr> 
<td>&nbsp;</td> 
<td>&nbsp;</td> 
<td><input type="submit" name="Submit" value="Submit"> &nbsp; 
<input type="reset" name="Reset" value="Reset"></td> 
</tr> 
</table> 
</form></td> 
</tr> 
</table> 

我想使用這個註冊頁面然後一個確認頁面來創建密碼重置腳本。但我遇到的問題是,當我去「註冊」時,沒有任何事情發生,沒有任何錯誤或結果。表單填充後,我只是重定向到相同的頁面,只是表單重置,沒有任何錯誤明智出現。這個密碼重置代碼有什麼問題?

+0

是'$ _POST'name';'壞的複製和粘貼? – 2011-12-23 23:13:14

+0

對不起,我不得不修復/被傷害在我的眼睛 – 2011-12-23 23:15:07

+0

http://bobby-tables.com/ – 2011-12-23 23:17:52

回答

0

你有一些打字錯誤:

// values sent from form 
$name=$_POST'name'; 
$email=$_POST'email'; 
$password=$_POST'password'; 
$country=$_POST'country'; 

應該

// values sent from form 
$name=$_POST['name']; 
$email=$_POST['email']; 
$password=$_POST['password']; 
$country=$_POST['country']; 

希望這一切。

+2

不,這不是全部。但是代碼並不像你知道你在寫什麼。我認爲從頭開始是最好的主意。 – Yogu 2011-12-23 23:17:30

0

重置代碼沒有任何問題。問題是你不需要從數據庫中選擇任何東西。試試這個:

// values sent from form 
$name  = $_POST['name']; 
$email = $_POST['email']; 
$password = $_POST['password']; 
$country = $_POST['country']; 

// Insert data into database 
$sql="INSERT INTO $tbl_name(confirm_code, name, email, password, country)VALUES('$confirm_code', '$name', '$email', '$password', '$country')"; 
$result=mysql_query($sql);