Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: Php email form

  1. #1
    New Coder
    Join Date
    Jan 2009
    Posts
    46
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Php email form

    Okay simple question

    What would the PHP CODE FOR THE FOLLOWING HTML:


    Code:
     <select name="choice">
          <option selected="selected" label="Eventtype" value="Eventtype">
          Select Event Type
          </option>
         
            <option label="Birthday Party" value="Birthday Party">Birthday Party
            </option>
            <option label="Block Party" value="Block Party">Block Party
            </option>
            <option label="Barmitfa" value="Barmitfa">Barmitfa
            </option>
            <option label="Corporate Event" value="Corporate Event">Corporate Event
               </option>
               <option label="Day Care Centers" value="Day Care Centers">Day Care Centers
               </option>
               <option label="Graduation Party" value="Graduation Party">Graduation Party
               </option>
                 <option label="Private Event" value="Private Event">Private Event
               </option>
                 <option label="Wedding Event" value="Wedding Event">Wedding Event
               </option>
                <option label="Other" value="Other">Other
               </option>
               </select>
        <br >
        <br />
        
        
        <select name="choicetwo">
          <option selected="selected" label="Number of Children" value="Number of Children">
          Number of Children
          </option>
         
            <option label="12 and Under" value="12 AND Under">12 and Under
            </option>
            <option label="13 - 25" value="13-25">13 - 25
            </option>
            <option label="25 - 50" value="25 - 50">25 - 50
            </option>
            <option label="50 Plus" value="50 Plus">50 Plus
               </option>
               </select>
        </fieldset>
    RIGHT NOW MY PHP CODE (NOT WORKING HOWEVER)

    PHP Code:
    $choice $_POST['choice']
    $choicetwo $_POST['choicetwo']; 
    i guess my php form is wrong, i would appreciate any help.

    thank you in advance for your time.

  • #2
    New to the CF scene
    Join Date
    Aug 2009
    Location
    Cincinnati, Ohio
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You will need a form and a method of submitting the form in order for you to be able to access the selected values.

  • #3
    New Coder
    Join Date
    Jan 2009
    Posts
    46
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I think you misunderstand my question, i understand i need submitt code

    i want to know if the following snipet of code is wrong.

    PHP Code:
    $choice $_POST['choice'
    $choicetwo $_POST['choicetwo']; 

  • #4
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    that is correct, also make sure your form method is set to post.

  • #5
    New to the CF scene
    Join Date
    Aug 2009
    Location
    Cincinnati, Ohio
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by adolph0034 View Post
    I think you misunderstand my question, i understand i need submitt code

    i want to know if the following snipet of code is wrong.

    PHP Code:
    $choice $_POST['choice'
    $choicetwo $_POST['choicetwo']; 
    It appears you have neglected to include PHP tags.. That would be important. But no, that code in and of itself looks fine. $choice will contain the value of the selected option for the choice select, $choicetwo will contain the value of the choicetwo select.

    Is this PHP on the same page or a separate page? If the same, you need to check that the form was submitted before attempting to retrieve the values.

    PHP Code:
    if (isset($_POST['choice']))
    {
       
    // Your PHP here.


  • #6
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    PHP Code:
    <?php
        
    if(isset($_POST['submitForm']))
        {
            if (isset(
    $_POST['choice'])) 
            { 
                echo 
    $_POST['choice']."<br />";
            }
            if (isset(
    $_POST['choicetwo'])) 
            { 
                echo 
    $_POST['choicetwo']."<br />";
            }
        }
    ?>
    <form method="post" action="index.php">
        <fieldset>
            <select name="choice">
                <option selected="selected" label="Eventtype" value="Eventtype">Select Event Type</option>
                <option label="Birthday Party" value="Birthday Party">Birthday Party</option>
                <option label="Block Party" value="Block Party">Block Party</option>
                <option label="Barmitfa" value="Barmitfa">Barmitfa</option>
                <option label="Corporate Event" value="Corporate Event">Corporate Event</option>
                <option label="Day Care Centers" value="Day Care Centers">Day Care Centers</option>
                <option label="Graduation Party" value="Graduation Party">Graduation Party</option>
                <option label="Private Event" value="Private Event">Private Event</option>
                <option label="Wedding Event" value="Wedding Event">Wedding Event</option>
                <option label="Other" value="Other">Other</option>
            </select>
            <br /><br />
            <select name="choicetwo">
                <option selected="selected" label="Number of Children" value="Number of Children">Number of Children</option>
                <option label="12 and Under" value="12 AND Under">12 and Under</option>
                <option label="13 - 25" value="13-25">13 - 25</option>
                <option label="25 - 50" value="25 - 50">25 - 50</option>
                <option label="50 Plus" value="50 Plus">50 Plus</option>
            </select>
        </fieldset>
        <input type="submit" name="submitForm" value="submit" />
    </form>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •