Monday, 9 September 2013

PHP query wont work

PHP query wont work

My query in php is not working.
When the boolean: $alles_goed=true; then it should run the query. But it
doesn't. In the php file everything is just working great but when i try
to test it in mysql, it doesn't show anything.
This is my code:
$mysqli = new mysqli("localhost", "root", "usbw", "accounts");
$resultaat='';
$username='';
$password='';
$email='';
$age='';
$alles_goed=false;
if (isset($_POST['username'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$age = $_POST['age'];
$alles_goed=true;
echo'<div class="error">';
if (substr_count($email, '@')<1){
echo'Geen geldig emailadress<br>';
$alles_goed=false;
}
if ($username==''){
echo 'Geen naam ingevuld</br>';
$alles_goed=false;
}
if ($password==''){
echo 'Geen tekst ingevuld</br>';
$alles_goed=false;
}
echo '</div> ';
if ($alles_goed==true){
$veld1 = $mysqli->real_escape_string($username);
$veld2 = $mysqli->real_escape_string($password);
$veld3 = $mysqli->real_escape_string($email);
$resultaat = $mysqli->query("INSERT INTO account_information
(username, password, email) VALUES ('" . $veld1 . "','" . $veld2 . "',
'".$veld3 ."')");
var_dump($resultaat);
}
At this part of the code, it shows:"We have sent an verification link to
your email".So $resultaat is not the problem?
if ($resultaat == false)
{
echo "Query mislukt. Foutmelding: " . $mysqli->error;
}
else
{
var_dump($mysqli->insert_id);
echo"We have sent an verification link to your email";
}
I also use checks to check if I connect to the database and it doesn't
give and error.:
if($mysqli->connect_error>0){// I am not sure if we need this, but too
scared to delete.
echo 'ERROR' . $mysqli->connect_error;
}
if ($mysqli->connect_errno >0) {// I am not sure if we need this, but
too scared to delete.
echo "er is iets fout";
}
if (mysqli_connect_errno())
{
printf("Er kan geen verbinding worden gemaakt met de database.
Foutmelding: %s\n", mysqli_connect_error());
}
Thank you for your time.

No comments:

Post a Comment