How to validate all text or send the data by submit image in html button tag





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















i have used the submit image between the button tag to send the data on my mail id but when i clicked on button it redirect to next page without filled the data into text boxes and not getting the mail on my mail id. php script also used for this. i have checked many times but not get success so please help me out how to validate & send the data on mail. ican't under stand where is issue :



enter code here
<?php



if(isset($_POST['submit'])){
$to = "sandeepdoliya110@gmail.com"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$state = $_POST['state'];
$city = $_POST['city'];
$pincode = $_POST['pincode'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$payment_type = $_POST['payment_type'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";

$message = $first_name . "n " . $last_name . " n" .$address1. "n " .$address2 . "n " . $state . "n " . $city . "n " . $pincode . " n" . $phone . "n " . $email . "n " . $payment_type ."nn" ;
$message2 = "Thank you for showing interest. We will Contact You Soon " . $first_name . "n " . $last_name . " n" .$address1. "n " .$address2 . "n " . $state . "n " . $city . "n " . $pincode . " n" . $phone . "n " . $email . "n " . $payment_type ."nn" ;

$headers = "From:" . $from;
$headers2 = "From:" . $to;
@mail($to,$subject,$message,$headers);
@mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.


}

else{
echo "something is wrong";
}

?>

html part is :

<!-- Form -->
<form name="package-payment" id="package-payment" method="post" action="" class="form-horizontal">
<div class="form-group" id="error-message">
</div>

<div class="col-sm-12">
<div class="col-sm-6">
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label" required>First Name</label>
<div class="col-sm-9">
<input class="form-control" id="first_name" name="first_name" required name="first_name" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Last Name</label>
<div class="col-sm-9">
<input class="form-control" id="last_name" name="last_name" required name="last_name" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Address 1</label>
<div class="col-sm-9">
<input class="form-control" id="address1" name="address1" required name="address1" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Address 2</label>
<div class="col-sm-9">
<input class="form-control" id="address2" name="address2"required name="address2" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">State</label>
<div class="col-sm-9">
<select id="state" name="state" class="form-control">
<option value="State" option=""></option>
<option value="Andaman and Nicobar Islands">Andaman and Nicobar Islands</option>
<option value="Andhra Pradesh">Andhra Pradesh</option>
<option value="Arunachal Pradesh">Arunachal Pradesh</option>
<option value="Assam">Assam</option>
<option value="Bihar">Bihar</option>
<option value="Chandigarh">Chandigarh</option>
<option value="Chhattisgarh">Chhattisgarh</option>
<option value="Dadra and Nagar Haveli">Dadra and Nagar Haveli</option>
<option value="Daman and Diu">Daman and Diu</option>
<option value="Delhi">Delhi</option>
<option value="Goa">Goa</option>
<option value="Gujarat">Gujarat</option>
<option value="Haryana">Haryana</option>
<option value="Himachal Pradesh">Himachal Pradesh</option>
<option value="Jammu and Kashmir">Jammu and Kashmir</option>
<option value="Jharkhand">Jharkhand</option>
<option value="Karnataka">Karnataka</option>
<option value="Kerala">Kerala</option>
<option value="Lakshadweep">Lakshadweep</option>
<option value="Madhya Pradesh">Madhya Pradesh</option>
<option value="Maharashtra">Maharashtra</option>
<option value="Manipur">Manipur</option>
<option value="Meghalaya">Meghalaya</option>
<option value="Mizoram">Mizoram</option>
<option value="Nagaland">Nagaland</option>
<option value="Orissa">Orissa</option>
<option value="Pondicherry">Pondicherry</option>
<option value="Punjab">Punjab</option>
<option value="Rajasthan">Rajasthan</option>
<option value="Sikkim">Sikkim</option>
<option value="Tamil Nadu">Tamil Nadu</option>
<option value="Tripura">Tripura</option>
<option value="Uttaranchal">Uttaranchal</option>
<option value="Uttar Pradesh">Uttar Pradesh</option>
<option value="West Bengal">West Bengal</option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">City</label>
<div class="col-sm-9">
<input class="form-control" id="city" name="city" required name="city" value="" type="text">
</div>
</div>

</div>

<div class="col-sm-6">

<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Pincode</label>
<div class="col-sm-9">
<input class="form-control" id="pincode" name="pincode" required name="pincode" maxlength="6" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Phone</label>
<div class="col-sm-9">
<input class="form-control" id="phone" name="phone" required name="phone" maxlength="12" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Email</label>
<div class="col-sm-9">
<input class="form-control" id="email" name="email" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Shipping</label>
<div class="col-sm-9">
<p class=" custom_form_fields_reeadonly"><b class="black-text"><i class="fas fa-rupee-sign"></i>. 199/-</b></p>
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Amount</label>
<div class="col-sm-9">
<p class=" custom_form_fields_reeadonly">MRP. <i class="fas fa-rupee-sign"></i>. <s>2,600/-</s> &nbsp; <b class="orange-text font-bolder">Offer <i class="fas fa-rupee-sign"></i>. 1,299/-</b></p>
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Payment</label>
<div class="col-sm-9 padd-top-05em">
<input value="cod" name="payment_type" id="cod" checked="checked" type="radio"><b class="padd-right-1em"> Cash on Delivery</b>
<input value="prepaid" name="payment_type" id="prepaid" type="radio"><b> Prepaid</b>
</div>
</div>

</div>
</div>
<div class="clearfix"></div>
<!-- <input name="gateway" type="hidden" id="gateway" />
<input type="hidden" name="ch" id="ch" value="" />
<input type="hidden" name="ssd" id="ssd" value=""/>
<input type="hidden" name="ocode" id="ocode" value=""/>
<input type="hidden" value="2922" id="page_id" name="page_id"/>
<input type="hidden" value="1498" id="amount" name="amount"/>
<input type="hidden" value="1498" id="payu_amount" name="payu_amount"/>
<input type="hidden" value="25" id="product_id" name="product_id"/>
<input type="hidden" value="fitband" id="product_info" name="product_info"/>-->
<div class="col-sm-12 text-center">
<button type="button" onclick="location.href = 'contact.php';" name="submit" value="submit" class="submitbtn">
<img src="images/button-buy-now.png" alt="submit" style="padding:18px 0px; width:190px;">

</button>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span class="brand-color"><b>Mail Us:</b></span><i class="font-bolder">support@neutrikart.com</i>&nbsp;
</div>
</form>

<!-- Icons -->
<div class="col-sm-12 icon-form-box black-text text-uppercase text-shadow-black">
<div class="col-sm-3 padd-top-1em">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="icon-number font-bolder">100%</td>
<td>risk-free purchase</td>
</tr>
</table>
</div>
<div class="col-sm-3 icon-number-top padd-top-1em">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="icon-number font-bolder">COD</td>
<td>cash-on delivery</td>
</tr>
</table>
</div>
<div class="col-sm-3 icon-number-top padd-top-1em">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="icon-number font-bolder">48-Hrs</td>
<td>money-back guarantee</td>
</tr>
</table>
</div>
<div class="col-sm-3 icon-number-top padd-top-1em animated fadeInDown">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="icon-number font-bolder">50%</td>
<td>Discounted Price</td>
</tr>
</table>
</div>
</div>
</div>
</div>

</div>
</div>
</div>









share|improve this question

























  • The redirect happens because you explicitely are doing so: <button type="button" onclick="location.href = 'contact.php';" name="submit" value="submit" class="submitbtn">" Remove the onclick attribute and use a button type of submit.

    – Teemu
    Jan 4 at 5:28


















0















i have used the submit image between the button tag to send the data on my mail id but when i clicked on button it redirect to next page without filled the data into text boxes and not getting the mail on my mail id. php script also used for this. i have checked many times but not get success so please help me out how to validate & send the data on mail. ican't under stand where is issue :



enter code here
<?php



if(isset($_POST['submit'])){
$to = "sandeepdoliya110@gmail.com"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$state = $_POST['state'];
$city = $_POST['city'];
$pincode = $_POST['pincode'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$payment_type = $_POST['payment_type'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";

$message = $first_name . "n " . $last_name . " n" .$address1. "n " .$address2 . "n " . $state . "n " . $city . "n " . $pincode . " n" . $phone . "n " . $email . "n " . $payment_type ."nn" ;
$message2 = "Thank you for showing interest. We will Contact You Soon " . $first_name . "n " . $last_name . " n" .$address1. "n " .$address2 . "n " . $state . "n " . $city . "n " . $pincode . " n" . $phone . "n " . $email . "n " . $payment_type ."nn" ;

$headers = "From:" . $from;
$headers2 = "From:" . $to;
@mail($to,$subject,$message,$headers);
@mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.


}

else{
echo "something is wrong";
}

?>

html part is :

<!-- Form -->
<form name="package-payment" id="package-payment" method="post" action="" class="form-horizontal">
<div class="form-group" id="error-message">
</div>

<div class="col-sm-12">
<div class="col-sm-6">
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label" required>First Name</label>
<div class="col-sm-9">
<input class="form-control" id="first_name" name="first_name" required name="first_name" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Last Name</label>
<div class="col-sm-9">
<input class="form-control" id="last_name" name="last_name" required name="last_name" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Address 1</label>
<div class="col-sm-9">
<input class="form-control" id="address1" name="address1" required name="address1" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Address 2</label>
<div class="col-sm-9">
<input class="form-control" id="address2" name="address2"required name="address2" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">State</label>
<div class="col-sm-9">
<select id="state" name="state" class="form-control">
<option value="State" option=""></option>
<option value="Andaman and Nicobar Islands">Andaman and Nicobar Islands</option>
<option value="Andhra Pradesh">Andhra Pradesh</option>
<option value="Arunachal Pradesh">Arunachal Pradesh</option>
<option value="Assam">Assam</option>
<option value="Bihar">Bihar</option>
<option value="Chandigarh">Chandigarh</option>
<option value="Chhattisgarh">Chhattisgarh</option>
<option value="Dadra and Nagar Haveli">Dadra and Nagar Haveli</option>
<option value="Daman and Diu">Daman and Diu</option>
<option value="Delhi">Delhi</option>
<option value="Goa">Goa</option>
<option value="Gujarat">Gujarat</option>
<option value="Haryana">Haryana</option>
<option value="Himachal Pradesh">Himachal Pradesh</option>
<option value="Jammu and Kashmir">Jammu and Kashmir</option>
<option value="Jharkhand">Jharkhand</option>
<option value="Karnataka">Karnataka</option>
<option value="Kerala">Kerala</option>
<option value="Lakshadweep">Lakshadweep</option>
<option value="Madhya Pradesh">Madhya Pradesh</option>
<option value="Maharashtra">Maharashtra</option>
<option value="Manipur">Manipur</option>
<option value="Meghalaya">Meghalaya</option>
<option value="Mizoram">Mizoram</option>
<option value="Nagaland">Nagaland</option>
<option value="Orissa">Orissa</option>
<option value="Pondicherry">Pondicherry</option>
<option value="Punjab">Punjab</option>
<option value="Rajasthan">Rajasthan</option>
<option value="Sikkim">Sikkim</option>
<option value="Tamil Nadu">Tamil Nadu</option>
<option value="Tripura">Tripura</option>
<option value="Uttaranchal">Uttaranchal</option>
<option value="Uttar Pradesh">Uttar Pradesh</option>
<option value="West Bengal">West Bengal</option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">City</label>
<div class="col-sm-9">
<input class="form-control" id="city" name="city" required name="city" value="" type="text">
</div>
</div>

</div>

<div class="col-sm-6">

<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Pincode</label>
<div class="col-sm-9">
<input class="form-control" id="pincode" name="pincode" required name="pincode" maxlength="6" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Phone</label>
<div class="col-sm-9">
<input class="form-control" id="phone" name="phone" required name="phone" maxlength="12" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Email</label>
<div class="col-sm-9">
<input class="form-control" id="email" name="email" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Shipping</label>
<div class="col-sm-9">
<p class=" custom_form_fields_reeadonly"><b class="black-text"><i class="fas fa-rupee-sign"></i>. 199/-</b></p>
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Amount</label>
<div class="col-sm-9">
<p class=" custom_form_fields_reeadonly">MRP. <i class="fas fa-rupee-sign"></i>. <s>2,600/-</s> &nbsp; <b class="orange-text font-bolder">Offer <i class="fas fa-rupee-sign"></i>. 1,299/-</b></p>
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Payment</label>
<div class="col-sm-9 padd-top-05em">
<input value="cod" name="payment_type" id="cod" checked="checked" type="radio"><b class="padd-right-1em"> Cash on Delivery</b>
<input value="prepaid" name="payment_type" id="prepaid" type="radio"><b> Prepaid</b>
</div>
</div>

</div>
</div>
<div class="clearfix"></div>
<!-- <input name="gateway" type="hidden" id="gateway" />
<input type="hidden" name="ch" id="ch" value="" />
<input type="hidden" name="ssd" id="ssd" value=""/>
<input type="hidden" name="ocode" id="ocode" value=""/>
<input type="hidden" value="2922" id="page_id" name="page_id"/>
<input type="hidden" value="1498" id="amount" name="amount"/>
<input type="hidden" value="1498" id="payu_amount" name="payu_amount"/>
<input type="hidden" value="25" id="product_id" name="product_id"/>
<input type="hidden" value="fitband" id="product_info" name="product_info"/>-->
<div class="col-sm-12 text-center">
<button type="button" onclick="location.href = 'contact.php';" name="submit" value="submit" class="submitbtn">
<img src="images/button-buy-now.png" alt="submit" style="padding:18px 0px; width:190px;">

</button>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span class="brand-color"><b>Mail Us:</b></span><i class="font-bolder">support@neutrikart.com</i>&nbsp;
</div>
</form>

<!-- Icons -->
<div class="col-sm-12 icon-form-box black-text text-uppercase text-shadow-black">
<div class="col-sm-3 padd-top-1em">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="icon-number font-bolder">100%</td>
<td>risk-free purchase</td>
</tr>
</table>
</div>
<div class="col-sm-3 icon-number-top padd-top-1em">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="icon-number font-bolder">COD</td>
<td>cash-on delivery</td>
</tr>
</table>
</div>
<div class="col-sm-3 icon-number-top padd-top-1em">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="icon-number font-bolder">48-Hrs</td>
<td>money-back guarantee</td>
</tr>
</table>
</div>
<div class="col-sm-3 icon-number-top padd-top-1em animated fadeInDown">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="icon-number font-bolder">50%</td>
<td>Discounted Price</td>
</tr>
</table>
</div>
</div>
</div>
</div>

</div>
</div>
</div>









share|improve this question

























  • The redirect happens because you explicitely are doing so: <button type="button" onclick="location.href = 'contact.php';" name="submit" value="submit" class="submitbtn">" Remove the onclick attribute and use a button type of submit.

    – Teemu
    Jan 4 at 5:28














0












0








0








i have used the submit image between the button tag to send the data on my mail id but when i clicked on button it redirect to next page without filled the data into text boxes and not getting the mail on my mail id. php script also used for this. i have checked many times but not get success so please help me out how to validate & send the data on mail. ican't under stand where is issue :



enter code here
<?php



if(isset($_POST['submit'])){
$to = "sandeepdoliya110@gmail.com"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$state = $_POST['state'];
$city = $_POST['city'];
$pincode = $_POST['pincode'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$payment_type = $_POST['payment_type'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";

$message = $first_name . "n " . $last_name . " n" .$address1. "n " .$address2 . "n " . $state . "n " . $city . "n " . $pincode . " n" . $phone . "n " . $email . "n " . $payment_type ."nn" ;
$message2 = "Thank you for showing interest. We will Contact You Soon " . $first_name . "n " . $last_name . " n" .$address1. "n " .$address2 . "n " . $state . "n " . $city . "n " . $pincode . " n" . $phone . "n " . $email . "n " . $payment_type ."nn" ;

$headers = "From:" . $from;
$headers2 = "From:" . $to;
@mail($to,$subject,$message,$headers);
@mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.


}

else{
echo "something is wrong";
}

?>

html part is :

<!-- Form -->
<form name="package-payment" id="package-payment" method="post" action="" class="form-horizontal">
<div class="form-group" id="error-message">
</div>

<div class="col-sm-12">
<div class="col-sm-6">
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label" required>First Name</label>
<div class="col-sm-9">
<input class="form-control" id="first_name" name="first_name" required name="first_name" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Last Name</label>
<div class="col-sm-9">
<input class="form-control" id="last_name" name="last_name" required name="last_name" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Address 1</label>
<div class="col-sm-9">
<input class="form-control" id="address1" name="address1" required name="address1" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Address 2</label>
<div class="col-sm-9">
<input class="form-control" id="address2" name="address2"required name="address2" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">State</label>
<div class="col-sm-9">
<select id="state" name="state" class="form-control">
<option value="State" option=""></option>
<option value="Andaman and Nicobar Islands">Andaman and Nicobar Islands</option>
<option value="Andhra Pradesh">Andhra Pradesh</option>
<option value="Arunachal Pradesh">Arunachal Pradesh</option>
<option value="Assam">Assam</option>
<option value="Bihar">Bihar</option>
<option value="Chandigarh">Chandigarh</option>
<option value="Chhattisgarh">Chhattisgarh</option>
<option value="Dadra and Nagar Haveli">Dadra and Nagar Haveli</option>
<option value="Daman and Diu">Daman and Diu</option>
<option value="Delhi">Delhi</option>
<option value="Goa">Goa</option>
<option value="Gujarat">Gujarat</option>
<option value="Haryana">Haryana</option>
<option value="Himachal Pradesh">Himachal Pradesh</option>
<option value="Jammu and Kashmir">Jammu and Kashmir</option>
<option value="Jharkhand">Jharkhand</option>
<option value="Karnataka">Karnataka</option>
<option value="Kerala">Kerala</option>
<option value="Lakshadweep">Lakshadweep</option>
<option value="Madhya Pradesh">Madhya Pradesh</option>
<option value="Maharashtra">Maharashtra</option>
<option value="Manipur">Manipur</option>
<option value="Meghalaya">Meghalaya</option>
<option value="Mizoram">Mizoram</option>
<option value="Nagaland">Nagaland</option>
<option value="Orissa">Orissa</option>
<option value="Pondicherry">Pondicherry</option>
<option value="Punjab">Punjab</option>
<option value="Rajasthan">Rajasthan</option>
<option value="Sikkim">Sikkim</option>
<option value="Tamil Nadu">Tamil Nadu</option>
<option value="Tripura">Tripura</option>
<option value="Uttaranchal">Uttaranchal</option>
<option value="Uttar Pradesh">Uttar Pradesh</option>
<option value="West Bengal">West Bengal</option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">City</label>
<div class="col-sm-9">
<input class="form-control" id="city" name="city" required name="city" value="" type="text">
</div>
</div>

</div>

<div class="col-sm-6">

<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Pincode</label>
<div class="col-sm-9">
<input class="form-control" id="pincode" name="pincode" required name="pincode" maxlength="6" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Phone</label>
<div class="col-sm-9">
<input class="form-control" id="phone" name="phone" required name="phone" maxlength="12" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Email</label>
<div class="col-sm-9">
<input class="form-control" id="email" name="email" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Shipping</label>
<div class="col-sm-9">
<p class=" custom_form_fields_reeadonly"><b class="black-text"><i class="fas fa-rupee-sign"></i>. 199/-</b></p>
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Amount</label>
<div class="col-sm-9">
<p class=" custom_form_fields_reeadonly">MRP. <i class="fas fa-rupee-sign"></i>. <s>2,600/-</s> &nbsp; <b class="orange-text font-bolder">Offer <i class="fas fa-rupee-sign"></i>. 1,299/-</b></p>
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Payment</label>
<div class="col-sm-9 padd-top-05em">
<input value="cod" name="payment_type" id="cod" checked="checked" type="radio"><b class="padd-right-1em"> Cash on Delivery</b>
<input value="prepaid" name="payment_type" id="prepaid" type="radio"><b> Prepaid</b>
</div>
</div>

</div>
</div>
<div class="clearfix"></div>
<!-- <input name="gateway" type="hidden" id="gateway" />
<input type="hidden" name="ch" id="ch" value="" />
<input type="hidden" name="ssd" id="ssd" value=""/>
<input type="hidden" name="ocode" id="ocode" value=""/>
<input type="hidden" value="2922" id="page_id" name="page_id"/>
<input type="hidden" value="1498" id="amount" name="amount"/>
<input type="hidden" value="1498" id="payu_amount" name="payu_amount"/>
<input type="hidden" value="25" id="product_id" name="product_id"/>
<input type="hidden" value="fitband" id="product_info" name="product_info"/>-->
<div class="col-sm-12 text-center">
<button type="button" onclick="location.href = 'contact.php';" name="submit" value="submit" class="submitbtn">
<img src="images/button-buy-now.png" alt="submit" style="padding:18px 0px; width:190px;">

</button>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span class="brand-color"><b>Mail Us:</b></span><i class="font-bolder">support@neutrikart.com</i>&nbsp;
</div>
</form>

<!-- Icons -->
<div class="col-sm-12 icon-form-box black-text text-uppercase text-shadow-black">
<div class="col-sm-3 padd-top-1em">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="icon-number font-bolder">100%</td>
<td>risk-free purchase</td>
</tr>
</table>
</div>
<div class="col-sm-3 icon-number-top padd-top-1em">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="icon-number font-bolder">COD</td>
<td>cash-on delivery</td>
</tr>
</table>
</div>
<div class="col-sm-3 icon-number-top padd-top-1em">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="icon-number font-bolder">48-Hrs</td>
<td>money-back guarantee</td>
</tr>
</table>
</div>
<div class="col-sm-3 icon-number-top padd-top-1em animated fadeInDown">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="icon-number font-bolder">50%</td>
<td>Discounted Price</td>
</tr>
</table>
</div>
</div>
</div>
</div>

</div>
</div>
</div>









share|improve this question
















i have used the submit image between the button tag to send the data on my mail id but when i clicked on button it redirect to next page without filled the data into text boxes and not getting the mail on my mail id. php script also used for this. i have checked many times but not get success so please help me out how to validate & send the data on mail. ican't under stand where is issue :



enter code here
<?php



if(isset($_POST['submit'])){
$to = "sandeepdoliya110@gmail.com"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$state = $_POST['state'];
$city = $_POST['city'];
$pincode = $_POST['pincode'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$payment_type = $_POST['payment_type'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";

$message = $first_name . "n " . $last_name . " n" .$address1. "n " .$address2 . "n " . $state . "n " . $city . "n " . $pincode . " n" . $phone . "n " . $email . "n " . $payment_type ."nn" ;
$message2 = "Thank you for showing interest. We will Contact You Soon " . $first_name . "n " . $last_name . " n" .$address1. "n " .$address2 . "n " . $state . "n " . $city . "n " . $pincode . " n" . $phone . "n " . $email . "n " . $payment_type ."nn" ;

$headers = "From:" . $from;
$headers2 = "From:" . $to;
@mail($to,$subject,$message,$headers);
@mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.


}

else{
echo "something is wrong";
}

?>

html part is :

<!-- Form -->
<form name="package-payment" id="package-payment" method="post" action="" class="form-horizontal">
<div class="form-group" id="error-message">
</div>

<div class="col-sm-12">
<div class="col-sm-6">
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label" required>First Name</label>
<div class="col-sm-9">
<input class="form-control" id="first_name" name="first_name" required name="first_name" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Last Name</label>
<div class="col-sm-9">
<input class="form-control" id="last_name" name="last_name" required name="last_name" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Address 1</label>
<div class="col-sm-9">
<input class="form-control" id="address1" name="address1" required name="address1" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Address 2</label>
<div class="col-sm-9">
<input class="form-control" id="address2" name="address2"required name="address2" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">State</label>
<div class="col-sm-9">
<select id="state" name="state" class="form-control">
<option value="State" option=""></option>
<option value="Andaman and Nicobar Islands">Andaman and Nicobar Islands</option>
<option value="Andhra Pradesh">Andhra Pradesh</option>
<option value="Arunachal Pradesh">Arunachal Pradesh</option>
<option value="Assam">Assam</option>
<option value="Bihar">Bihar</option>
<option value="Chandigarh">Chandigarh</option>
<option value="Chhattisgarh">Chhattisgarh</option>
<option value="Dadra and Nagar Haveli">Dadra and Nagar Haveli</option>
<option value="Daman and Diu">Daman and Diu</option>
<option value="Delhi">Delhi</option>
<option value="Goa">Goa</option>
<option value="Gujarat">Gujarat</option>
<option value="Haryana">Haryana</option>
<option value="Himachal Pradesh">Himachal Pradesh</option>
<option value="Jammu and Kashmir">Jammu and Kashmir</option>
<option value="Jharkhand">Jharkhand</option>
<option value="Karnataka">Karnataka</option>
<option value="Kerala">Kerala</option>
<option value="Lakshadweep">Lakshadweep</option>
<option value="Madhya Pradesh">Madhya Pradesh</option>
<option value="Maharashtra">Maharashtra</option>
<option value="Manipur">Manipur</option>
<option value="Meghalaya">Meghalaya</option>
<option value="Mizoram">Mizoram</option>
<option value="Nagaland">Nagaland</option>
<option value="Orissa">Orissa</option>
<option value="Pondicherry">Pondicherry</option>
<option value="Punjab">Punjab</option>
<option value="Rajasthan">Rajasthan</option>
<option value="Sikkim">Sikkim</option>
<option value="Tamil Nadu">Tamil Nadu</option>
<option value="Tripura">Tripura</option>
<option value="Uttaranchal">Uttaranchal</option>
<option value="Uttar Pradesh">Uttar Pradesh</option>
<option value="West Bengal">West Bengal</option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">City</label>
<div class="col-sm-9">
<input class="form-control" id="city" name="city" required name="city" value="" type="text">
</div>
</div>

</div>

<div class="col-sm-6">

<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Pincode</label>
<div class="col-sm-9">
<input class="form-control" id="pincode" name="pincode" required name="pincode" maxlength="6" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Phone</label>
<div class="col-sm-9">
<input class="form-control" id="phone" name="phone" required name="phone" maxlength="12" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Email</label>
<div class="col-sm-9">
<input class="form-control" id="email" name="email" value="" type="text">
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Shipping</label>
<div class="col-sm-9">
<p class=" custom_form_fields_reeadonly"><b class="black-text"><i class="fas fa-rupee-sign"></i>. 199/-</b></p>
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Amount</label>
<div class="col-sm-9">
<p class=" custom_form_fields_reeadonly">MRP. <i class="fas fa-rupee-sign"></i>. <s>2,600/-</s> &nbsp; <b class="orange-text font-bolder">Offer <i class="fas fa-rupee-sign"></i>. 1,299/-</b></p>
</div>
</div>
<div class="form-group">
<label for="inputname" class="col-sm-3 control-label">Payment</label>
<div class="col-sm-9 padd-top-05em">
<input value="cod" name="payment_type" id="cod" checked="checked" type="radio"><b class="padd-right-1em"> Cash on Delivery</b>
<input value="prepaid" name="payment_type" id="prepaid" type="radio"><b> Prepaid</b>
</div>
</div>

</div>
</div>
<div class="clearfix"></div>
<!-- <input name="gateway" type="hidden" id="gateway" />
<input type="hidden" name="ch" id="ch" value="" />
<input type="hidden" name="ssd" id="ssd" value=""/>
<input type="hidden" name="ocode" id="ocode" value=""/>
<input type="hidden" value="2922" id="page_id" name="page_id"/>
<input type="hidden" value="1498" id="amount" name="amount"/>
<input type="hidden" value="1498" id="payu_amount" name="payu_amount"/>
<input type="hidden" value="25" id="product_id" name="product_id"/>
<input type="hidden" value="fitband" id="product_info" name="product_info"/>-->
<div class="col-sm-12 text-center">
<button type="button" onclick="location.href = 'contact.php';" name="submit" value="submit" class="submitbtn">
<img src="images/button-buy-now.png" alt="submit" style="padding:18px 0px; width:190px;">

</button>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span class="brand-color"><b>Mail Us:</b></span><i class="font-bolder">support@neutrikart.com</i>&nbsp;
</div>
</form>

<!-- Icons -->
<div class="col-sm-12 icon-form-box black-text text-uppercase text-shadow-black">
<div class="col-sm-3 padd-top-1em">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="icon-number font-bolder">100%</td>
<td>risk-free purchase</td>
</tr>
</table>
</div>
<div class="col-sm-3 icon-number-top padd-top-1em">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="icon-number font-bolder">COD</td>
<td>cash-on delivery</td>
</tr>
</table>
</div>
<div class="col-sm-3 icon-number-top padd-top-1em">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="icon-number font-bolder">48-Hrs</td>
<td>money-back guarantee</td>
</tr>
</table>
</div>
<div class="col-sm-3 icon-number-top padd-top-1em animated fadeInDown">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="icon-number font-bolder">50%</td>
<td>Discounted Price</td>
</tr>
</table>
</div>
</div>
</div>
</div>

</div>
</div>
</div>






javascript php html






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 4 at 6:43









Akash

642215




642215










asked Jan 4 at 5:02









sandeepsandeep

6




6













  • The redirect happens because you explicitely are doing so: <button type="button" onclick="location.href = 'contact.php';" name="submit" value="submit" class="submitbtn">" Remove the onclick attribute and use a button type of submit.

    – Teemu
    Jan 4 at 5:28



















  • The redirect happens because you explicitely are doing so: <button type="button" onclick="location.href = 'contact.php';" name="submit" value="submit" class="submitbtn">" Remove the onclick attribute and use a button type of submit.

    – Teemu
    Jan 4 at 5:28

















The redirect happens because you explicitely are doing so: <button type="button" onclick="location.href = 'contact.php';" name="submit" value="submit" class="submitbtn">" Remove the onclick attribute and use a button type of submit.

– Teemu
Jan 4 at 5:28





The redirect happens because you explicitely are doing so: <button type="button" onclick="location.href = 'contact.php';" name="submit" value="submit" class="submitbtn">" Remove the onclick attribute and use a button type of submit.

– Teemu
Jan 4 at 5:28












1 Answer
1






active

oldest

votes


















0














Since you are submitting to same page, remove the



action="" 


on your form.



Change submit button type from
type="button"
To
type="submit"






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54033338%2fhow-to-validate-all-text-or-send-the-data-by-submit-image-in-html-button-tag%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Since you are submitting to same page, remove the



    action="" 


    on your form.



    Change submit button type from
    type="button"
    To
    type="submit"






    share|improve this answer




























      0














      Since you are submitting to same page, remove the



      action="" 


      on your form.



      Change submit button type from
      type="button"
      To
      type="submit"






      share|improve this answer


























        0












        0








        0







        Since you are submitting to same page, remove the



        action="" 


        on your form.



        Change submit button type from
        type="button"
        To
        type="submit"






        share|improve this answer













        Since you are submitting to same page, remove the



        action="" 


        on your form.



        Change submit button type from
        type="button"
        To
        type="submit"







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 4 at 5:22









        JoshuaJoshua

        1275




        1275
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54033338%2fhow-to-validate-all-text-or-send-the-data-by-submit-image-in-html-button-tag%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas