我正在尝试创建这些页面。第一页获取用户的信息,然后将其保存在phpadmin上,然后它将选择进入和退出页面的日期。但是,如果用户输入进入和退出时间,然后输入属性表,则不会保存输入日期,退出日期和用户名。但问题是,用户名不会保持不变。就像我昨天创建这些页面一样,一切都运行正常,但现在,有一个问题,我删除了一些客户名称并重新输入新的名称但是当我尝试使用php时,它会一直显示旧的用户名。这是一个例子, 在此图片中,在我选择注册表单输入数据后,已删除的人的用户名和密码开始出现:
在此图片中,我输入之前的DIFFERENT用户名后,仍会从旧的已删除数据库中获取用户名并将其放入我的phpadmin。例如,我在屏幕顶部放置了一个用户名xand1,用户名取得了来自我旧数据库的值andy91:
这是我的注册代码:
<?php
$firstnameError = $lastnameError = $usernameError = $passwordError = $birthdateError = $mobileError = $emailError = "";
// Check if data are posted.
if (isset($_POST['submit'])){
$firstname = $lastname = $username = $password = $birthdate = $mobile = $email = "";
$errorOccured = false;
if (isset($_POST['tsmFirstName'])){
$firstname = trim($_POST['tsmFirstName']);
if (strlen($firstname) == 0){
$firstnameError = "First Name is missing";
$errorOccured = true;
}
}
else{
$firstnameError = "First Name is missing";
}
//Checking last name
if (isset($_POST['tsmLastName'])){
$lastname = trim($_POST['tsmLastName']);
if (strlen($lastname) == 0){
$lastnameError = "First Name is missing";
$errorOccured = true;
}
}
else{
$lastnameError = "First Name is missing";
}
//checking the username
if (isset($_POST['tsmUserName'])){
$username = trim($_POST['tsmUserName']);
$usernameLenght = strlen($username);
if ($usernameLenght == 0){
$usernameError = "First Name is missing";
$errorOccured = true;
}
elseif ($usernameLenght < 4){
$usernameError = "Your username should be minimum 4 characters";
$errorOccured = true;
}
}
else{
$usernameError = "First Name is missing";
}
//checking the password
if (isset($_POST['tsmPassword'])){
$password = trim($_POST['tsmPassword']);
if (strlen($password) == 0){
$passwordError = "First Name is missing";
$errorOccured = true;
}
}
else{
$passwordError = "First Name is missing";
}
//checking the birthdate
if (isset($_POST['tsmBirthDate'])){
$birthdate = trim($_POST['tsmBirthDate']);
if (strlen($birthdate) == 0){
$birthdateError = "First Name is missing";
$errorOccured = true;
}
}
else{
$birthdateError = "First Name is missing";
}
// checking the mobile
if (isset($_POST['tsmMobile'])){
$mobile = trim($_POST['tsmMobile']);
if (strlen($mobile) == 0){
$mobileError = "First Name is missing";
$errorOccured = true;
}
}
else{
$mobileError = "Mobile is missing";
}
//checking the email
if (isset($_POST['tsmEmail'])){
$email = trim($_POST['tsmEmail']);
if (strlen($email) == 0){
$emailError = "Email is missing";
$errorOccured = true;
}
}
else{
$emailError = "Email is missing";
}
if(!$errorOccured){
require_once("connection.php");
$_SESSION['tsmUserName']=$username;
var_dump($_SESSION);
$keychain= sha1($username);
$my_query="INSERT INTO users (id, firstname, lastname, username, password, birthdate, mobile, email, status, keychain) VALUES (NULL,'$firstname','$lastname','$username','$password','2016-1-1','$mobile','$email','0','$keychain')";
$result=mysqli_query($connection,$my_query);
if($result){
$message_mail = "Dear $firstname, <br> Thank You for registering with us. Click now on the link below to activate your account. <br> $keychain <br><br> Thank You.";
$subject_mail= "Your account has been created";
$to_mail = $email;
$headers[]= 'MIME-Version 1.0';
$headers[]= 'content-type:text/html; charset=utf8';
$headers[]= 'From: admin@tassimo.com';
mail($to_mail,$subject_mail,$message_mail,implode("\r\n",$headers));
//after email is sent redirect to thank you page.
header("Location:completed.php?task=done");
exit();
echo 'Thank You';
}
else{
echo "<b> Error unable to post. </b>";
mysqli_error($connection);
}
mysqli_close($connection);
}
}
?>
这里是时间
<?php
session_start();
$EntryError=$ExitError="";
if (isset($_POST['submit'])){
$entrydate = $exitdate = "";
$errorOccured = false;
if (isset($_POST['tsmdate'])){
$entrydate = trim($_POST['tsmdate']);
if (strlen($entrydate) == 0){
$EntryError = "date is missing";
$errorOccured = true;
}
}
else{
$EntryError = "date is missing";
}
// checking for last name
if (isset($_POST['tsmexit'])){
$exitdate = trim($_POST['tsmexit']);
if (strlen($exitdate) == 0){
$ExitError = "First Name is missing";
$errorOccured = true;
}
}
else{
$ExitError = "last Name is missing";
}
$ids=$_SESSION['tsmUserName'];
var_dump($_SESSION);
if(!$errorOccured){
require_once("connection.php");
$my_query="INSERT INTO timing (`No`, `Entry Date and Time`, `Exit Date and Time`, `Username`) VALUES (NULL,'$EntryError','$exitdate','$ids')";
$result=mysqli_query($connection,$my_query);
if($result)
{
echo 'thank you';
}
else
{
echo 'error';
}
mysqli_close($connection);
}
}
?>
答案 0 :(得分:0)
你们所有人的第一个错误都有相同的描述“缺少名字”。我认为你应该改变这一点。如果您上传的第二个代码与$ _SESSION ['tsmUserName']相同,那就太好了。
关于第一个屏幕,您可以删除浏览器数据以删除自动填充选项。