0

I'm trying to insert values into my MySQL database using PHP but it's not getting my POST values

PHP code:

<?php

    /*
    if (isset($_POST["voornaam"])){
      $voornaam = $_POST["voornaam"];
    } else {
        $voornaam= null;
    }
    */

    $voornaam = $_POST['voornaam'];
    $naam = $_POST['naam'];
    //$foto = $_POST['foto'];
    $geboortedatum = $_POST['geboortedatum'];
    $info = $_POST['info'];
    $telefoonnummer = $_POST['telefoonnummer'];
    $email = $_POST['email'];
    $wachtwoord = $_POST['wachtwoord'];
    //$adresID = $_POST['adresID'];



    if($voornaam == ''  || $naam == '' || $geboortedatum == '' || $telefoonnummer == ''  || $email == '' || $wachtwoord == ''){
        echo 'Gelieve de verplichte velden in te vullen.';
    }else{
        require_once('dbConnect.php');
        $sql = "SELECT * FROM Personen WHERE voornaam='$voornaam' AND naam='$naam' AND email='$email'";

        $check = mysqli_fetch_array(mysqli_query($con,$sql));

        if(isset($check)){
            echo 'Combinatie voornaam, naam en email bestaat al.';
        }else{              
            //foto + adresID terug toevoegen
            $sql = "INSERT INTO Personen (voornaam, naam, geboortedatum, telefoonnummer, email, wachtwoord, info) 
            VALUES('$voornaam','$naam', $geboortedatum','$telefoonnummer','$email','$wachtwoord', '$info')";
            if(mysqli_query($con,$sql)){
                echo 'Succes';
            }else{
                echo 'Registratie mislukt, er is iets fout gelopen!';
            }
        }
        mysqli_close($con);
    }

And I'm trying to send a request with the Advanced REST Client like so:

ARC screenshot

But I keep getting the following as an error

Undefined index: voornaam in <b>/mnt/studentenhomes/bram.nouwen/public_html/ios_php/registerPersoonPost.php</b> on line

And I have no idea why it's not getting/assigning the values, any ideas?

Bram-N
  • 426
  • 4
  • 15
  • try printing out all values to test the page: `print_r($_POST); die();` – Jerodev May 19 '16 at 14:59
  • Probably something to do with your content type – RiggsFolly May 19 '16 at 14:59
  • @RiggsFolly Cheers for the quick moderating. :) I don't really think this is a duplicate, though, although if it's kept closed I will respect that. There's nothing that answers his question in the referenced thread, and the issue appears to be with the post request - not the php script. The error message is the symptom here, not the problem really. – Joel Hinz May 19 '16 at 15:04
  • @JoelHinz I see your point, but the issue is most likely that whatever that tool is he is using, he is using it wrong and it is not POSTing the values to his script at all. So the answer would really be _read the docs on whatever that tool is you are using_ Which is kinda off topic. But I wont get upset if someone reopens it. – RiggsFolly May 19 '16 at 15:12
  • @RiggsFolly Yeah, good point. The question should probably remain closed, although perhaps for a different reason than the current one. I think I'll retract my reopen vote. – Joel Hinz May 19 '16 at 15:17

0 Answers0