0

嗨,我有一个 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:support@playtimeboys.com\">Support@PlaytimeBoys.com</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");

?> 
4

1 回答 1

0

为什么要在 id 中插入 null ?我猜你的 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()
)";

其他查询也一样。

于 2013-04-07T20:53:48.560 回答