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

时间:2014-03-27 21:34:10

标签: php html

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

  1. 通过电子邮件发送我的所有数据的最佳做法是什么?使用 isset()等待所有这些内容填写完 mail()功能是不是一个坏主意?

  2. 如何将“身体活动准备问卷”下的是/否收音机输入显示在彼此旁边而不是彼此叠加?

  3. 在'一般&医疗调查问卷',如果用户为“职业问题”选择“”,是否可以使以下5个问题无效/变暗? (我希望'职业问题'作为切换)

  4. 该网站位于:http://macrorevolution.com/health/

    - 忽略php代码,这是无关紧要的 - 这是代码(跳到html部分):

    <?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(); ?>
    

0 个答案:

没有答案