Home Get HTML Form ID within PHP

# Get HTML Form ID within PHP

J.K. Harthoorn
1#
J.K. Harthoorn Published in 2017-09-14 08:56:52Z
 I would like to get the form ID with PHP. This is my HTML code. Each answer within a question, has an ID. 

Vraag 1: Wat is de juiste formule van Arbeid?

 So in PHP, I receive the values like this, to calculate the score: $q1=$_POST['question-1'];  But how can I reive the ID and make it so that if (*QUESTION-1-A* *IS FILLED IN*) { echo "You filled in A" }  How do I do this?
d3r1ck
2#
 PHP can only access the values passed using POST/GET so you can't access the input IDs or form IDs. You can however create a hidden element like: 
 Now when you post the form you can do: $questions = ["A","B","C","D"]; foreach($_POST['question-1'] as $index =>$response){ if($response!==''){ // then there is something in it. echo "You filled in Question ".$questions [\$index]; } }  Hope this helps.
 You can't. The id is only available client side. The value is designed for what you are trying to do. Use the value instead. You'll need to give different answers different values. Your current values do not make sense.