2013-04-07 76 views
0

嗨,我有一個mysql註冊表,我有困難,50%的時間工作正常沒有任何問題,其他50%的時間失敗。mysql註冊表單工作50/50?

有時經過一次不成功的嘗試,它會在我清空瀏覽器緩存時起作用。

這是否對任何人都有意義,請有人可以告訴我,如果有辦法我可以解決這個問題,謝謝。

<?php ob_start(); 
// CONNECT TO THE DATABASE 
    require('../includes/_config/connection.php'); 
// LOAD FUNCTIONS 
    require('../includes/functions.php'); 
$username = $_POST['username']; 
$password = $_POST['password']; 
$firstname = $_POST['firstname']; 
$lastname = $_POST['lastname']; 
$email = $_POST['email']; 
$number = $_POST['number']; 
$dob = $_POST['dob']; 
$accounttype = $_POST['accounttype']; 
$query="INSERT INTO ptb_registrations (id, 
username, 
password, 
firstname, 
lastname, 
email, 
number, 
dob, 
accounttype, 
date_created) 
VALUES('NULL', 
'".$username."', 
'".$password."', 
'".$firstname."', 
'".$lastname."', 
'".$email."', 
'".$number."', 
'".$dob."', 
'".$accounttype."', 
now() 
)"; 
mysql_query($query) or dieerr(); 
function dieerr() { 
echo '<!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" xml:lang="en"> 
<head> 
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> 
<title></title> 

<link rel="stylesheet" type="text/css" href="css/style.css" media="all" /> 


</head> 
<body background="../assets/img/form/backdrop.png" style="background-repeat:no-repeat; background-size: 100% 2000px;"> 

<div id="container"> 
<h1>REGISTRATION WAS UNSUCCESFULL</h1><br/><br/><br/><br/> 
<div class="textarea"> 
    <h3>Oooops! I tried my hardest to register you onto our system but it looks like one of us has made an error :-(Try and have another go and if there is still a problem then contact one of the Tech Team at <a href=\"mailto:[email protected]\">[email protected]</a></h3> 
</div> 
    <div class="man_reg"><img src="../assets/img/help_support/man.png" alt="" width="210" height="214" /></div></div> 
<div id="progress_bar"> 
    <div id="progress"></div> 
    <div id="progress_text">Registration Completed</div> 
</div> 

<style> 
.textarea{ 
    padding-left:55px; 
    padding-right:55px; 
    text-align:center; 
} 
.man_reg{ 
    margin-top:54px; 
    margin-left:450px; 
} 

</style>  
</body> 
</html>'; 
exit; 
} 
$pass = $_GET['pass']; 


$query="INSERT INTO ptb_users (id, 
user_id, 
first_name, 
last_name, 
email, 
password) 
VALUES('NULL', 
'NULL', 
'".$firstname."', 
'".$lastname."', 
'".$email."', 
MD5('".$password."') 
)"; 
mysql_query($query) or dieerr(); 
$result = mysql_query("UPDATE ptb_users SET ptb_users.user_id=ptb_users.id"); 

$query="INSERT INTO ptb_stats (id, 
user_id, 
display_name) 
VALUES('NULL', 
'NULL', 
'".$username."' 
)"; 
mysql_query($query) or dieerr(); 
$result2 = mysql_query("UPDATE ptb_stats SET ptb_stats.user_id=ptb_stats.id"); 

$query="INSERT INTO ptb_profiles (id, 
user_id, 
display_name, bio, status) 
VALUES('NULL', 
'NULL', 
'".$username."', 
'Welcome, Tell us about yourself?', 
'Whats on your mind?' 
)"; 
mysql_query($query) or dieerr(); 
$result3 = mysql_query("UPDATE ptb_profiles SET ptb_profiles.user_id=ptb_profiles.id"); 

$query="INSERT INTO ptb_profiles_rates (id, 
profile_id) 
VALUES('NULL', 
'NULL' 
)"; 
mysql_query($query) or dieerr(); 
$result4 = mysql_query("UPDATE ptb_profiles_rates SET ptb_profiles_rates.profile_id=ptb_profiles_rates.id"); 

?> 

回答

0

你爲什麼要插入id到id?我想你的ID是自動增量,所以不需要插入ID嘗試那樣

$query="INSERT INTO ptb_registrations (
username, 
password, 
firstname, 
lastname, 
email, 
number, 
dob, 
accounttype, 
date_created) 
VALUES(
'".$username."', 
'".$password."', 
'".$firstname."', 
'".$lastname."', 
'".$email."', 
'".$number."', 
'".$dob."', 
'".$accounttype."', 
now() 
)"; 

其他查詢相同。