send email selecting checkbox html - php

I trying my cients select what services they want on email. I recevied the email but services are empty, mybe my php file is wrong. Thank you in advance
<h3>Tell us your inquiries</h3>
<hr>
<form id="contact-form" action="mailto:info#dosaladesign.com" method="post" onsubmit="return checkform(this);">
<div class="form-group">
<label for="firstname">First Name <span class="form-required" title="This field is required.">*</span></label>
<input type="text" name="firstname" class="form-control half" id="firstname" required>
</div>
<div class="form-group">
<label for="lastname">Last Name <span class="form-required" title="This field is required.">*</span></label>
<input type="text" name="lastname" class="form-control half" id="lastname" required>
</div>
<div class="form-group">
<label for="email">E-mail <span class="form-required" title="This field is required.">*</span></label>
<input type="email" name="email" class="form-control half" id="email" required>
</div>
<div class="form-group">
<label for="subject">Zip Code <span class="form-required" title="This field is required.">*</span></label>
<input type="text" name="zipcode" class="form-control half" id="zipcode" required>
</div>
<div class="form-group" >
<label for="email">Select Services</label>
<div class="row1">
<div class="col1"><input id="chk1" type="checkbox"><label>As-Built</label></div>
<div class="col1"><input id="chk2" type="checkbox" onclick="myFunction('New Construction Design','chk2')"/><label>New Construction Design</label></div>
<div class="col1"><input id="chk3" type="checkbox" onclick="myFunction('Residential Remodels','chk3')"/><label>Residential Remodels</label></div>
<div class="col1"><input id="chk4" type="checkbox" onclick="myFunction('Residential Additions','chk4')"/><label>Residential Additions</label></div>
<div class="col1"><input id="chk5" type="checkbox" onclick="myFunction('3D Modeling and Renderings','chk5')"/><label>3D Modeling and Renderings</label></div>
<div class="col1"><input id="chk6" type="checkbox" onclick="myFunction('Interior Design','chk6')"/><label>Interior Design</label></div>
<div class="col1"><input id="chk7" type="checkbox" onclick="myFunction('Space Planning and Furniture Layouts','chk7')"/><label>Space Planning and Furniture Layouts</label></div>
<div class="col1"><input id="chk8" type="checkbox" onclick="myFunction('Custom Furniture Design','chk8')"/><label>Custom Furniture Design</label></div>
<div class="col1"><input id="chk9" type="checkbox" onclick="myFunction('Landscape Design','chk9')"/><label>Landscape Design</label></div>
</div>
</div>
<div class="form-group">
<label for="message">Message <span class="form-required" title="This field is required.">*</span></label>
<textarea name="message" class="form-control" rows="4" id="message" required></textarea>

Ensure that your input elements contain a name attribute and value. According to the specs: If no name is specified, or name is empty, the input's value is not submitted with the form.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#name

Related

I want to update the recorded in data base. I want to send the "employee_id" on clicking save button. so that corresponding 'id' recorded is updated

I want to update the record of the corresponding id that is sent on clicking save button. I tried button tage, input tage and link tage but there is some mistake that I am making, but I don't know where?
This is my form
<form method="POST" action="handle_update.php">
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">First name</label>
<input type="text" name="fname" value="'.$first_name.'" class="form-control" >
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Last name</label>
<input type="text" name="last_name" value="'.$last_name.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Email</label>
<input type="email" name="email" value="'.$email.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Designation</label>
<input type="text" name="designation" value="'.$designation.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Address</label>
<input type="address" name="address" value="'.$address.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Date of Joining</label>
<input type="date" name="joining_date" value="'.$joining_date.'" class="form-control">
</div>
<a name="update" role = "button" type="submit" href="handle_update.php?ployee_id='.$id2.'">Save</a>
</form>
Add a hidden input field that holds the value you want to submit. Change your <a> to a <button> that can submit your form. Change your code to:
<form method="POST" action="handle_update.php">
<input type="hidden" name="ployee_id" value="' . $id2 . '">
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">First name</label>
<input type="text" name="fname" value="'.$first_name.'" class="form-control" >
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Last name</label>
<input type="text" name="last_name" value="'.$last_name.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Email</label>
<input type="email" name="email" value="'.$email.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Designation</label>
<input type="text" name="designation" value="'.$designation.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Address</label>
<input type="address" name="address" value="'.$address.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Date of Joining</label>
<input type="date" name="joining_date" value="'.$joining_date.'" class="form-control">
</div>
<button type="submit" name="update">Save</button>
</form>
More on forms: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form
More on hidden inputs: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/hidden

Laravel app not saving data and not displaying any error

I am using controller store method to save data, I have the model,views and controllers in place. i m using Laravel resource routing and intend to use the controller to perform CRUD operation. However, nothing seems to work.
This is the Controller save method
public function store(Request $request)
{
//
$request->validate([
'adm'=>'required|unique:student',
'fullname'=>'required|alpha',
'dept'=>'required|alpha',
'course'=>'required|alpha',
'level'=>'required|alpha',
'feyear'=>'required|numeric',
'feser'=>'required|alpha',
'idnum'=>'unique:student|required|numeric|max:8',
'current_address'=>'required',
'permanent_address'=>'required',
'email'=>'unique:student|required|email',
'mobile'=>'unique:student|required|numeric',
'occupation'=>'nullable',
'occupation_place'=>'nullable',
'otherphone'=>'nullable:numeric|max:13',
'nextofkin'=>'nullable|alpha',
'nextofkinadd'=>'required',
'nextofkinphone'=>'required|numeric',
'placeofworkadd'=>'nullable',
'supervisoradd'=>'nullable'
]);
$std = new Student([
'adm'=> $request->get('adm'),
'fullname'=> $request->get('fullname'),
'dept'=> $request->get('dept'),
'course'=> $request->get('course'),
'level'=> $request->get('level'),
'feyear'=> $request->get('feyear'),
'feser'=> $request->get('feser'),
'idnum'=> $request->get('idnum'),
'current_address'=> $request->get('current_address'),
'permanent_address'=> $request->get('permanent_address'),
'email'=> $request->get('email'),
'mobile'=> $request->get('mobile'),
'occupation'=> $request->get('occupation'),
'occupation_place'=> $request->get('occupation_place'),
'otherphone'=> $request->get('otherphone'),
'nextofkin'=> $request->get('nextofkin'),
'nextofkinadd'=> $request->get('nextofkinadd'),
'nextofkinphone'=> $request->get('nextofkinphone'),
'placeofworkadd'=> $request->get('placeofworkadd'),
'supervisoradd'=> $request->get('supervisoradd')
]);
$std->save();
return redirect('/')->with('success', 'You have been added as an Student');
}
My Model
class Student extends Model
{
protected $fillable = [
'adm',
'fullname',
'dept',
'course',
'level',
'feyear',
'feser',
'idnum',
'current_address',
'permanent_address',
'email',
'mobile',
'occupation',
'occupation_place',
'otherphone',
'nextofkin',
'nextofkinadd',
'nextofkinphone',
'placeofworkadd',
'supervisoradd'
];
}
My form
<form name="frmRegistration" method="post" action="{{ route('student.store') }}">
#csrf
<br> <p class="text-white">Fill this form if you have not yet Registered as student</p>
<div class="form-group">
<label class="text-white" for="inputEmail">Enter Full Names</label>
<input type="text" class="form-control" name="fullname" id="inputName" placeholder="e.g. Miss. Jane Doe">
</div>
<div class="form-group">
<label class="text-white" for="inputEmail">Enter National ID/Passport Number</label>
<input type="text" class="form-control" name="idnum" id="inputID" placeholder="e.g. 21436587">
</div>
<div class="form-group">
<label class="text-white" for="no">Current Mobile Phone Number</label>
<input type="text" class="form-control" name="mobile" id="inputphone" placeholder="e.g. 0734567890">
</div>
<div class="form-group">
<label class="text-white" for="otherno">Other Mobile Phone Number</label>
<input type="text" class="form-control" name="othermobile" id="altmobile" placeholder="e.g. 0734567890">
</div>
<div class="form-group">
<label class="text-white" for="inputEmail">Enter email Address</label>
<input type="email" class="form-control" name="email" id="inputName" placeholder="e.g. janedoe#yahoo.com ">
</div>
<div class="form-group">
<label class="text-white" for="inputEmail">Enter Current Address</label>
<input type="text" class="form-control" name="current_address" id="inputName" placeholder="e.g. P.O. Box 123456789 -00200- Nairobi ">
</div>
<div class="form-group">
<label class="text-white" for="inputEmail">Enter Permanent Address (can be similar to the above) </label>
<input type="text" class="form-control" name="permanent_address" id="inputName" placeholder="e.g. P.O. Box 123456 -30108- Timboroa ">
</div>
<div class="form-group">
<label class="text-white" for="admissionnumber">Next of Kin</label>
<input type="text" class="form-control" id="nextofkin" name ="nextofkin" placeholder="e.g. Jane Doe">
</div>
<div class="form-group">
<label class="text-white" for="admissionnumber">Next of Kin Address</label>
<input type="text" class="form-control" id="nextofkinadd" name ="nextofkinadd" placeholder="e.g. P.O. Box 234 -00100- Nairobi">
</div>
<div class="form-group">
<label class="text-white" for="admissionnumber">Next of Kin Mobile Phone</label>
<input type="text" class="form-control" id="nextofkinphone" name ="nextofkinphone" placeholder="e.g. 0734567890">
</div>
<div class="form-group">
<label class="text-white" for="admissionnumber">Current Occupation (if None use N/A) </label>
<input type="text" class="form-control" id="inputAdmissionnumber" name ="occupation" placeholder="e.g. Network Administrator">
</div>
<div class="form-group">
<label class="text-white" for="admissionnumber">Place of Current Occupation ( if None use N/A)</label>
<input type="text" class="form-control" id="inputAdmissionnumber" name ="occupation_place" placeholder="e.g. Nairobi">
</div>
<div class="form-group">
<label class="text-white" for="inputsupname">Supervisor Telephone Number ( if None use N/A)</label>
<input type="text" class="form-control" name="supervisoradd" id="supphone" placeholder="e.g. 0734567890">
</div>
<div class="form-group">
<label class="text-white" for="inputsupname">Address of Current Place of Work ( if None use N/A)</label>
<input type="text" class="form-control" name="placeofworkadd" id="occuadd" placeholder="e.g. Rift Valley Technical Training Institute, P.O. Box 244 -30100-,Eldoret">
</div>
<div class="form-group">
<label class="text-white" for="admissionnumber">Your Student Registration Number</label>
<input type="text" class="form-control" id="inputAdmissionnumber" name ="adm" placeholder="e.g. 117R0008">
</div>
<div class="form-group">
<label class="text-white" for="department">Select your Course's Department</label>
<select class="form-control" id="dept" name="dept">
<option>Automotive Engineering</option>
<option>Building & Civil Engineering</option>
<option>Business and Development Studies</option>
<option>Electrical & Electronic Engineering</option>
<option>Hospitality & Dietetics Management</option>
<option>Information Communication Technology</option>
<option>Mechanical and Automotive Engineering</option>
<option>Pharmacy & Chemical Science</option>
<option>Medical & Biological Sciences</option>
</select>
</div>
<div class="form-group">
<label class="text-white" for="admissionnumber">Course (in full as per registration)</label>
<input type="text" class="form-control" id="inputcourse" name="course" placeholder="e.g. Diploma in Information Communication Technology">
</div>
<div class="form-group">
<label class="text-white" for="courselevel">Select your current Course's Level</label>
<select class="form-control" id="select" name="level">
<option>Artisan</option>
<option>Craft</option>
<option>Diploma</option>
<option>Higher Diploma</option>
</select>
</div>
<div class="form-group">
<label class="text-white" for="year"> Final Examination Year</label>
<input type="number" class="form-control" id="datepicker" name="feyear" placeholder="e.g. 1994" min="1980" max="2018" value="2018">
</div>
<div class="form-group">
<label class="text-white" for="year"> Series</label>
<Select class="form-control" id="selectSeries" name="feser">
<option>July</option>
<option>November</option>
</select>
</div>
<div class="form-group">
<!--<a class="btn btn-primary btnNext" >Next Tab</a> --> <button type="submit" class="btn bg-primary btn-outline btn-xl js-scroll-trigger">Add</button></div>
</form>
Maybe, you could try with fill method to be more specific
try:
$std = new Student;
$std->fill($request->all());
$std->save();
Have you checked the Request data you are receiving? Try dumping it and checking if it's correct dd($request->all())
Check your logs too, laravel.log, php-errors.log, etc.
Also, your validator should return the validated data, like:
$validatedData = $request->validate([
'adm'=>'required|unique:student',
'fullname'=>'required|alpha',
etc....
]);
Then, if all the fields are in your fillable array, you can just do: Student::create($validatedData)
Any way, I would recommend you use Form Requests for validation, so your controller isn't so bloated.
try doing
$std = Student::create([
'adm'=> $request->get('adm'),
'fullname'=> $request->get('fullname'),
'dept'=> $request->get('dept'),
'course'=> $request->get('course'),
'level'=> $request->get('level'),
'feyear'=> $request->get('feyear'),
'feser'=> $request->get('feser'),
'idnum'=> $request->get('idnum'),
'current_address'=> $request->get('current_address'),
'permanent_address'=> $request->get('permanent_address'),
'email'=> $request->get('email'),
'mobile'=> $request->get('mobile'),
'occupation'=> $request->get('occupation'),
'occupation_place'=> $request->get('occupation_place'),
'otherphone'=> $request->get('otherphone'),
'nextofkin'=> $request->get('nextofkin'),
'nextofkinadd'=> $request->get('nextofkinadd'),
'nextofkinphone'=> $request->get('nextofkinphone'),
'placeofworkadd'=> $request->get('placeofworkadd'),
'supervisoradd'=> $request->get('supervisoradd')
]);
or the easier way if your $request fields are same as in fillable
$input=$request->all();
$std = Student::create($input);

Pop up contact form disappears when clicking the submit button

The form is based on bootstrap here is the code:
When i try to validate the submition of the for using this very simple code.
Then the form just disappears. Any insights guys would be greatly appreciated.
Thanks
New gal to coding.
<div class="container">
<div class="row">
<div class="col-sm-12 contact-form">
<form id="contact" method="post" class="form" role="form">
<div class="row">
<div class="col-xs-6 col-md-6 form-group">
<input class="form-control" id="name" name="name" placeholder="FIRST NAME" type="text" required autofocus />
</div>
<div class="col-xs-6 col-md-6 form-group">
<input class="form-control" id="name" name="lastname" placeholder="LAST NAME" type="text" required
autofocus />
</div>
<div class="col-xs-6 col-md-6 form-group">
<input class="form-control" id="email" name="email" placeholder="EMAIL" type="email" required />
</div>
<div class="col-xs-6 col-md-6 form-group">
<input class="form-control" id="name" name="phone" placeholder="PHONE" type="text" required autofocus />
</div>
<div class="col-xs-6 col-md-6 form-group">
<input class="form-control" id="name" name="address1" placeholder="ADDRESS 1" type="text" required
autofocus />
</div>
<div class="col-xs-6 col-md-6 form-group">
<input class="form-control" id="name" name="address2" placeholder="ADDRESS 2" type="text" required
autofocus />
</div>
<div class="col-xs-6 col-md-6 form-group">
<input class="form-control" id="name" name="city" placeholder="CITY" type="text" required autofocus />
</div>
<div class="col-xs-3 col-md-3 form-group">
<input class="form-control" id="name" name="state" placeholder="STATE" type="text" required autofocus />
</div>
<div class="col-xs-3 col-md-3 form-group">
<input class="form-control" id="name" name="zipcode" placeholder="ZIPCODE" type="text" required autofocus />
</div>
<h1 class="h1-contact">WHAT SERVICES ARE YOU INTERESTED IN?</h1>
</div>
<div class="row">
<div class="col-sm-6">
<h3>SELECT ALL THAT APPLY:</h3>
<label class="checkbtn">item 1
<input type="checkbox" checked="checked" name="item5" value="item5">
<span class="checkmark"></span>
</label>
<label class="checkbtn"> item 2
<input type="checkbox" name="item4" id="item4">
<span class="checkmark"></span>
</label>
<label class="checkbtn">item 3
<input type="checkbox" name="item3" id="item3">
<span class="checkmark"></span>
</label>
<label class="checkbtn">item 4
<input type="checkbox" name="item2" id="item2">
<span class="checkmark"></span>
</label>
<label class="checkbtn">item 5
<input type="checkbox" name="example1">
<span class="checkmark"></span>

Bootstrap Panel Body Left and Right

I want create panel-body bootstrap left and right
here my code
<div class="panel-body">
<p>1. Fill Full Name</p>
<p> Example</p>
<label for="name" class="col-sm-1 control-label">Full Name<span class="important">*</span></label>
<div class="col-sm-3">
<input type="text" class="form-control" id="name" name="name" size="40" maxlength="50" disabled="disabled"
value="Full Name" required>
<div class="help-block with-errors"></div>
</div>
</div>
<!-- Phone Ext -->
<div class="panel-body">
<p>2. Fill Phone Extention</p>
<p> Extention</p>
<label for="name" class="col-sm-1 control-label">Phone Extention<span class="important">*</span></label>
<div class="col-sm-3">
<input type="text" class="form-control" id="name" name="name" size="40" maxlength="50" disabled="disabled"
value="Phone Extention" required>
<div class="help-block with-errors"></div>
</div>
</div>
and number 3 I want it in Right side
Thanks a lot for your help
You could split the column like this :
<div class="panel-body">
<div class="col-md-6">
<p>1. Fill Full Name</p>
<p> Example</p>
<label for="name" class="col-sm-2 control-label">Full Name<span class="important">*</span></label>
<div class="col-sm-6">
<input type="text" class="form-control" id="name" name="name" size="40" maxlength="50" disabled="disabled"
value="Full Name" required>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-6">
<p>3. Title #3</p>
<p> Content for #3</p>
<label for="name" class="col-sm-2 control-label">Label #3<span class="important">*</span></label>
<div class="col-sm-6">
<input type="text" class="form-control" id="name" name="name" size="40" maxlength="50" disabled="disabled"
value="Label #3" required>
<div class="help-block with-errors"></div>
</div>
</div>
</div>
<!-- Phone Ext -->
<div class="panel-body">
<p>2. Fill Phone Extention</p>
<p> Extention</p>
<label for="name" class="col-sm-1 control-label">Phone Extention<span class="important">*</span></label>
<div class="col-sm-3">
<input type="text" class="form-control" id="name" name="name" size="40" maxlength="50" disabled="disabled"
value="Phone Extention" required>
<div class="help-block with-errors"></div>
</div>
</div>

Apply Validation on the added form using jquery [duplicate]

This question already has answers here:
jquery validate plugin on dynamic form inputs not working
(3 answers)
Closed 5 years ago.
I have a form with fields with firstname, last name and email.
I have added a code in which when user clicks a button it adds the another person with same three fields. This works perfect.
Apart from it i have applied (required) validations on these three fields.
The problem i am facing is when i clicks on add another person it adds the fields and but the validations part is not working.
I want to add the required validations on the added person.
Thanks in advance.
Here is my code.
<form name="AttendeeForm" id="AttendeeForm" action="" method="post" >
<div class="block" id="Attendent-list">
<div class="col-md-12 col-lg-12">
<div class="col-md-12 col-lg-12">
<h3 class="heading">Who's Attending?</h3>
</div>
<div class="col-md-3 col-lg-3">
<label for="first_name">First Name<span class="">*</span></label><br>
<input id="first_name" value="" class="field" name="fname[]" type="text" placeholder="First Name" required=""><br>
<p id="FNameerror"></p>
</div>
<div class="col-md-3 col-lg-3">
<label for="last_name">Last Name<span class="">*</span></label><br>
<input id="last_name" value="" class="field" name="lname[]" type="text" placeholder="Last Name" required="">
<p id="LNameerror"></p>
</div>
<div class="col-md-6 col-lg-6">
<label for="email">Email<span class="">*</span></label><br>
<input id="email" value="" class="field" type="email" name="email[]" placeholder="me#example.com" required="">
<p id="Emailerror"></p>
</div>
</div>
</div>
<div class="col-md-12 col-lg-12">
<fieldset id="add_another_person" class="add-person">
<input type="button" name="add_person_button" class="add_person_button button-ghost" id="add_person_button" value="Add Another Person">
</fieldset>
</div>
</form>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
<script>
$('.add_person_button').click(function() {
var abc=$("#AttendeeForm").valid();
if(abc == true){
$('.block:last').after('<div class="block" id="Attendent-list" style="clear: both;"><div style="clear:both;"><div class="col-md-12"><div class="col-md-3"><label for="first_name">First Name<span class="">*</span></label><input id="first_name_'+personcounter+'" value="" class="field" name="fname[]" type="text" placeholder="First Name" required=""><p id="FNameerror"></p></div><div class="col-md-3"><label for="last_name">Last Name <span class="">*</span></label><input id="last_name_'+personcounter+'" value="" class="field" name="lname[]" type="text" placeholder="Last Name" required=""><p id="LNameerror"></p></div><div class="col-md-6"><label for="email">Email <span class="">*</span></label><input id="email_'+personcounter+'" value="" class="field" type="email" name="email[]" placeholder="me#example.com" required=""><p id="Emailerror"></p></div></div></div><div class="col-md-12"><br></div><div style="clear:both;"></div><div class="col-md-12"><br><br></div><div style="clear:both;"><div class="col-md-12"><div class="col-md-4"><input type="button" name="delete_person_button" id="remove_registrant_36391" class="delete_person_button button-ghost" value="Remove this Person"></a></div></div></div><div class="col-md-12"><div class="col-md-12"><br><hr><br></div></div></div>');
}
});
$('#AttendeeForm').validate();
$('input[type="text"]').each(function () {
$(this).rules('add', {
required: true
});
});
</script>
Don't write required=""
Just write required.

Categories