Checked Checkbox Not Working? - php

I have an HTML form that posts to a PHP script. Everything is working except the checkbox. When it is checked, the value is not being posted.
HTML:
<input name="test" id="checkbox-02" type="checkbox" value="1" />
PHP:
if(!isset($_POST['test'])) {
$eventRepeat="No";
}
if(isset($_POST['test'])) {
$eventRepeat="Yes";
}
When this code runs, $eventRepeat always comes out as "No." I tried using the command "print_r($_POST)" and all inputs are posted except the checkbox, even when it is checked.
Any ideas what could cause this? I do have jQuery running so when it is checked two divs appear. Could that somehow be interfering? Here's the jQuery:
$(document).ready(function () {
$('#checkbox-02').change(function () {
if (!this.checked)
// ^
$('#repeatUntilDIV').fadeIn('slow');
$('#repeatFrequencyDIV').fadeIn('slow');
});
});
For reference, here is the full code:
<form class="cmxform form-horizontal tasi-form" id="commentForm" role="form" action="" method="post">
<div class="form-group">
<label for="inputEventTitle" class="col-lg-2 control-label">Event Title</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputEventTitle" name="inputEventTitle" placeholder="Event Title" required>
</div>
</div>
<div class="form-group">
<label for="inputEventDescription" class="col-lg-2 control-label">Description</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputEventTitle" name="inputEventDescription" placeholder="Event Description" required>
</div>
</div>
<div class="form-group">
<label for="inputEventStartTime" class="col-lg-2 control-label">Start Time</label>
<div class="col-lg-10">
<select name="inputEventStartTime" class="form-control" id="dp1" required>
<option label="Start Time">
<option value="12:00AM">12:00AM</option>
<option value="12:15AM">12:15AM</option>
<option value="12:30AM">12:30AM</option>
<option value="12:45AM">12:45AM</option>
<option value="1:00AM">1:00AM</option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputEventEndTime" class="col-lg-2 control-label">End Time</label>
<div class="col-lg-10">
<select name="inputEventEndTime" class="form-control" id="dp1" required>
<option label="End Time">
<option value="1:00AM">1:00AM</option>
<option value="1:15AM">1:15AM</option>
<option value="1:30AM">1:30AM</option>
<option value="1:45AM">1:45AM</option>
<option value="2:00AM">2:00AM</option>
</select> </div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">Date</label>
<div class="col-sm-6">
<input id="dp1" name="inputEventDate" type="text" size="16" class="form-control" required>
</div>
</div>
<div class="form-group">
<label for="inputEventDate" class="col-lg-2 control-label">Repeat?</label>
<div class="col-lg-10 checkboxes">
<label class="label_check" for="checkbox-02"> </label>
<input name="test" id="checkbox-02" type="checkbox" value="1" /> Yes, I want to repeat this event.
</div>
</div>
<div class="form-group" id="repeatUntilDIV" style="display:none;">
<label for="inputEventEndDate" class="col-lg-2 control-label">Repeat Until</label>
<div class="col-lg-10">
<input name="inputEventEndDate" id="eventEndDate" type="text" placeholder="End Date" class="form-control">
</div>
</div>
<div class="form-group" id="repeatFrequencyDIV" style="display:none;">
<label for="inputEventFrequency" class="col-lg-2 control-label">Repeat Every</label>
<div class="col-lg-10">
<select name="inputEventFrequency" class="form-control" id="dp1">
<option label="Repeat Every">
<option value="1">Repeat Every Day</option>
<option value="2">Repeat Every Other Day</option>
<option value="7">Repeat Every Week</option>
<option value="14">Repeat Every Other Week</option>
<option value="30">Repeat Every Month</option>
</select>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Cancel</button>
<input type="submit" name="addPrimaryEvent" class="btn btn-success" value="Submit" />
</form>
I get this from var_dump($_POST):
array(8) {
["inputEventTitle"]=>
string(5) "Title"
["inputEventDescription"]=>
string(11) "Description"
["inputEventStartTime"]=>
string(6) "2:00AM"
["inputEventEndTime"]=>
string(6) "3:00AM"
["inputEventDate"]=>
string(10) "05-26-2014"
["inputEventEndDate"]=>
string(10) "05-29-2014"
["inputEventFrequency"]=>
string(1) "1"
["addPrimaryEvent"]=>
string(6) "Submit"
}

Very unclear why this would not work. But I noticed inconsistencies & imbalance in the HTML tags as well as an empty action="" which is not HTML5 valid. For more details, see this great answer over here.
So I have set it to #. You might want to actually change that to the full filename or path to the PHP script such as action="form.php". Or you could leave it out altogether like this:
<form class="cmxform form-horizontal tasi-form" id="commentForm" role="form" action="#" method="post">
But I prefer to be explicit & recommend the action="form.php" way of handling things. Here is your cleaned up HTML form:
<form class="cmxform form-horizontal tasi-form" id="commentForm" role="form" action="#" method="post">
<div class="form-group">
<label for="inputEventTitle" class="col-lg-2 control-label">Event Title</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputEventTitle" name="inputEventTitle" placeholder="Event Title" required="" />
</div>
</div>
<div class="form-group">
<label for="inputEventDescription" class="col-lg-2 control-label">Description</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputEventTitle" name="inputEventDescription" placeholder="Event Description" required="" />
</div>
</div>
<div class="form-group">
<label for="inputEventStartTime" class="col-lg-2 control-label">Start Time</label>
<div class="col-lg-10">
<select name="inputEventStartTime" class="form-control" id="dp1" required="">
<option value="12:00AM">
12:00AM
</option>
<option value="12:15AM">
12:15AM
</option>
<option value="12:30AM">
12:30AM
</option>
<option value="12:45AM">
12:45AM
</option>
<option value="1:00AM">
1:00AM
</option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputEventEndTime" class="col-lg-2 control-label">End Time</label>
<div class="col-lg-10">
<select name="inputEventEndTime" class="form-control" id="dp1" required="">
<option value="1:00AM">
1:00AM
</option>
<option value="1:15AM">
1:15AM
</option>
<option value="1:30AM">
1:30AM
</option>
<option value="1:45AM">
1:45AM
</option>
<option value="2:00AM">
2:00AM
</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">Date</label>
<div class="col-sm-6">
<input id="dp1" name="inputEventDate" type="text" size="16" class="form-control" required="" />
</div>
</div>
<div class="form-group">
<label for="inputEventDate" class="col-lg-2 control-label">Repeat?</label>
<div class="col-lg-10 checkboxes">
<input name="test" id="checkbox-02" type="checkbox" value="1" /> Yes, I want to repeat this event.
</div>
</div>
<div class="form-group" id="repeatUntilDIV" style="display:none;">
<label for="inputEventEndDate" class="col-lg-2 control-label">Repeat Until</label>
<div class="col-lg-10">
<input name="inputEventEndDate" id="eventEndDate" type="text" placeholder="End Date" class="form-control" />
</div>
</div>
<div class="form-group" id="repeatFrequencyDIV" style="display:none;">
<label for="inputEventFrequency" class="col-lg-2 control-label">Repeat Every</label>
<div class="col-lg-10">
<select name="inputEventFrequency" class="form-control" id="dp1">
<option value="1">
Repeat Every Day
</option>
<option value="2">
Repeat Every Other Day
</option>
<option value="7">
Repeat Every Week
</option>
<option value="14">
Repeat Every Other Week
</option>
<option value="30">
Repeat Every Month
</option>
</select>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Cancel</button> <input type="submit" name="addPrimaryEvent" class="btn btn-success" value="Submit" />
</div>
</form>

Related

Form validates HTML controls but doesn't submit in CodeIgniter 4

I have developed a website in CodeIgniter 4 framework. One particular page has a form that doesn't submit but validates HTML input controls that have required attributes. I have tried everything but could not find the exact bug. Following is the live URL of that page:
https://spcollegedumka.ac.in/index.php/feedback/send
<form method="post" id="feedbackForm">
<div class="mb-2">
<label class="form-label">Who you are?</label>
<select name="category" class="form-control form-control-sm" required="">
<option value="" selected="" disabled="">---- Select ----</option>
<option value="Student">Student</option>
<option value="Parent">Parent</option>
<option value="Guest">Guest</option>
</select>
</div>
<div class="mb-2">
<label class="form-label">Your Name</label>
<input type="text" name="name" class="form-control form-control-sm" required="">
</div>
<div class="mb-2">
<label class="form-label">Roll No. (students only)</label>
<input type="text" name="roll" class="form-control form-control-sm">
</div>
<div class="mb-2">
<label class="form-label">Select Faculty</label>
<select name="faculty" class="form-control form-control-sm" required="">
<option value="" selected="" disabled="">---- Select ----</option>
<option value="1">Faculty of Humanities</option>
<option value="2">Faculty of Social Science</option>
<option value="3">Faculty of Commerce</option>
<option value="4">Faculty of Science</option>
<option value="100">Not Applicable (For Parent/Guest)</option>
</select>
</div>
<div class="row">
<div class="col-md-6">
<div class="mb-2">
<label class="form-label">Mobile No.</label>
<input type="text" name="mobile" class="form-control form-control-sm" required="">
</div>
</div>
<div class="col-md-6">
<div class="mb-4">
<label class="form-label">Email Address</label>
<input type="email" name="email" class="form-control form-control-sm" required="">
</div>
</div>
</div>
<button type="submit" value="submit" class="btn btn-sm">SUBMIT & GO NEXT</button>
</form>
i dont know wht u mean, but try to read attribut required
required="true"
or
required
https://www.w3schools.com/tags/att_input_required.asp

Bootstrap 3: How to properly use a form-groups (a form) inside a grid?

For a university assessment I have been tasked with creating a very simple website with the concept of a 'Facebook Lite' that uses basic PHP and SQL functionality.
I am very new to bootstrap and have been attempting to correctly align a form within my register page. I can't quite figure out the correct way to place a form within a 3-6-3 bootstrap grid, the webpage just keeps presenting the form incorrectly to how I would like it.
The page I am working with is a php file (register.php) and so far I have worked out how to successfully create a working bootstrap horizontal form that will collapse to vertical when the window is sized down etc.
However I can't quite get it centered, the form keeps presenting to the right of the viewport, and the input boxes look horrible on a mobile device.
As explained I am extremely new to bootstrap so please forgive me if I am going about this the completely wrong way.
For your convenience I have prepared 2 pages;
Page 1 (register.php) -
What I believe to be the correct way to make a simple bootstrap form, however it is not centered and the input boxes go TINY on a mobile device (I just followed the bootstrap website instructions)
http://titan.csit.rmit.edu.au/~s3605062/register.php
Page 2 (register2.php)
My attempt to place my newly created form INSIDE a bootstrap grid of 3-6-3 (to supposedly center the form). I used the example demo from W3Schools so I could try and understand how it works, but as you can see its not working properly...
http://titan.csit.rmit.edu.au/~s3605062/register2.php
Code of register.php:
<div class="container">
<form class="form-horizontal" method="post" action="/register_new.php">
<div class="form-group">
<label class="control-label col-sm-2" for="email">Email:</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="email" placeholder="e.g. jsmith#example.com" name="email">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="pwd">Password:</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="pwd" placeholder="Create a password" name="pwd">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="fullname">Full Name:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="fullname" placeholder="e.g. John Smith" name="fullname">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="screenname">Screen Name:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="screenname" placeholder="e.g. John S" name="screenname">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="dateofbirth">Date of Birth:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="dateofbirth" placeholder="MM/DD/YYYY" name="dateofbirth"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="gender">Gender:</label>
<div class="col-sm-10">
<select class="form-control" id="gender" name="gender">
<option value="" selected disabled>Please select...</option>
<option value="male">Male</option>
<option value="female">Female</option>
<option value="nonbinary">Non-Binary</option>
<option value="notsharing">Prefer not to answer</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="gender">Status:</label>
<div class="col-sm-10">
<select class="form-control" id="status" name="status">
<option value="" selected disabled>Please select...</option>
<option value="single">Single</option>
<option value="relationship">In a relationship</option>
<option value="complicated">Its complicated</option>
<option value="partnership">In a domestic partnership</option>
<option value="married">Married</option>
<option value="widowed">Widowed</option>
<option value="notsharing">Prefer not to answer</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="location">Location:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="location" placeholder="e.g. Melbourne, Australia" name="location">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="registerbtn" class="btn btn-default">Sign Up</button>
</div>
</div>
</form>
</div>
Code of register2.php:
<div class="container">
<div class="row">
<div class="col-sm-3" style="background-color:lavender;">.col-sm-3</div>
<div class="col-sm-6" style="background-color:lavenderblush;">
<form class="form-horizontal" method="post" action="/register_new.php">
<div class="form-group">
<label class="control-label col-sm-3" for="email">Email:</label>
<div class="col-sm-3">
<input type="email" class="form-control" id="email" placeholder="e.g. jsmith#example.com" name="email">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-6" for="pwd">Password:</label>
<div class="col-sm-6">
<input type="password" class="form-control" id="pwd" placeholder="Create a password" name="pwd">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-6" for="fullname">Full Name:</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="fullname" placeholder="e.g. John Smith" name="fullname">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-6" for="screenname">Screen Name:</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="screenname" placeholder="e.g. John S" name="screenname">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-6" for="dateofbirth">Date of Birth:</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="dateofbirth" placeholder="MM/DD/YYYY" name="dateofbirth"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-6" for="gender">Gender:</label>
<div class="col-sm-6">
<select class="form-control" id="gender" name="gender">
<option value="" selected disabled>Please select...</option>
<option value="male">Male</option>
<option value="female">Female</option>
<option value="nonbinary">Non-Binary</option>
<option value="notsharing">Prefer not to answer</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-6" for="gender">Status:</label>
<div class="col-sm-6">
<select class="form-control" id="status" name="status">
<option value="" selected disabled>Please select...</option>
<option value="single">Single</option>
<option value="relationship">In a relationship</option>
<option value="complicated">Its complicated</option>
<option value="partnership">In a domestic partnership</option>
<option value="married">Married</option>
<option value="widowed">Widowed</option>
<option value="notsharing">Prefer not to answer</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-6" for="location">Location:</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="location" placeholder="e.g. Melbourne, Australia" name="location">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-6 col-sm-6">
<button type="registerbtn" class="btn btn-default">Sign Up</button>
</div>
</div>
</form>
</div>
<div class="col-sm-3" style="background-color:lavender;">.col-sm-3</div>
</div>
</div>
As an end result I would like it to have the form centered like on register2.php, but with the form labels and inputs presenting properly (similar to how they are on register.php). I am not even sure if a bootstrap grid is the correct way to do this!
Any help is extremely appreciated thank you and I do apologise for the lengthy post I just wanted to explain myself clearly.
Thank you.
Ricky
This will be the first code:
Try to always declare row with column inside container. d-flex and justify-content-center will help to centralized the form. It's bootstrap default class.
<div class="container">
<div class="row d-flex justify-content-center">
<div class="col-md-9">
<form class="form-horizontal" method="post" action="/register_new.php">
<div class="form-group">
<label class="control-label col-sm-2" for="email">Email:</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="email" placeholder="e.g. jsmith#example.com" name="email">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="pwd">Password:</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="pwd" placeholder="Create a password" name="pwd">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="fullname">Full Name:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="fullname" placeholder="e.g. John Smith" name="fullname">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="screenname">Screen Name:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="screenname" placeholder="e.g. John S" name="screenname">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="dateofbirth">Date of Birth:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="dateofbirth" placeholder="MM/DD/YYYY" name="dateofbirth"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="gender">Gender:</label>
<div class="col-sm-10">
<select class="form-control" id="gender" name="gender">
<option value="" selected disabled>Please select...</option>
<option value="male">Male</option>
<option value="female">Female</option>
<option value="nonbinary">Non-Binary</option>
<option value="notsharing">Prefer not to answer</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="gender">Status:</label>
<div class="col-sm-10">
<select class="form-control" id="status" name="status">
<option value="" selected disabled>Please select...</option>
<option value="single">Single</option>
<option value="relationship">In a relationship</option>
<option value="complicated">Its complicated</option>
<option value="partnership">In a domestic partnership</option>
<option value="married">Married</option>
<option value="widowed">Widowed</option>
<option value="notsharing">Prefer not to answer</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="location">Location:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="location" placeholder="e.g. Melbourne, Australia" name="location">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="registerbtn" class="btn btn-default">Sign Up</button>
</div>
</div>
</form>
</div>
</div>
</div>
For the second form default.css, you are using padding for form, that's why you got a blank space in left side.
form {
margin-top: 10px;
padding-left: 370px;
}
Thanks.

how to use different forms in one blade file in laravel 5.6

I am using laravel 5.6 and I am developing auto classifieds web application. in My app I have 3 different vehicle categories as car, van, truck and I have blade file to select this three different vehicle types. when I select this vehicles my urls show like this,
http://localhost:8000/post-ad/Truck/8 <- this is category id
http://localhost:8000/post-ad/van/7
http://localhost:8000/post-ad/Car/5
now when I clicked one of above vehicle category page redirect to show.blade.php file, so, now I need 3 different forms to submit data to each vehicles, this is my vehicles form, car form
<form method="post" action="{{url('form')}}" enctype="multipart/form-data">
{{csrf_field()}}
<input type="hidden" id="cid" name="cid" value="{{ $catagories->id }}" />
<div class="form-group">
<label for="exampleFormControlSelect1">District</label>
<select class="form-control" id="exampleFormControlSelect1" name="district">
</select>
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Town</label>
<select class="form-control" id="exampleFormControlSelect1" name="town">
</select>
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Brand</label>
<select class="form-control" id="exampleFormControlSelect1" name="brand">
</select>
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Model</label>
<select class="form-control" id="exampleFormControlSelect1" name="model">
</select>
</div>
</form>
van form
<form method="post" action="{{url('form')}}" enctype="multipart/form-data">
{{csrf_field()}}
<input type="hidden" id="cid" name="cid" value="{{ $catagories->id }}" />
<div class="form-group">
<label for="exampleFormControlSelect1">District</label>
<select class="form-control" id="exampleFormControlSelect1" name="district">
</select>
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Town</label>
<select class="form-control" id="exampleFormControlSelect1" name="town">
</select>
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Brand</label>
<select class="form-control" id="exampleFormControlSelect1" name="brand">
</select>
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Model</label>
<select class="form-control" id="exampleFormControlSelect1" name="model">
</select>
</div>
</form>
Truck Form
<form method="post" action="{{url('form')}}" enctype="multipart/form-data">
{{csrf_field()}}
<input type="hidden" id="cid" name="cid" value="{{ $catagories->id }}" />
<div class="form-group">
<label for="exampleFormControlSelect1">District</label>
<select class="form-control" id="exampleFormControlSelect1" name="district">
</select>
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Town</label>
<select class="form-control" id="exampleFormControlSelect1" name="town">
</select>
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Brand</label>
<select class="form-control" id="exampleFormControlSelect1" name="brand">
</select>
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Model</label>
<select class="form-control" id="exampleFormControlSelect1" name="model">
</select>
</div>
</form>
I need show each form when some user click each vehicle links on one blade file. how can I do this?
You may add name to your routes, for example:
Route::group(['prefix' => 'post-ad'], function () {
Route::get('Truck/{id}', 'TruckController#fetch')->name('track');
Route::get('Van/{id}', 'VanController#fetch')->name('van');
Route::get('Car/{id}', 'CarController#fetch')->name('car');
})
Put your form to another files like:
truck-form.blade.php
van-form.blade.php
car-form.blade.php
In your view:
#if(request()->route()->getName() = 'track')
#include('truck-form')
#elseif(request()->route()->getName() = 'van')
#include('van-form')
#elseif
#include('van-form')
#endif

even after submit of form my fields are not inserted into database using php

I am new to php. When form is submitted the data has to store on database. When I started to code it worked fine but later on data is not inserted into database I was trying to insert form details to database but unable to insert on regular basis. Sometimes,data is stored on database but most of the times, it doesn't store. so please help me....
php version:7
and MySQL database
form
<form role="form" class="register-form" method="post" action="aluminiregdb.php">
<center><h2>Alumni Registration</h2></center>
<hr class="colorgraph">
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-6">
<div class="form-group">
<input type="text" name="first_name" id="first_name" class="form-control input-lg" placeholder="First Name" tabindex="1">
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-6">
<div class="form-group">
<input type="text" name="last_name" id="last_name" class="form-control input-lg" placeholder="Last Name" tabindex="2">
</div>
</div>
</div>
<div class="form-group">
<input type="number" name="roll_number" id="roll_number" class="form-control input-lg" placeholder="Roll Number" tabindex="3">
</div>
<div class="form-group">
<input type="email" name="email" id="email" class="form-control input-lg" placeholder="Email Address" tabindex="4">
</div>
<div class="row">
<div class="col-xs-12 col-lg-12 col-sm-6 col-md-6 ">
<select class="form-group form-control input-lg" name="SelectInstitution">
<option value="select">Select Institution</option>
<option value="sdes">Sree Dattha institute of Engineering and science (SDES)</option>
<option value="sdgi">Sree Dattha group of istitutions Integrated Campus (SDGI)</option>
<option value="sdip">Sree Dattha institute of Pharmacy (SDIP)</option>
<option value="sdbn">Sree Dattha Brindavan institute of Teacher Education (SDBN)</option>
<option value="sdbd">Sree Dattha Brindavan institute of Diploma (SDBD)</option>
<option value="bits">Brindavan institute of Teacher Education (BITS)</option>
</select>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-lg-12 col-sm-6 col-md-6 ">
<select class="form-group form-control input-lg" name="SelectInstitutiondegree">
<option value="select">Select Degree Obtained</option>
<option value="B.Tech">B.Tech</option>
<option value="M.Tech">M.Tech</option>
<option value="MBA">MBA</option>
<option value="Polytechnic">Polytechnic</option>
<option value="B.Pharm">B.Pharm</option>
<option value="M.Pharm">M.Pharm</option>
<option value="Pharm.D">Pharm.D</option>
<option value="B.Ed">B.Ed</option>
</select>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-12">
<div class="form-group">
<input type="text" name="program" id="program" class="form-control input-lg" placeholder="Program : CSE or ECE or B.Pharm or M.Pharm or B.Ed etc..." tabindex="5">
</div>
</div>
</div>
<div class="form-group">
<input type="number" name="year" id="year" min="2000" class="form-control input-lg" placeholder="Completion Year Of Graduation" tabindex="6">
</div>
<div class="form-group">
<input type="date" name="dob" id="dob" class="form-control input-lg" placeholder=" Date of Birth : 1994-07-23" tabindex="7">
</div>
<div class="form-group">
<input type="number" name="mobile" id="mobile" class="form-control input-lg" placeholder="Mobile Number" tabindex="8">
</div>
<div class="form-group">
<textarea class="form-control form-control input-lg" name="adress" rows="6" data-rule="required" data-msg="Please write something for us" placeholder="Address"></textarea>
<div class="validation"></div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-12">
<div class="form-group input-lg">
<label for="Status">Current Status :&nbsp&nbsp</label>
<label class="radio-inline">
<input type="radio" name="optradio" value="Working" onclick="doClick(this)">Working
</label>
<label class="radio-inline">
<input type="radio" name="optradio" value="Self-Employed" onclick="doClick(this)">Self-Employed
</label>
<label class="radio-inline">
<input type="radio" name="optradio" value="Studying" onclick="doClick(this)">Studying
</label>
<label class="radio-inline">
<input type="radio" name="optradio" value="Home Maker" onclick="doClick(this)">Home Maker
</label>
</div>
</div>
</div>
<div class="row" id="textbox" style="display:none">
<div class="col-xs-12 col-sm-6 col-md-12">
<div class="form-group">
<input type="text" name="org_name" id="org_name" class="form-control input-lg" placeholder="Organization Name" tabindex="9">
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-12">
<div class="form-group">
<input type="text" name="designatin" id="designation" class="form-control input-lg" placeholder="Designation in your Company" tabindex="10">
</div>
</div>
</div>
<hr class="colorgraph">
<div class="row">
<div class="col-xs-12 col-md-12"><input align="center" name="alumniregs" type="submit" value="Submit" class="btn btn-theme btn-block btn-lg" tabindex="11"></div>
</div>
</form>
dbconnection
if(isset($_POST['alumniregs'])){
if(isset($_POST['first_name'])){
$fname=$_POST['first_name'];
}
if(isset($_POST['last_name'])){
$lname=$_POST['last_name'];
}
if(isset($_POST['roll_number'])){
$roll=$_POST['roll_number'];
}
if(isset($_POST['email'])){
$email=$_POST['email'];
}
if(isset($_POST['SelectInstitution'])){
$institu=$_POST['SelectInstitution'];
}
if(isset($_POST['SelectInstitutiondegree'])){
$insttidegree=$_POST['SelectInstitutiondegree'];
}
if(isset($_POST['program'])){
$program=$_POST['program'];
}
if(isset($_POST['year'])){
$year=$_POST['year'];
}
if(isset($_POST['dob'])){
$dob=$_POST['dob'];
}
if(isset($_POST['mobile'])){
$mobile=$_POST['mobile'];
}
if(isset($_POST['adress'])){
$adress=$_POST['adress'];
}
if(isset($_POST['optradio'])){
$optradio=$_POST['optradio'];
}
if(isset($_POST['org_name'])){
$orgname=$_POST['org_name'];
}
if(isset($_POST['designatin'])){
$designatin=$_POST['designatin'];
}
$date = date('Y-m-d H:i:s');
$smt=$db->prepare("INSERT INTO `naik`.`aluminireg` (`fname`, `lname`, `rollno`, `email`, `Institution`, `degree`, `branch`, `year`, `dob`, `mobile`, `adress`, `presentstatus`, `orgname`, `designatin`,`date`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,'$date')");
$smt->bind_param('ssssssssssssss',$fname,$lname,$roll,$email,$institu,$insttidegree,$program,$year,$dob,$mobile,$adress,$optradio,$orgname,$designatin);
$smt->execute();
$smt->close();
if ($smt) {
echo "<script>alert('Item Entered Successful')</script>";
}
}
?>
config
<?php
$dbconnection=array(
'server'=>'localhost',
'user'=>'root',
'password'=>'java',
'dbname'=>'naik'
);
$db=new mysqli(
$dbconnection['server'],
$dbconnection['user'],
$dbconnection['password'],
$dbconnection['dbname']
);
//if($db!="null"){
// echo "<script>alert('connection Successful')</script>";
//}
if($db->connect_errno>0){
echo "database connection error".$db->connect_error;
exit;
}
//echo $db->host_info;
#echo $db->connect_errno;
?>

Laravel testing unreachable field error when there is two forms in page

I want to test a page which has two forms in.
When I want to test one of my forms the following error occurs:
Unreachable field "count"
Which count is a field in that form (it doesn't exit in the other form). When i remove the other form completely, it works correctly but I need to have both in the page.
It's my view:
<section class="content">
<div class="row">
<div class="col-md-6">
<div class="panel panel-green">
<div class="panel-heading">
<h3 class="panel-title">
Passenger Credit Adjustment
</h3>
</div>
<div class="panel-body">
<form method="post" action="{{route('credits.passenger.post', ['id' => $passenger->id])}}">
{{csrf_field()}}
<div class="form-group">
<label for="amount">Name</label>
<input type="text" class="form-control" id="name" name="name" disabled="disabled"
title="" value="{{$passenger->fullname}}">
</div>
<div class="form-group">
<label for="amount">Credit</label>
<input type="text" class="form-control" id="cashable" name="name" title=""
disabled="disabled" value="{{number_format($credit) . ' RLS'}}">
</div>
<div class="form-group">
<label for="amount">Add/DeductAmount</label>
<input type="text" class="form-control" id="amount" name="amount">
</div>
<div class="form-group">
<label for="description">Description</label>
<input type="text" class="form-control" id="description" name="description">
</div>
<button type="submit" class="btn btn-danger">Apply</button>
</form>
</div>
<div class="panel-heading">
<h3 class="panel-title">
<i class="livicon" data-name="money" data-loop="true" data-color="#fff"
data-hovercolor="#fff" data-size="18"></i>
Voucher
</h3>
</div>
<div class="panel-body">
<form method="post"
action="{{route('credits.rideVoucher.post', ['id' => $passenger->id])}}">
{{csrf_field()}}
<div class="form-group">
<label for="type">Type</label>
<select id="single-prepend-text" class="form-control select2" title=""
name="type">
<option value="5k">5k</option>
<option value="10k">10k</option>
<option value="20k">20k</option>
<option value="15p">15%</option>
<option value="20p">20%</option>
<option value="25p">25%</option>
<option value="30p">30%</option>
<option value="50p">50% (Max 10k)</option>
<option value="100p">100% (Max 20k)</option>
</select>
</div>
<button type="submit" class="btn btn-danger" name="generate">Generate</button>
</form>
</div>
</div>
</div>
<div class="col-md-6">
<div class="panel panel-green">
<div class="panel-heading">
<h3 class="panel-title">
Free Ride
</h3>
</div>
<div class="panel-body">
<form method="post"
action="{{route('credits.passenger.freeRide.post', ['id' => $passenger->id])}}">
{{csrf_field()}}
<div class="form-group">
<label>Number of free ride(s):</label>
<input type="number" name="count" value="1" title="Count" id="count"
class="form-control">
</div>
<div class="form-group">
<label>Cap:</label>
<select class="form-control" name="cap" title="">
<option value="">[NOT SELECTED]</option>
<option value="50000">5,000 T</option>
<option value="100000">10,000 T</option>
<option value="150000">15,000 T</option>
<option value="200000">20,000 T</option>
</select>
</div>
<input type="submit" class="btn btn-danger" name="generate" value="Generate">
</form>
</div>
</div>
</div>
</div>
It's my test:
$this->visit($uri)
->type(3, 'count')
->select($cap, 'cap')
->press('Generate')
I'm using Laravel 5.1.
Both submit buttons have the same name. Try using different names. Also, instead of using press, you can use the submitForm method

Categories