PHP没有读取POST变量

时间:2016-06-09 15:53:24

标签: php post

我有一个PHP文件,我传递了很多值。一个如果第一行检查它们是否使用isset设置。 isset有效,因为它确实为我的select语句使用了get值。这是我的insert语句没有值。

    $conn = mysqli_connect("hostname", "user name", "password", "db name");

    // check connection
    if ($conn->connect_error)
    {
      echo ('Database connection failed: '  .mysqli_connect_error);
    }
    else
    {
        echo 'db connected </br>';
    }

function cryptPass($input, $round = 9)
{
    $salt = "";
    $saltChars = array_merge(range('A','Z'), range('a','z'), range('0','9'));
    for($i = 0; $i < 22; $i++)
    {
        $salt .=$saltChars[array_rand($saltChars)];
    }
    return crypt($input, sprintf('$2y$%02d$', $rounds) . $salt);
}


if(isset($_POST['firstName']) && isset($_POST['lastName']) && isset($_POST['email']) && isset($_POST['password']) && isset($_POST['code']) && isset($_POST['diabetes']) && isset($_POST['bloodPressure']) && isset($_POST['fitness']) && isset($_POST['cholesteral']));
{
    //Get post values
    $firstNaame = $_POST['firstName'];
    $lastName = $_POST['lastName'];
    $email = $_POST['email'];
    $password = $_POST['password'];
    $encrptPassword = cryptPass($_password);
    $code = $_GET['code'];
    $diabetes = $_POST['diabetes'];
    $bloodpressure = $_POST['bloodPressure'];
    $fitness = $_POST['fitness'];
    $cholesteral = $_POST['cholesteral'];
    $codeId = "";
    $result = "";

    echo $firstName;

    $sql = "SELECT id FROM mentor where mcode = '" . $code . "'";
    $result = mysqli_query($conn, $sql);

    if((mysqli_num_rows($result))===1)
    {
        while($row = mysqli_fetch_assoc($result))
        {
            $codeId = $row['id'];
            echo $codeId;
        }

        $sql = "INSERT INTO users ('firstName','lastName','email','encrypted_password','diabetes','hiLowChorlesteral','hiLowBloodPressure','fitnessTraining') values('".$firstName."','".$lastName."','".$_email."','".$encryptedPassword."',".$codeId.",".$diabetes.",".$cholesteral.",".$bloodpressure.",".$fitness.")";
        echo($sql);
        mysqli_query($conn,$sql);
    }
    else
    {
        echo "</br>no rows found";
    }
}

我的名字的echo语句出现空白

我的echo语句用于插入节目

  

INSERT INTO用户('firstName','lastName','email','encrypted_pa​​ssword','糖尿病','hiLowChorlesteral','hiLowBloodPressure','fitnessTraining')值('','','', '',1 ,,,,)

它的唯一价值就是获取。

我正在使用网络浏览器进行测试 http://website.com/test/biteboard/CreateContact.php?firstName=larry&lastName=seymour&email=larry@sbmgroup.ca&password=password&code=56gfd&diabetes=0&bloodpressure=0&fitness=0&cholesteral=1

1 个答案:

答案 0 :(得分:-1)

$firstNaame = $_POST['firstName'];

$sql = "INSERT INTO users ('firstName','lastName','email','encrypted_password','diabetes','hiLowChorlesteral','hiLowBloodPressure','fitnessTraining') values('".$firstName."','".$lastName."','".$_email."','".$encryptedPassword."',".$codeId.",".$diabetes.",".$cholesteral.",".$bloodpressure.",".$fitness.")";

您拼错了变量名$ firstNaame ve $ firstName。 PHP中的变量名也区分大小写。