duanchan9354 2015-12-22 14:38
浏览 17

通过php发送选择表单“选定的详细信息”

I created a form with a select drop-down list that effect the other one. I mean, the choice in the first drop-down list effect the data in the other drop-down list. I did it using Json and jQuery.

The problem is that I can not get the dorm details by email. it doesn't work.

The json file is:

{
"health":[
    ["1","Biorgonomi"],
    ["2","Diet and Weight Loss"],
    ["3","Lasik"],
    ["4","Smoking Cessation"],
    ["5","Body Lines"],
    ["6","Treatment of hemorrhoids"],
    ["7","Treatment of snoring"],
    ["8","personal trainer"],
    ["9","Gyms"],
    ["10","hearing aid"],
    ["11","Nail Fungus"],
    ["12","Pilates"]
],
"mercedes":[
    ["13","class A"],
    ["14","class B"],
    ["15","class C"],
    ["16","class E"]
],
"audi":[
    ["17","a3"],
    ["18","a4"],
    ["19","a5"],
    ["20","a6"]
],
"volswagen":[
    ["21","polo"],
    ["22","golf"],
    ["23","cady"]
]
}

The jQuery file is:

jQuery().ready(function(){
var tabMarque=[];
$.getJSON('http://thewebsite.com/wp-content/themes/Avada/js/healthandbeauty/healthandbeautydetails.json', function(data) {
    $.each(data, function(index, val) {
         tabMarque[index]=val;
    });
});

$('#Marque').change(function(event) {
    $marque=$(this).val();
    $htmlOption='<option value="0">Choix du serie</option>';
    if($marque!=0)
    {
        $.each(tabMarque[$marque], function(key, value) {
             $htmlOption+='<option value="'+value[0]+'">'+value[1]+'</option>';
        });
    }
    $('#Serie').html($htmlOption);
});
});

The html form :

<form action="http://thewebsite.com/wp-content/themes/Avada/js/healthandbeauty/js/send_to_email.php" method="get">
    <select id="Marque">
                <option value="0">CAR COMPANY</option>
                <option value="health">health</option>
                <option value="mercedes">mercedes</option>
                <option value="audi">audi</option>
                <option value="volswagen">volswagen</option>
            </select>
            <select id="Serie"></select>

<select id="Location">
                <option value="0">Your Location</option>
                <option value="Elondon">East London</option>
                <option value="nlondon">North London</option>
                <option value="wlondon">West London</option>
                <option value="slondon">South London</option>
            </select>
<input name="vemail" placeholder="Your Email" type="text" value="">
<input id="send" name="submit" type="submit" value="Send">

</form>

The php file that send the details to my email :

<?php
if(isset($_POST["submit"])){
// Checking For Blank Fields..
if($_POST["Marque"]==""||$_POST["vemail"]==""||$_POST["Serie"]==""||$_POST["Location"]==""){
echo "Fill All Fields..";
}else{
// Check if the "Sender's Email" input field is filled out
$email=$_POST['vemail'];
// Sanitize E-mail Address
$email =filter_var($email, FILTER_SANITIZE_EMAIL);
// Validate E-mail Address
$email= filter_var($email, FILTER_VALIDATE_EMAIL);
if (!$email){
echo "Invalid Sender's Email";
}
else{
$subject = $_POST['Marque'];
$message = $_POST['Serie'];
$location= $_POST['Location'];
$headers = 'From:'. $email2 . "
"; // Sender's Email
$headers .= 'Cc:'. $email2 . "
"; // Carbon copy to Sender
// Message lines should not exceed 70 characters (PHP rule), so wrap it
$message = wordwrap($message, 70);
// Send Mail By PHP Mail Function
mail("myemail@xyz.com", $subject, $message, $headers, $location);
echo "Your mail has been sent successfuly ! Thank you for your feedback";
}
}
}
?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题