Php 如何对已发布的输入变量进行排序和发送电子邮件

Php 如何对已发布的输入变量进行排序和发送电子邮件,php,html,Php,Html,我有一个post表单,我从用户输入中收集了一些数据。当所有数据发布后,我想通过电子邮件向用户和我自己确认。我还希望该页面重定向到一个单独的页面,将重新显示输入的数据返回给用户。以下是我的问题 通过电子邮件发送我的所有数据的最佳做法是什么?使用isset()等待填写完所有内容,然后使用mail()函数,这是一个坏主意吗 如何使“体力活动准备度问卷”下的是/否无线电输入彼此相邻,而不是相互重叠 在“普通与医疗问卷”下,如果用户为“职业问题””选择“否”,是否可以取消/隐藏以下5个问题?(我想用“职业

我有一个post表单,我从用户输入中收集了一些数据。当所有数据发布后,我想通过电子邮件向用户和我自己确认。我还希望该页面重定向到一个单独的页面,将重新显示输入的数据返回给用户。以下是我的问题

  • 通过电子邮件发送我的所有数据的最佳做法是什么?使用isset()等待填写完所有内容,然后使用mail()函数,这是一个坏主意吗

  • 如何使“体力活动准备度问卷”下的是/否无线电输入彼此相邻,而不是相互重叠

  • 在“普通与医疗问卷”下,如果用户为“职业问题””选择“否”,是否可以取消/隐藏以下5个问题?(我想用“职业问题””作为切换键)

  • 该网站位于以下位置:

    --忽略php代码,这是不相关的-- 以下是代码(跳到html部分):

    
    脂肪损失计算器
    桌子{
    字体大小:15px;
    字体系列:“PT Sans”,无衬线;
    背景色:#FFFFFF;
    }
    tr.spaceUnder>td
    {
    填充:0em 1em 1em 0em;
    }
    p、 党卫军{
    字体大小:30px;
    文本对齐:居中
    }
    输入{
    右边距:5px;
    左边距:5px;
    }
    健康标题


    描述在这里 名字:
    以这种不安全的方式发送医疗数据是一种不好的做法,在某些司法管辖区可能是非法的。您有什么建议吗?我该如何保护它@dagon没有什么东西应该在一封你不会写在明信片外面的电子邮件中。您应该安全地存储和访问它(它们是非常大的主题,超出了本文的范围)
    <?php
    /*
    Template Name: healthquestions
    */
    ?>
    <?php get_header(); ?>
    <?php $al_options = get_option('al_general_settings');?>
    <!-- Title -->
    
    <div class="box pt20">
    
        <!-- Title -->
    
        <div class="headertext">
    
            <?php the_title() ?>
    
            <?php $headline = get_post_meta($post->ID, "_headline", $single = false);?>
    
            <?php if(!empty($headline[0]) ):?>
    
                <span><?php echo $headline[0] ?></span>
    
            <?php endif?>
    
        </div>
    
        <div class="clearsmall"></div>
    
    
    
        <!-- Promo text -->
    
        <?php $promo = get_post_meta($post->ID, "_promo", $single = false);?>
    
        <?php if(!empty($promo[0]) ):?>
    
           <div class="calloutcontainer">
    
                <div class="container_12">
    
                    <div class="grid_12">            
    
                        <?php echo do_shortcode($promo[0]);?>
    
                    </div>
    
                </div>
    
            </div>    
    
        <?php endif?>
    
        <div class="container_12">
    
            <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    
                <?php the_content(); ?>
    
            <?php endwhile; ?>
        </div>
    </div>
    <!-------PHP CODE------------------------------>
    <?php
    $goalbodyfatv = "";
    $weightv = "";
    $bodyfatv = "";
    $answer="";
    if(isset($_POST['weightv']) && isset($_POST['bodyfatv']) && isset($_POST['goalbodyfatv'])) {
    
        $weightv = $_POST['weightv'];
        $bodyfatv = $_POST['bodyfatv'];
        $goalbodyfatv = $_POST['goalbodyfatv'];
        $weightkg = $weightv/2.2;
        $answer = ($weightv * $bodyfatv)-($weightv * $goalbodyfatv);
    
    }
    ?>
    <!----------CSS CODE-------------------------->
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
    <title>Fat Loss Calculator</title>
    <style>
      table {
        font-size:15px;
        font-family: 'PT Sans', sans-serif;
        background-color:#FFFFFF;
      }
    tr.spaceUnder > td
    {
      padding:0em 1em 1em 0em;
    
    }
    p.ss {
        font-size:30px; 
        text-align:center
    }
    input {
    margin-right:5px;
    margin-left:5px;
    }
    
    </style>
    </head>
    <body>
    <div class="box pt20">
    <p class="ss">health title</p><br>
    <table width='80%' style="margin: 0 auto;">
        <tr class="spaceUnder">
        <td colspan="4">
    description here
        </td>
        </tr>
    </table> 
    
    <!-------------HTML CODE STARTS HERE--------------------->
    <!-----------Contact information------------------>
    <form method='post' action=''>
    <table width='80%' style="margin: 0 auto;">
        <tr class="spaceUnder">
            <td colspan='2'>First name: <input type='text' name='fname' value="<?php echo $fname; ?>"/>&nbsp; &nbsp;Last name<input type='text' name='lname' value="<?php echo $lname; ?>"/>&nbsp;&nbsp;Email: <input type='text' name='email' size='16' value="<?php echo $email; ?>"/></td>
        </tr>
        <tr class="spaceUnder">
            <td colspan='2'>Age: <input type='text' name='age' size='6' value="<?php echo $age; ?>"/> Years &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            &nbsp;&nbsp;&nbsp;&nbsp;Height: <input type='text' name='height' size='6' value="<?php echo $heightft; ?>"/> ft. <input type='text' name='age' size='5' value="<?php echo $heightin; ?>"/> in.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Weight: <input type='text' name='weight' size='6' value="<?php echo $weight; ?>"/> lbs. </td>
        </tr>
        <tr><td>&nbsp;</td></tr>
    </table>
    <!----------------Physical/Activity Readiness--------------------->
    <table width='80%' style="margin: 0 auto;">
        <tr><td>&nbsp;</td></tr>
        <tr class="spaceUnder">
        <td colspan='2'><p style="font-size:25px"><strong>Physical Activity Readiness Questionnaire</strong></p></td>
        </tr>
        <tr class="spaceUnder">
        <td colspan='2'>1. Has your doctor ever said that you have a heart condition and that you should
    only perform physical activity recommended by a doctor?</td>
        <td>
        <input type='radio' name='q1' value='yes'>Yes
        <input type='radio' name='q1' value='no'>No
        </td>
        </tr>
        <tr class="spaceUnder">
        <td colspan='2'>2. Do you feel pain in your chest when you perform physical activity?</td>
        <td>
        <input type='radio' name='q2' value='yes'>Yes
        <input type='radio' name='q2' value='no'>No
        </td>
        </tr>
            <tr class="spaceUnder">
        <td colspan='2'>3. In the past month, have you had chest pain when you were not performing any
    physical activity?</td>
        <td>
        <input type='radio' name='q3' value='yes'>Yes
        <input type='radio' name='q3' value='no'>No
        </td>
        </tr>
            <tr class="spaceUnder">
        <td colspan='2'>4. Do you lose your balance because of dizziness or do you ever lose
    consciousness?</td>
        <td>
        <input type='radio' name='q4' value='yes'>Yes
        <input type='radio' name='q4' value='no'>No
        </td>
        </tr>
            <tr class="spaceUnder">
        <td colspan='2'>
    5. Do you have a bone or joint problem that could be made worse by a change in
    your physical activity?</td>
        <td>
        <input type='radio' name='q5' value='yes'>Yes
        <input type='radio' name='q5' value='no'>No
        </td>
        </tr>
            <tr class="spaceUnder">
        <td colspan='2'>
    6. Is your doctor currently prescribing any medication for your blood pressure or
    for a heart condition?</td>
        <td>
        <input type='radio' name='q6' value='yes'>Yes
        <input type='radio' name='q6' value='no'>No
        </td>
        </tr>
                <tr class="spaceUnder">
        <td colspan='2'>
    7. Do you know of any other reason why you should not engage in physical
    activity?</td>
        <td>
        <input type='radio' name='q7' value='yes'>Yes
        <input type='radio' name='q7' value='no'>No
        </td>
        </tr>  
        <tr><td>&nbsp;</td></tr>
        <tr><td width='100%'>**********If you have answered “Yes” to one or more of the above questions, consult your physician before
    engaging in physical activity. Tell your physician which questions you answered “Yes” to. After a
    medical evaluation, seek advice from your physician on what type of activity is suitable for your
    current condition.</td></tr>
    </table>
    <!----------------------General&Med---------------------------------->
    <table width='80%' style="margin: 0 auto;">
    <tr><td>&nbsp;</td></tr>
        <tr class='spaceUnder'><td><p style="font-size:25px"><strong>General & Medical Questionnaire</strong></p></td></tr>
    
        <tr class='spaceUnder'><td><strong>Occupational Questions</strong>
        <input type='radio' name='oyesno' value='yes'>Yes
        <input type='radio' name='oyesno' value='no'>No
        </td></tr>
        <tr class='spaceUnder'><td colspan='2'>1. What is your current occupation?<input type='text' name='occ1' value="<?php echo $occ1; ?>"/></td></tr>
        <tr class='spaceUnder'><td>2. Does your occupation require extended periods of sitting?    
        <input type='radio' name='o2' value='yes'>Yes
        <input type='radio' name='o2' value='no'>No</td></tr>
        <tr class='spaceUnder'><td colspan='2'>3. Does your occupation require extended periods of repetitive movements? (if yes, please explain) <input type='text' name='occ3' size='20' value="<?php echo $occ3; ?>"/></td><td>
        <input type='radio' name='o3' value='yes'>Yes
        <input type='radio' name='o3' value='no'>No
        </td></tr>
        <tr class='spaceUnder'><td>4. Does your occupation require you to wear shoes with a heel (dress shoes)?
        <input type='radio' name='o4' value='yes'>Yes
        <input type='radio' name='o4' value='no'>No</td></tr>
        <tr class='spaceUnder'><td>5. Does your occupation cause you anxiety (mental stress)?
        <input type='radio' name='o5' value='yes'>Yes
        <input type='radio' name='o5' value='no'>No</td></tr>    
    
    <!------------Recreational Questions------------------------------>
    <tr><td>&nbsp;</td></tr>
    
        <tr class='spaceUnder'><td><strong>Recreational Questions</strong>
        <input type='radio' name='ryesno' value='yes'>Yes
        <input type='radio' name='ryesno' value='no'>No
        </td></tr>
        <tr class='spaceUnder'><td colspan='2'>1. Do you partake in any recreational activities (golf, tennis, skiing, etc.)? (if yes, please explain) <input type='text' name='rec1' size='20' value="<?php echo $rec1; ?>"/></td><td>
        <input type='radio' name='r1' value='yes'>Yes
        <input type='radio' name='r1' value='no'>No
        </td></tr>
        <tr class='spaceUnder'><td colspan='2'>2. Do you have any hobbies (reading, gardening, working on cars, exploring the Internet, etc.)? (if yes, please explain) <input type='text' name='rec2' size='20' value="<?php echo $rec2; ?>"/></td><td>
        <input type='radio' name='r2' value='yes'>Yes
        <input type='radio' name='r2' value='no'>No
        </td></tr>    
    <!-------------Medical Questions--------------------------->
    <tr><td>&nbsp;</td></tr>
    
        <tr class='spaceUnder'><td><strong>Medical Questions</strong>
        <input type='radio' name='myesno' value='yes'>Yes
        <input type='radio' name='myesno' value='no'>No
        </td></tr>
        <tr class='spaceUnder'><td colspan='2'>1. Have you ever had any pain or injuries (ankle, knee, hip, back, shoulder, etc.)? (if yes, please explain) <input type='text' name='med1' size='20' value="<?php echo $med1; ?>"/></td><td>
        <input type='radio' name='m1' value='yes'>Yes
        <input type='radio' name='m1' value='no'>No
        </td></tr>
        <tr class='spaceUnder'><td colspan='2'>2. Have you ever had surgeries? (if yes, please explain) <input type='text' name='med2' size='20' value="<?php echo $med2; ?>"/></td><td>
        <input type='radio' name='m2' value='yes'>Yes
        <input type='radio' name='m2' value='no'>No
        </td></tr>
        <tr class='spaceUnder'><td colspan='2'>3. Has a medical doctor ever diagnosed you with a chronic disease such as coronary heart disease, coronary artery disease, hypertension (high blood pressure), high cholesterol, or diabetes? (if yes, please explain) <input type='text' name='med3' size='20' value="<?php echo $med3; ?>"/></td><td>
        <input type='radio' name='m3' value='yes'>Yes
        <input type='radio' name='m3' value='no'>No
        </td></tr>
        <tr class='spaceUnder'><td colspan='2'>4. Are you currently taking any medication? (if yes, please list) <input type='text' name='med4' size='20' value="<?php echo $med4; ?>"/></td><td>
        <input type='radio' name='m4' value='yes'>Yes
        <input type='radio' name='m4' value='no'>No
        </td></tr>        
    
    <!--------------------submit button-------------------------------->
        <tr><td>&nbsp;</td></tr>
        <tr class="spaceUnder">
            <td colspan="2"><input type='submit' class="button highlight small" value='Submit'/></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        <tr><td>&nbsp;</td></tr>
    </table>
    </form>
    </div>
    </body>
    </html>  
    
    <?php get_footer(); ?>