访问除单选和复选框值以外的任何值


Accessing any values other than the radio and checkbox values

我遇到的问题是我的值没有通过我的PHP代码。我将php文件路径名放在下面表单的操作部分,并将验证Javascript代码附加到提交按钮。我在php中唯一可以访问的值是复选框和单选值。

* * * * * * * * * * HTML * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

    <div id="right-cont">
        <form name = "contact_Us" action="http://nova.umuc.edu/cgi-bin/cgiwrap/ct386a28/eContact.php" method = "post"> 
            <div id="style2">
                <p>Please enter contact information below:</p>                                 
            </div>
            <div class="style7">
                <label>First Name: </label>
                &nbsp;<br /><input type="text" id="firstName" tabindex="1" 
                    style="width: 176px" />
            </div>  
            <div class="style7">
                <label>Middle Name: </label>
                &nbsp;<br /><input type="text" id ="middleName" tabindex="2" 
                    style="width: 176px" />
            </div>
            <div class="style7">
                <label>Last Name: </label>
                &nbsp;<br /><input type="text" id ="lastName" tabindex="3" 
                    style="width: 176px" />
            </div>
            <div class =" buttons">
             <input type="submit" value="SUBMIT" onclick = "return validate()"/><input type="reset" value="CLEAR"/> <br />                
            </div>     
        </form>
     </div> 

* * * * * * * * * * * * * * * * * PHP代码 * * * * * * * * * * * * * * * * * * * *

       <?= '<' . '?xml version="1.0" encoding="utf-8"?' . '>' ?>
       <?php     
         $fName = $_POST["firstName"];
         $lName = $_POST["lastName"];
         $mName = $_POST["middleName"];
         $email = $_POST["email"];
         $phone = $_POST["phone_Num"];
         $comment = $_POST["comment"];
         $phone_Type = $_POST["phone"];
         $specialty_Type = $_POST["specType"];      
       ?>
       <div id="right-cont">       

            <div style="style8">
                <h2>The Below Information has been sent to Pierre Law, LLC:</h2>                                   
            </div>
            <div class="style7">
                <label>First Name: </label>
                <?php echo $fName; ?>
            </div>  
            <div class="style7">
                <label>Middle Name: </label>
                <?php echo $mName;?>
            </div>
            <div class="style7">
                <label>Last Name: </label>
                <?php echo $lName;?>
            </div>
        </div>        

您的输入标签缺少name属性。请求数据以"NAME=VALUE"的形式发送。您只放置了元素的id。您可以在输入元素中使用与name相同的id属性值,这些值将在PHP代码中被接收

应该是这样的:

<div class="style7">
   <label for="firstName">First Name: </label>
   <input type="text" name="firstName" id="firstName" tabindex="1" />
</div> 

输入宽度应该来自.style7 input{} css规则和,停止使用<br />&nbsp;进行格式化,这就是css的作用。

注:CSS类的名称应该描述标签的内容("article"、"important"等)。form是一个字段列表