开发者

Accessing any values other than the radio and checkbox values

开发者 https://www.devze.com 2023-03-01 12:20 出处:网络
The problem that I am having is that my values aren\'t coming through with my PHP code.I put the php file pathname in the action part of the form below as well as attach the validation Javascript code

The problem that I am having is that my values aren't coming through with my PHP code. I put the php file pathname in the action part of the form below as well as attach the validation Javascript code to the submit button. The only values that I have access to in my php are the checkbox and radio values.

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

    <div id="right-cont">

        <form name = "contact_Us" action="http://no开发者_运维技巧va.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 CODE********************

       <?= '<' . '?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>        


Your input tags are missing the name attribute. The request data is sent for in form of "NAME=VALUE". You have only put ids of elements. You can use same value of id attribute as name in your input elements and the values will be received in PHP code


This is how it should look like :

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

The width of input should come from .style7 input{} css rule and please , stop using <br /> and &nbsp; for formating, thats what css is for.

P.S. the name of the css class should describe the content of the tag ( 'article' , 'important' , etc. ). And form is a list of fields.

0

精彩评论

暂无评论...
验证码 换一张
取 消