-1

I am trying to create an event registration form for my event (my first time using PHP), but am having trouble with the input text for my HTML/PHP form. I can submit the form and it sends me an email with the names of the inputs, but not the actual entered text/information.

Here is my HTML code:

<div class="WMF-form">
          <form method="post" action="myform.php"> 

                  Name: <input type="text" name="name">
                  E-mail: <input type="text" name="email">
                  Family Count: <textarea name="familycount" rows="5" cols="40"></textarea>
                  Family Names:: <textarea name="familynames" rows="5" cols="40"></textarea>
                  Volunteer:
                  <input type="radio" name="volunteer" value="female">Female
                  <input type="radio" name="volunteer" value="male">Male
                  <input type="radio" name="volunteer" value="other">Other
                  Fee Options:
                  <input type="radio" name="feeoptions" value="female">Female
                  <input type="radio" name="feeoptions" value="male">Male
                  <input type="radio" name="feeoptions" value="other">Other
                  Lodging:
                  <input type="radio" name="lodging" value="female">Female
                  <input type="radio" name="lodging" value="male">Male
                  <input type="radio" name="lodging" value="other">Other

                  <br>

<input type="submit" name="submit" value="Submit"> 



</form>
</div>
</section>

Here is my PHP code: PHP code

PHP code

Sarah A.
  • 1
  • 1

2 Answers2

3

PHP $_POST values are case sensitive. Your HTML has

<input type="text" name="name">

But you access it in the PHP file as

$Name = $_POST["Name"];

Make sure the cases match.

Try

$Name = $_POST["name"];
mconkin
  • 121
  • 7
  • shouldn't this throw an undefined index notice? – No Name Aug 06 '18 at 20:11
  • 2
    @BojanSrbinoski It should. But when faced with "something doesn't work", most newcomers do not even look for / enable error_reporting. – mario Aug 06 '18 at 20:13
  • 1
    @mario Yes but I mean instead of sending the `name` attribute's value, shouldn't it just throw the notice and not do anything else? I ask because I tried to reproduce this error but instead of echoing the value of the `$_GET`, I just get the notice. – No Name Aug 06 '18 at 20:14
  • @BojanSrbinoski With PHP, an incorrect index error is not 'fatal' so the php script continues on. She is sending an email to a static variable email address... and then the fields from the form. However all the indexes are wrong, so the email is resulting in missing data. She is not seeing the notices/warnings, because she most likely does not have full error reporting on. – IncredibleHat Aug 06 '18 at 20:18
  • @Bojan Well, if the key is absent, an implied NULL value gets assigned (because scripting language). The Notice is really just a side-effect in such cases. It's not like an exception, that might stop program execution. – mario Aug 06 '18 at 20:18
  • @mario right but if NULL gets assigned, then how is she getting the name of the input? Shouldn't she get nothing or NULL? – No Name Aug 06 '18 at 20:23
  • @BojanSrbinoski she isn't getting those names, she hard-coded them into the $Body var ;) Would all be easier to read if she posted actual code in her question, instead of images. – IncredibleHat Aug 06 '18 at 20:25
  • 1
    @IncredibleHat OOOH thanks for clearing that up :) I was really confused – No Name Aug 06 '18 at 20:26
0

Capitalize your names in your form. the post variables have a capital Name Email FamilyNames etc and the form doesnt

Joe Alvini
  • 306
  • 1
  • 3
  • 15