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 11 of 11
  1. #1
    Regular Coder
    Join Date
    Apr 2004
    Location
    Philadelphia
    Posts
    241
    Thanks
    2
    Thanked 5 Times in 5 Posts

    List/Radio Form Help

    Okay...I've been working on some automatic mail PHP forms...now I'm stuck...
    How do I make it so a listbox answer is e-mailed...here's what I mean

    Here's HTML
    <form action="quiz.php" method="post">
    <font face="Tunga"><b>Fill out the following questions honestly and arccuratly for <i>best</i> results</b>
    <br><br>
    Name: &nbsp;&nbsp;<input type="text" name="name" size="25" maxlength="256">
    <br>
    Email: <input type="text" name="email" size="25" maxlength="256">
    <br><br>
    and our good friend Mr. PHP
    <html>
    <?php
    mail(
    "A n t h o n y H u r s t@balhsnfjnsd.com"
    "Love Quiz!"
    "{$_POST['name']} ({$_POST['email']})has filled out a love quiz! Here are their answers!";
    ?>
    </html>
    now wut would be the $_POST['????'] for a listbox or radio button or text box????

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i don't understand the question.

    can you explain some more?
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #3
    Regular Coder
    Join Date
    Apr 2004
    Location
    Philadelphia
    Posts
    241
    Thanks
    2
    Thanked 5 Times in 5 Posts
    Okay here's an example coding that is actually in affect...

    <form action="updates.php" method="post">
    Name: &nbsp;&nbsp;<input type="text" name="name" size="20" maxlength="100"><br>
    E-mail: &nbsp;<input type="text" name="email" size="20" maxlength="100"><br>
    <input type="submit" value="Get Updates!">
    See how in that form name="email" and name="email...
    it makes it a variable for the php...
    mail(
    $_POST['email'],
    "Welcome {$_POST['name']}",
    "Just e-mailing you to inform you that you will recieve site updates
    \n Thanks for Joining,
    \n JAcostuff.com
    ");
    ...see how the $_POST['email'] $_POST['name']
    make it connected from the previous page's name="email" name="name"

    Now how do I "Connect it" with other form types such as radio buttons, list boxes, text area's etc.
    Last edited by As5a5sIn5; 05-20-2004 at 07:38 AM.

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You need to loop thropugh the formcollection. Like

    foreach ($_POST as $var=>$value){
    }

    If you just wan't to print the answers, then you need to be able to filter them out. So all formfields that contain an answer should have the same first x letters in there name. Like answ1, answ2, answ3 etc.
    None of the non-answer formfields should have this first 'answ' at the start of there name.

    Then you can go

    PHP Code:
    $answers='';
    foreach (
    $_POST as $var=>$value){
       if (
    substr($var04)=='answ'){
          
    $answers .= ('Answer to question ' substr($var,4) . ': ' $value '<br />') ;
       }

    $answer will then contain all answers
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #5
    Regular Coder
    Join Date
    Apr 2004
    Location
    Philadelphia
    Posts
    241
    Thanks
    2
    Thanked 5 Times in 5 Posts
    Thanks...I'm gonna have to read up on php a lil more 2 understand that^

  • #6
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    with say
    <input type="radio" name="radiobutt" value="yes" />
    <input type="radio" name="radiobutt" value="no" />

    then {$_POST['radiobutt']} is good enough (will equal whatever is selected)

    for multiples , say checkboxes ..make the name an array by adding '[]' to the name

    1<input type="checkbox" name="checkbutt[0]" value="yes" />
    2<input type="checkbox" name="checkbutt[1]" value="no" />
    3<input type="checkbox" name="checkbutt[2]" value="maybee" />
    4<input type="checkbox" name="checkbutt[3]" value="perhaps" />

    then if checked,
    PHP Code:
    <?$_POST['checkbutt'][0]?>
    will = 'yes'


    errr & could you tone down the `thanks CF` bit of your sig (nice thought but a bit heavy )
    Last edited by firepages; 05-21-2004 at 11:57 AM.
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #7
    Regular Coder
    Join Date
    Apr 2004
    Location
    Philadelphia
    Posts
    241
    Thanks
    2
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by firepages
    with say
    <input type="radio" name="radiobutt" value="yes" />
    <input type="radio" name="radiobutt" value="no" />

    then {$_POST['radiobutt']} is good enough (will equal whatever is selected)

    for multiples , say checkboxes ..make the name an array by adding '[]' to the name

    1<input type="checkbox" name="checkbutt[0]" value="yes" />
    2<input type="checkbox" name="checkbutt[1]" value="no" />
    3<input type="checkbox" name="checkbutt[2]" value="maybee" />
    4<input type="checkbox" name="checkbutt[3]" value="perhaps" />

    then if checked,
    PHP Code:
    <?$_POST['checkbutt'][0]?>
    will = 'yes'

    So basically this would work?
    PHP Code:
    If($_POST['checkbutt'][0]){
    Script Here
    }elseif($_POST['checkbutt'][1]{
    Script Here


  • #8
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    Seriously, would you name a form element checkbutt ???

  • #9
    Regular Coder
    Join Date
    Apr 2004
    Location
    Philadelphia
    Posts
    241
    Thanks
    2
    Thanked 5 Times in 5 Posts
    Haha...jus relized that...but seriously...would it work?
    or would you have to put
    if($_POST['checkbutt'][0] == true){
    SCRIPT HERE
    }

  • #10
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    no cos checkbutt won't == true , it will equal whatever value you gave it in the form..

    PHP Code:
    <?
    if(!empty($_POST['checkbutt'][0])){
        
    //should work
    }
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #11
    Regular Coder
    Join Date
    Apr 2004
    Location
    Philadelphia
    Posts
    241
    Thanks
    2
    Thanked 5 Times in 5 Posts
    thanks much!


  •  

    Posting Permissions

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