-1

I am trying to make a registration page for my website but when I run it; it gives error. What am I doing wrong?

<?php
//Form values

$name_value=$_POST['Name_input'];

$Username_value=$_POST['Username_input'];

$DOB_value=$_POST['DOB_input'];

$Password_value=$_POST['Password_input'];

$Phone_number_value=$_POST['Phone_number_input'];

$Python_checkbox_value=$_POST['Python_checkbox'];

$Java_checkbox_value=$_POST['Java_checkbox'];

$C_sharp_checkbox_value=$_POST['C#_checkbox'];

$HTML_checkbox_value=$_POST['HTML_checkbox'];

$Cpp_checkbox_value=$_POST['C++_checkbox'];

$R_checkbox_value=$_POST['R_checkbox'];

$swift_checkbox_value=$_POST['swift_checkbox'];

$kotlin_checkbox_value=$_POST['kotlin_checkbox'];

$JS_checkbox_value=$_POST['JS_checkbox'];
IMSoP
  • 89,526
  • 13
  • 117
  • 169
  • Please remove the image and add a text-based [mcve] – evolutionxbox Jul 01 '22 at 15:31
  • 1
    What is the error you are seeing? – IMSoP Jul 01 '22 at 15:35
  • Warning: Undefined array key "Python_checkbox" in C:\xampp\htdocs\The project Progmeet\Landing Page\membership-selection.Php on line 14 – Cihan Toker Jul 01 '22 at 15:36
  • System gives this error for every variable – Cihan Toker Jul 01 '22 at 15:37
  • please send more of your code, have you assigned names to your checkbox ? Undefined array key definly means php cant find the variable for some reasons or you dont defined it. – hugomztl Jul 01 '22 at 15:37
  • I inserted HTML code as an answer.There is no more Php code that I wrote. – Cihan Toker Jul 01 '22 at 15:41
  • 2
    Don't post code as an answer, edit the question, https://stackoverflow.com/posts/72831537/edit. – user3783243 Jul 01 '22 at 15:43
  • System doesn't allow me to do it.It says "Your question is mostly code" – Cihan Toker Jul 01 '22 at 15:44
  • I didnt even noticed, you try to access empty checkboxes. Try add `if(isset($_POST["name_of_checkbox"]))` condition before getting their value. Note that you have to submit your form before trying access the values. – hugomztl Jul 01 '22 at 15:50
  • I think it's already solved, here is an answer [Checkbox php](https://stackoverflow.com/questions/18421988/getting-checkbox-values-on-submit), pay attention to the HTML name attribute and to the method (get or post) – Ayoub Mabrouk Jul 01 '22 at 15:57

1 Answers1

1

Take a look at this code :


    <form method="GET">
        <input type="checkbox" value="value" name="name">checkbox label</input>
        <input type="submit">
    </form>

    <?php 

    if (isset($_GET["name"]))
    {
        echo $_GET["name"];
    }

    ?>

As you can see when I submit the form without checking, the parameter in URI is empty because the checkbox isn't defined (I used GET method)

enter image description here

enter image description here

But when I check it, you can see the parameter is name=value

enter image description here

enter image description here

hugomztl
  • 88
  • 11