i have a PHP file that i am, passing numerous values in to. one if the first lines checks to see if they are set using isset. the isset worksbecause it does use a get value for my select statement. it is my insert statement that has no values.
$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";
}
}
my echo statement for firstname comes up empty
my echo statement for insert into shows
INSERT INTO users ('firstName','lastName','email','encrypted_password','diabetes','hiLowChorlesteral','hiLowBloodPressure','fitnessTraining') values('','','','',1,,,,)
the only value that it seems to pickup is the get.
i am testing from a web browser using 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