how to create Html form to send email with button - html

Unable to get ths form working.
Is there any easy to create html form that will simply send email upon submission?
Can anyone provide some code samples?
I tried to get it workin but it always stay there no response on email. In form i tried to get date, time, locations that can be typed, number passanger and cars, car type, name email and message.
<form class="booking-form">
<div class="row">
<!-- <div class="col-xs-6 col-sm-2">
<fieldset class="car-type">
<input type="checkbox" name="car-type" id="econo" />
<label for="econo"><i class="icon-car-econo"></i>Econo</label>
</fieldset>
</div> -->
<div class="col-xs-6 col-sm-2">
<fieldset class="car-type">
<input type="checkbox" name="car-tclass="icon-car-LUXURY SEDANype" id="LUXURY SEDAN" />
<label for="LUXURY SEDAN"><i class="icon-car-classic"> </i>LUXURY SEDAN</label>
</fieldset>
</div>
<div class="col-xs-6 col-sm-2">
<fieldset class="car-type">
<input type="checkbox" name="car-type" id="EUROPEAN SEDAN" />
<label for="EUROPEAN SEDAN"><i class="icon-car-wagon"></i>EUROPEAN SEDAN</label>
</fieldset>
</div>
</div>
<div class="row">
<div class="col-sm-3">
<fieldset>
<input type="text" name="name" placeholder="Name" />
</fieldset>
<fieldset>
<input type="email" name="email" placeholder="Email" />
</fieldset>
</div>
<div class="col-sm-3">
<fieldset>
<input type="text" name="from1" placeholder="From" />
</fieldset>
<fieldset>
<input type="text" name="to1" placeholder="To" />
</fieldset>
</div>
<div class="col-sm-3">
<fieldset>
<input type="text" name="date" placeholder="Date1" class="datepicker" />
</fieldset>
<fieldset>
<input type="text" name="time" placeholder="Time" class="timepicker" />
</fieldset>
</div>
<div class="col-sm-3">
<fieldset>
<select name="cars">
<option>Cars</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</fieldset>
<fieldset>
<select name="passengers">
<option>Passengers</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</fieldset>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<fieldset>
<textarea name="message2" placeholder="Message"></textarea>
</fieldset>
</div>
</div>
<div class="row">
<div class="col-sm-12 text-center">
<button class="btn btn-primary">Book Now</button>
</div>
</div>
</form>

you need a backend language
<!-- action->specify the destiny of data from form | method->indicate shipping method -->
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
<input type="text" name="someText" placeholder="someText">
<input type="submit" name="sendText" value="sendText">
</form>
and with php you can send the data form form
<?php
$errorMessage = ''; // case the user not complete all fields of the form
$to = 'myemail#company.com'; // destiny of message
if( isset($_POST['sendText']) ){ // comprobate the action of the input type submit
$someText = $_POST['someText']; // get the value of input type text
if( !empty($someText) ){ // comprobate if the variable is not empty
$someText = stripslashes(trim(filter_var($someText , FILTER_SANITIZE_STRING))); // this sanitize the text for avoid the code injection
mail($to,$someText); // this method only can send message when the web is working on server
}else{ // show an error message if text is empty
$errorMessage.="Please complete all fields <br>";
}
}
?>

Related

Form post adding data in url

I have some strange thing happening from my self post forms. I thought using form method="post" would not put data in the url. And I'm having different outcomes on both forms
<form method="post" action="" enctype="multipart/form-data" id="testForm">
<div class="form-group">
<div class="panel-heading">
some junk
</div>
<div class="panel-body">
<div class="col-md-12">
<textarea id="summernote" name="Full_Discription" class="form-control" required></textarea>
</div>
<div class="col-md-1">
<input type='hidden' name='var' value='<?php echo "$Known_Issue_id";?>'/>
<button name="submit" type="submit" id="submitButton" class="btn btn-accent">Submit Follow-up</button>
</div>
</div>
</div>
</form>
If I submit this form the hidden data shows in URL but not the body text from summernot
web_known_issues_bug.php?bug=20
<form method="post" enctype="multipart/form-data" id="testForm">
<div class="form-group">
<div class="col-md-2">
<label>Website Issue Type:</label>
<select class="form-control" name="Issue_Plugin" id="Issue_Plugin" required>
<option value="">- Select Web Issue -</option>
</select>
</div>
<div class="col-md-7">
<label>Description Of Known Issue:</label> <input name="Issue_Discription" type="text" value="" class="form-control" required>
</div>
<div class="col-md-2">
<label>Type Of Issue:</label>
<select class="form-control" name="Issue_Type" id="Issue_Type" required>
<option value="">- Bug Type -</option>
</select>
</div>
<div class="col-md-1">
<label>Submit Issue</label><BR>
<input type='hidden' name='bug' value='<?php echo "none";?>'/>
<button name="submit" type="submit" id="submitButton" class="btn btn-accent">Submit Issue</button>
</div>
<div class="col-md-12">
<textarea id="summernote" name="Full_Discription" class="form-control" required><?php echo $SendBody; ?></textarea>
</div>
</div>
This form is spitting everything to the url?
web_known_issues.php?message=Added%20New%20Bug%20List%20Item&title=Siclone%20Crashes%20when%20not%20used%20everyday&full=asdasdasdasdasd
I really need this stuff to send clean urls. Any idea on what I have done wrong?
Sorry, this is solved. My error, I left in some debug code in the miles of PHP

Is parsley lib work on check boxes and also for wizard class of bootstrap. if it is how to prevent it?

In my webapp i have made two <fieldset> one for four <input> fields and one for
checkboxes. Now i am using this parsely lib on these <fieldset> it is not working on it. but it works on othere pages that in which different fields have been made. now i don't know about this lib so much if it is work on checkboxes or not. and also i dont wanna apply parsely lib on these checkboxes.
So my question is :
why it does not work on given below code which is in my webapp it is
one page but on other page it works.?
Here's code:
<form id="form1" action="" method="POST" enctype="multipart/form-data" >
<input type="hidden" id="user_id" name="user_id" value="<?php echo empty($user_id)?"":$user_id;?>" />
<fieldset>
<legend>Basic Info</legend>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="name">First Name *</label>
<p id="validation"></p>
<input type="text" class="form-
control" id="fname" name="fname" value="<?php echo empty($fname)?"":$fname;?>"
placeholder="Enter First Name" data-type="alphanum" maxlength="45"/>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="email">Last Name *</label>
<input type="text" class="form-control" id="lname" name="lname" value="<?php echo empty($lname)?"":$lname;?>" placeholder="Enter Last Name" data-type="alphanum" maxlength="45"/>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="name">Email *</label>
<input type="text" class="form-
control" id="email" name="email" value="<?php echo empty($email)?"":$email;?
>"
placeholder="Enter Email" data-type="alphanum" maxlength="45"/>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="email">Mobile #</label>
<input type="text" class="form-control" id="mobile" name="mobile" value="<?php echo empty($mobile)?"":$mobile;?>" placeholder="+55 99 99999999" data-type="alphanum" maxlength="45"/>
</div>
</div>
</div>
<div class="row" style="display:none;">
<div class="col-md-6">
<div class="form-group">
<label for="status">Status</label>
<div>
<span class="text-muted m-l-5">InActive</span>
<input type="checkbox" data-render="switchery" id="status" name="status" data-theme="default" checked />
<span class="text-muted m-l-5">Active</span>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="status">All Permissions</label>
<div>
<span class="text-muted m-l-5">No</span>
<input type="checkbox" data-render="switchery" id="status" name="status" data-theme="default" checked />
<span class="text-muted m-l-5">Yes</span>
</div>
</div>
</div>
</div>
</fieldset>
<fieldset>
Here for checkboxes
</fieldset>
I found the answer to my question. after spending an hour reading official docs.It says
Checkbox, radio and select multiple are a bit different than regular
input, textarea or simple select. They need to have either a name or
an id attribute to be correctly bound and validated by Parsley.
Otherwise, they will be ignored and a warning will be put in the
console.

Upload files to a form

I have a form on my website to allow clients to submit inquiries but I need to add the option of adding files, in this case, it would be photos.
I can't find the proper solution for this. I'm new on this matter and I hope someone can help me.
Here it is the code i have about the form:
<form enctype="multipart/form-data" name="<?=$form_name?>" id="<?=$form_name?>" method="post" action="javascript:void(0);" >
<input type="hidden" name="lang" id="lang" value="<?=$_SESSION["lang"]?>" />
<input type="hidden" name="car_id" id="car_id" value="<?=$_SESSION["car_id"]?>" />
<input type="hidden" name="current_url" id="current_url" value="<?=$_SESSION["current_url"]?>" />
<!--NOME-->
<div class="form-group">
<? $input_name = $form_name."_"."name"; ?>
<label for="<?=$input_name?>"><?=NAME?>*</label>
<input type="text" class="{target:'#<?=$input_name?>_status',tagToload:{'.<?=$input_name?>':'#<?=$input_name?>_status','.script':'#<?=$result_div?>'}} form-control watermark required" name="<?=$input_name?>" value="<?=$_POST[$input_name]?>" id="<?=$input_name?>" placeholder="<?=NAME_PLACEHOLDER?>">
</div>
<!--END NOME-->
<!--EMAIL-->
<div class="form-group">
<? $input_name = $form_name."_"."email"; ?>
<label for="<?=$input_name?>"><?=EMAIL?>*</label>
<input type="email" class="{target:'#<?=$input_name?>_status',tagToload:{'.<?=$input_name?>':'#<?=$input_name?>_status','.script':'#<?=$result_div?>'}} form-control watermark required" name="<?=$input_name?>" value="<?=$_POST[$input_name]?>" id="<?=$input_name?>" placeholder="<?=EMAIL_PLACEHOLDER?>">
</div>
<!--END EMAIL-->
<!--SUBJECT-->
<div class="form-group">
<? $input_name = $form_name."_"."subject_other"; ?>
<label for="<?=$input_name?>"><?=SUBJECT?>*</label>
<input type="text" class="{target:'#<?=$input_name?>_status',tagToload:{'.<?=$input_name?>':'#<?=$input_name?>_status','.script':'#<?=$result_div?>'}} form-control watermark required" name="<?=$input_name?>" value="<?=$_SESSION['subject']?>" id="<?=$input_name?>" placeholder="<?=SUBJECT_PLACEHOLDER?>" <?=(isset($_SESSION["subject"])) ? 'readonly="readonly"' : ''?>>
</div>
<!--END SUBJECT-->
<!--MESSAGE-->
<div class="form-group" style="margin-bottom: 10px;">
<? $input_name = $form_name."_"."message"; ?>
<label for="<?=$input_name?>"><?=MESSAGE?>*</label>
<textarea class="{target:'#<?=$input_name?>_status',tagToload:{'.<?=$input_name?>':'#<?=$input_name?>_status','.script':'#<?=$result_div?>'}} form-control watermark required" name="<?=$input_name?>" id="<?=$input_name?>" placeholder="<?=MESSAGE_PLACEHOLDER?>" rows="3"></textarea>
</div>
<!--END MESSAGE-->
<span class="blue_label blue_label_block blue_label_small" style="text-align: left;">* Campos de preenchimento obrigatório.</span>
<div class="form-group pull-right" style="margin-bottom: 20px;">
<input type="reset" class="btn btn-primary" value="<?=CLEAR?>">
<a type="button" class="btn btn-default ml20" id="formSubmitLink_<?=$form_name?>" href="javascript:;"><?=SEND?></a>
</div>
<br class="clear">
<div class="resultForm" id="<?=$result_div?>"></div>
<div class="form-group">
<label for="photo" class="col-lg-2 control-label">Photo</label>
<div class="col-lg-10">
<input type="file" class="form-control" id="photo" placeholder="Photo">
</div>
</div>

HTML form not submitted via phone

Good day, I'm wondering why my button cannot do a submit inside phone browsers. Please take alook at my form
<form class="form-horizontal" method="POST" action="#" id ='form_id'>
<div class="form-group">
<label class="col-sm-3 control-label">Tipe</label>
<div class="col-sm-5">
<select onchange = 'by_brand();' name = 'tipenya' id="tipe" class="form-control select2">
<option value="">---</option>
<option value="AR-1">Naughty</option>
<option value="AR-6">Les Femmes</option>
<option value="AR-10">Matahari</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Area</label>
<div class="col-sm-5">
<select onchange="brands();" name ='area' id="areanya" class="form-control select2">
<option value="">All</option>
<?php foreach ($area as $areanya) {?>
<option value="<?=$areanya->AreaCode;?>"><?=$areanya->Description;?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Outlet</label>
<div class="col-sm-5">
<select name='outlet' id="hsl" class="form-control select2">
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Date</label>
<div class="col-sm-5">
<input type="text" class="form-control pull-right" readonly="readonly" placeholder="Tanggal" name="date_search" id="reservation" />
</div>
</div>
<div class="box-footer pull-right">
<input type="submit" class="btn btn-submit" />
</div>
</form>
It's working fine when i use any laptop. Can anyone help me?
Here is my full html code
http://pastebin.com/KCEQzW3e
First of all try using this to test if the sumbit actually works
<form action="javascript:alert("sumbit button works!");" id='form_id'>
if this doesnt work then there is something wrong with your form.
if this works. there is something wrong with the jquery function you used.
try using this to call a function if you click submit:
<form class="form-horizontal" method="POST" action="#" id ='form_id' onsubmit="myFunction()">
I hope this helps.

form submitting not refresing value if get out the button

I have a form, that I need my save button to be outside of form elements, but if I take it out elsewhere, it doesn`t like refresh the form.
<form ng-submit="save()" action="" name="addInv" novalidate>
<div class="col-md-10">
<label>Name:</label>
<input type="text" ng-model="newlocation.name" class="form-control">
</div>
<div class="col-md-10">
<label>Storage administrator:</label>
<select ng-model="newlocation.administrator" class="form-control" ng-options="user.resource_uri as user.first_name for user in users"></select>
</div>
<div class="col-md-6">
<label>Street:</label>
<input type="text" ng-model="newlocation.street" class="input-medium form-control">
</div>
<div class="col-md-6">
<label>City:</label>
<input type="text" ng-model="newlocation.city" class="input-medium form-control">
</div>
<div class="col-md-6">
<label>Country:</label>
<input type="text" ng-model="newlocation.country" class="input-medium form-control">
</div>
<div class="col-md-6">
<label>Postal code:</label>
<input type="text" ng-model="newlocation.postalCode" class="input-medium form-control">
</div>
<div class="col-md-6">
<button class="btn tbn-lg btn-primary">Save</button>
</div>
</form>
If I put button outside the <form> form doesn't refresh values.
You could use JavaScript to do this
<input type="submit" onclick="document.forms[0].submit();" />