Wow, so this is embarrassing. This is just supposed to be another boring web form. I have done plenty before, but for some reason this specific one doesn't want to cooperate. Am I somehow missing something? I have been trying to figure this out for hours. I swear I have tried troubleshooting everything, without any luck.
Basically, I am attempting to send via $_POST to a PHP file. Eventually I will use AJAX, but right now I can't even get the stupid thing to POST. So when you click submit, it goes to the correct page. But i get an error "Undefined Index (then points to the line that I call my $_POST variable). I have commented out everything on the PHP side (signup1.php) so that now all it does is var_dump($_POST);
so I can see the data and it isnt getting anything from _POST, the stupid thing is empty. I really think the problem is on the HTML side. I will post my code exactly. It has a ton of extra divs for styling and layout purposes. I am going to keep all of that in there just in case that is the cause of the error, maybe one of you will know. Also, you may notice I am using bootstrap. Maybe that is something? I have used bootstrap for forms before and its worked, but who knows.
<form action="actions/signup1.php" method="post">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="name">Name:</label>
<input type="text" id="name" class="form-control" placeholder="John Smith">
</div>
</div> <!-- end of name input column -->
<div class="col-md-6">
<div class="form-group">
<label for="phone">Phone Number:</label>
<input type="text" id="phone" class="form-control" placeholder="801-321-9876">
</div>
</div> <!-- end of phone number input column -->
</div> <!-- end of first .row of inputs -->
<div class="row">
<div class="col-md-6 column-sm-12">
<div class="form-group">
<label for="email">Email Address:</label>
<input type="text" id="email" class="form-control" placeholder="[email protected]">
</div>
</div> <!-- end of email address input column -->
<div class="col-md-3 col-sm-6">
<div class="form-group">
<label for="city">City:</label>
<select id="city" class="form-control">
<option>Las Vegas</option>
<option>Salt Lake City</option>
<option>I'll Choose a Default Later...</option>
</select>
</div>
</div> <!-- end of city dropdown -->
<div class="col-md-3 col-sm-6">
<div class="form-group">
<label for="type-of-phone">Type of Phone:</label>
<select id="type-of-phone" class="form-control">
<option>iPhone</option>
<option>Android</option>
<option>Windows Phone</option>
<option>Blackberry</option>
<option>Other Cellphone</option>
<option>Landline</option>
</select>
</div>
</div> <!-- end of Smartphone Question Dropdown -->
</div> <!-- end of second .row of inputs -->
<div class="row">
<div class="col-md-12"><input type="submit" value="Submit"></div>
</div>
</form>
If anyone has any idea please let me know. I am pulling my hair out. I figured I would be up all night with problems having it querying the database, or messing with the AJAX to make it polished, but instead I can't even get past the form submitting the RAW data! Very frustrating. I hope someone out there can see the issue.
For the record this is my exactmessage after the form redirects to the signup1.php (yes it goes to the right page). On the PHP all i do is a Var_dump of the whole $_POST variable.
var_dump($_POST);
And it shows me this:
array(0) { }
You should be adding the name attribute to the form fields.
For example:
<input name="phone" type="text" id="phone" class="form-control" placeholder="801-321-9876">
Try adding the name attribute to each input tag and the select tag. That should do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With