所以我有一个注册,登录系统,一旦用户登录,他们就在他们的帐户中。 从他们的帐户,他们可以填写其他页面上的其他详细信息,即个人详细信息表一旦他们填写了这些细节,它应该将它们返回到他们的帐户,但显然他们的详细信息应该在个人表中的mysql数据库中,但链接到他们在users表中的id(存储注册详细信息) 我有点卡在我的个人形式的代码上,这确保了特定用户的id是相同的。 任何帮助都会很棒
例如,我在两个表中都有'id'。我做了这个汽车公司。我也有一个名为user_id的唯一字段,用于链接表。
我个人的PHP代码:
include 'dbc.php';
$err = array();
if (!empty($_POST['doPersonal']) && $_POST['doPersonal'] == 'Submit')
{
/******************* Filtering/Sanitizing Input *****************************
This code filters harmful script code and escapes data of all POST data
from the user submitted form.
*****************************************************************/
foreach($_POST as $key => $value) {
$data[$key] = filter($value);
}
$host = $_SERVER['HTTP_HOST'];
$host_upper = strtoupper($host);
$path = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
if(empty($err)) {
$sql_insert = "INSERT into `personal`
(`sex`,`aux_citizen`,`birth_place`,`birth_country`,`children`
)
VALUES
('$data[sex]','$data[aux_citizen]','$data[birth_place]',
'$data[birth_country]','$data[children]'
)
";
mysql_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error());
header("Location: thankyou.php");
exit();
}
}
部分用户(注册详情)php代码:
<?php
include 'dbc.php';
$err = array();
if(@$_POST['doRegister'] == 'Register')
{
foreach($_POST as $key => $value) {
$data[$key] = filter($value);
}
$user_ip = $_SERVER['REMOTE_ADDR'];
$sha1pass = PwdHash($data['pwd']);
$host = $_SERVER['HTTP_HOST'];
$host_upper = strtoupper($host);
$path = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$usr_email = $data['usr_email'];
$user_name = $data['user_name'];
$birthday = date("Y-m-d", mktime(0,0,0,$dt,$mo,$yr));
if(empty($err)) {
$sql_insert = "INSERT into `users`
(`full_name`,`user_email`,`pwd`,`nationality`,`department`
,`birthday`,`date`,`users_ip`,`activation_code`,`user_name`
)
VALUES
('$data[full_name]','$usr_email','$sha1pass'
,'$data[nationality]','$data[department]','$birthday'
,now(),'$user_ip','$activ_code','$user_name'
)
";
mysql_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error());
$user_id = mysql_insert_id($link);
$md5_id = md5($user_id);
mysql_query("update users set md5_id='$md5_id' where id='$user_id'");
// echo "<h3>Thank You</h3> We received your submission.";
?>
答案 0 :(得分:0)
究竟是什么问题?将ID保存在PHP中,或将ID字段从个人链接到用户的ID字段?