//Here i have mentioned one form and gave action in that.I also gave a button submit.Now when I click on the submit button, It the action given in the form is not perfoming.
<form action="submit.php" method="POST">
<tbody>
<tr id='addr0' data-id="0" class="hidden">
<td data-name="loannum">
<input type="number" class="form-control" required>
</td>
<td data-name="name">
<input id="startdate" name="startdate" min="2016-01-01" max="2020-01-01" type="date" class="form-control">
</td>
<td data-name="name">
<input type="text" name='gname' placeholder='Group Name' class="form-control" pattern="([A-z\s]){2,}" required/>
</td>
<td data-name="desc">
<input type="number" placeholder='Batch Number' class="form-control" pattern="[0-9]{9}" required>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<a id="add_row" class="btn btn-primary" style="background:#84ca71;color:#F44336;padding-bottom:24px;">Add Group</a>
//here we mentioned a button and when we click on it the action given in form should be performed
<button class="btn btn-default" type="submit" style="background:#cddc39;color:#F44336;padding:5px 30px 25px 20px;">submit</button>
</form>

- 2,137
- 2
- 17
- 31

- 1
- 2
-
where is your button ? – Manthan Dave Nov 04 '16 at 06:54
-
u forgot to add button and `` – devpro Nov 04 '16 at 06:55
-
offo I forgot to link that code. so here is the button code. Add Group – Bhargavi K Nov 04 '16 at 06:59
-
ok it means, u are using also, add this in your quesion. and add `print_r($_POST)` in `submit.php` – devpro Nov 04 '16 at 07:01
-
If after you make changes which are in answers below and form still doesn't submit you data you can share your php part with us – S.I. Nov 04 '16 at 07:01
-
`submit.php` is different file? or same file – devpro Nov 04 '16 at 07:04
-
It is different file – Bhargavi K Nov 04 '16 at 07:15
-
different file and same root? if yes, than use `print_r($_POST)` in submit.php – devpro Nov 04 '16 at 07:16
-
I added it but its not working – Bhargavi K Nov 04 '16 at 07:18
2 Answers
If you are really using the button at bottom I also gave a button submit
and you also need to add </form>
closing form tag.
also note that, this input will return nothing:
<input type="number" class="form-control" required>
Because you are not using name attribute here.
You also need to add name attribute for Batch Number
field.
<input type="number" placeholder='Batch Number' class="form-control" pattern="[0-9]{9}" required>
Update:
As per your comments, you are using button and closing form tag, it means, this is pure PHP issue not related to form action.
What you need here:
You must need to check either
submit.php
available on same root or not, or if you have only one file than leave it blank<form action="">
In submit.php file you also need to check the post values like
print_r($_POST)
check what are you getting and add missing name attributes.Most important part is that, don't know are you using
isset()
or not, how can you check either submit button isset or not with this input:<button class="btn btn-default" type="submit" style="background:#cddc39;color:#F44336;padding:5px 30px 25px 20px;">

- 16,184
- 3
- 27
- 38
-
Even if I add a name attribute and mentioned print_r($_POST) in submit.php but I am not getting the output – Bhargavi K Nov 04 '16 at 07:16
-
-
I gave only this because I just need to redirect the page when i click on submit. – Bhargavi K Nov 04 '16 at 07:19
-
-
Yes because I just want to check whether my button is working or not – Bhargavi K Nov 04 '16 at 07:22
-
for the debugging, `action="submit.php"` remove submit.php from here, leave it empty, and add `print_r($_POST)` at top in same file. – devpro Nov 04 '16 at 07:22
-
-
yes but it nots working.It is showing the output for print_r($_POST) as array() – Bhargavi K Nov 04 '16 at 07:32
below is the code that is working fine. form.html
<!DOCTYPE html>
<html>
<head>
<title>Popup Timepicker Demo Using AngularJS, Bootstrap</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<meta name="description"
content="Popup Timepicker Demo Using AngularJS, Bootstrap.">
</head>
<body>
<form action="submit.php" method="POST">
<tbody>
<tr id='addr0' data-id="0" class="hidden">
<td data-name="loannum">
<input type="number" name="name1" class="form-control" required>
</td>
<td data-name="name">
<input id="startdate" name="startdate" min="2016-01-01" max="2020-01-01" type="date" class="form-control">
</td>
<td data-name="name">
<input type="text" name='gname' placeholder='Group Name' class="form-control" pattern="([A-z\s]){2,}" required/>
</td>
<td data-name="desc">
<input type="number" name="name2" placeholder='Batch Number' class="form-control" pattern="[0-9]{9}" required>
</td>
</tr>
</tbody>
</table>
</div> </div> <a id="add_row" class="btn btn-primary" style="background:#84ca71;color:#F44336;padding-bottom:24px;">Add Group</a> <button class="btn btn-default" type="submit" style="background:#cddc39;color:#F44336;padding:5px 30px 25px 20px;">submit</button> </form>
</body>
</html>
below is the submit.php code which is in the same folder of form.html.
print_r($_POST);

- 195
- 1
- 3
- 11
-
-
-
-
-
above code working fine in my pc perhaps it is php issues for posting data.please try method="get" and in php side and check it is working or not – sunil Nov 04 '16 at 09:30
-
-
http://stackoverflow.com/questions/28127142/html-form-just-wont-send-some-post-variables-to-a-php-script – sunil Nov 04 '16 at 09:38