MySQL添加没有拾取一个字段

时间:2016-06-14 19:31:10

标签: php forms mysqli phpmyadmin

我正在做一个从p2pmyadmin数据库添加,更新,删除等记录的项目。

我正在处理当前的代码。点击更新后,除了' Surname'领域。我无法弄清楚为什么......有人可以提出建议吗?

$dirtyPassword = $_POST['frmPassword1'];

if (isset($_POST['formName']) && $_POST['formName'] == "addUser") {

   if ( ($_POST['frmSurname'] != '') &&
     ($_POST['frmEmail'] != '') &&
     ($_POST['frmPassword1'] != '') ) {


    if ($_POST['frmPassword1'] != $_POST['frmPassword2'] )  {

        echo "Passwords do not match!";

//Clean form values
$cleanFirstName = mysqli_real_escape_string($db, $_POST['frmName']);
$cleanSurname = mysqli_real_escape_string($db, $_POST['frmSurname']);
$cleanEmail = mysqli_real_escape_string($db, $_POST['frmEmail']);

//Clean password
$password   = sha1(mysqli_real_escape_string($db,      $_POST['frmPassword1']));

// Build username
$username       =      strtolower($cleanFirstName.substr($cleanSurname,0,1));
$dateTime       = date('Y-m-d g:i:s',time());


// Check email is unique
$QryEmail = "SELECT  *
            FROM    registeredUsers
            WHERE   EmailAddress  = '$cleanEmail'";

$chkEmail = mysqli_query($db,$QryEmail);

$numChkRowsE = mysqli_num_rows($chkEmail); 

// Check Username is unique
$QryID = "SELECT  *
        FROM    registeredUsers
        WHERE    UserName = '$username'";

$ChkID = mysqli_query($db,$QryID);

$numChkRowsI = mysqli_num_rows($chkID); 

//check that zero records returned (no duplicates)
if ($numChkRowsE == 0 && $numChkRowsI == 0){

//Query
$query = "INSERT INTO registeredUsers VALUES(NULL, '$username', '$cleanFirstName', '$cleanSurname', '$cleanEmail', '$password', '$dateTime', 0) ";

$insQry = mysqli_query($db,$query);

if ($insQry) { 
             /* SUCCESS */ 
             $_SESSION['success'] = 'Registration successful';
             header("Location:project-users-manage.php");
             exit;
        } else {
             /* FAIL */ 

        }
     }
    }   
?>

<fieldset style =width:30%>
<form method="post" action="">
<p>
        First Name :    <input type="text"     name="frmName"    value="" placeholder='First Name'><br>
        Surname: <input type="text" name="frmSurname"  value="" placeholder='Surname'><br>
        Email Address:    <input type="text"     name="frmEmail"     value="" placeholder='Email Address'><br>
        Password: <input type="password" name="frmPassword1"  value="" placeholder='Password'><br>
        Repeat Password: <input type="password" name="frmPassword2"  value="" placeholder='Password Again'><br>
        <input type="submit"   name="Register"       value="Register">
        <input type='hidden' name='formName' value='addUser' />
    </p>
</form>

<br>
    <a href='project-users-manage.php'>User Management</a>
    <a href=''>Logout</a>

0 个答案:

没有答案