SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Europe
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help on PHP scrip (IF THEN STATEMENT)

    Hello,

    I am trying to add autoresponder to my web site. I have got a free arutoresponder php script in the net. But I am not good enough to deal with the script.

    My question here is that : Is it possible to add a IF STATEMENT and IF AND STATEMENT in the autoresponse text depending on the type of field the user checked?

    For instance, I have a form with two checkboxes

    IF
    <INPUT type=checkbox value=Yes name=Orange> THEN
    autoresponse text = thanks for chosing Orange

    IF
    <INPUT type=checkbox value=Yes name=Apel> THEN
    autoresponse text = thanks for chosing Orange

    IF
    <INPUT type=checkbox value=Yes name=Orange> AND
    <INPUT type=checkbox value=Yes name=Apel> THEN
    autoresponse text = thanks for chosing Orange and Apel


    Can anyone show me how to write the IF statement PHP script?
    I do not know PHP programming. I'am a guy how plays on FORTRAN and Visual Basic Stuff. So please help me.

    With regards,
    Comy

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    we suppose that your values are orange or something...
    PHP Code:
    if(!empty($_POST["filed_name"])) {
    $text "Thanx for choosing".$_POST["filed_name"];
    }
    //---------------
    if(!empty($_POST["filed_name1"]) || !empty($_POST["filed_name2"])) {
    $text "Thanx for choosing".$_POST["filed_name1"]." and ".$_POST["filed_name2"];

    cheers

  3. #3
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Europe
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks reminder,

    I tried your code:
    I have got the following error:

    Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in aformmail.php on line 45

    You may look at the outoresponder script (aformmail) that I downloaded from
    http://www.cgi-central.net/scripts/aformmail/

    I had put your code just next to the following text :
    Thank you for submitting the form. We will contact you shortly.

    Maybe I comitted some error on the 'filed_name', filed_name1, etc.
    The format of the two checkboxes in my HTML form are:

    <FONT><INPUT TYPE=checkbox NAME="Orange_Order" VALUE=Yes>Orange</FONT>

    <FONT><INPUT TYPE=checkbox NAME="Banana_Order" VALUE=Yes>Banana</FONT>


    Again, thank you for your help

    Comy

  4. #4
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this out

    PHP Code:
     <?php
     
     $msg 
    '';
     
    $done_one false;
     
     if (isset(
    $_POST['Orange_Order']))
     {
       if (
    false == $done_one)
       {
         
    $msg 'Thanks for choosing Orange';
       }
       else
       {
         
    $msg .= ' and Orange';
       }
       
    $done_one true;
     }
     
     if (isset(
    $_POST['Banana_Order']))
     {
       if (
    false == $done_one)
       {
         
    $msg 'Thanks for choosing Banana';
       }
       else
       {
         
    $msg .= ' and Banana';
       }
       
    $done_one true;
     }
     
     echo 
    $msg;
     
     
    ?>
     
     <form name="test form" method="post" action=" <?php echo $_SERVER['PHP_SELF']?>">
     
     <input type="checkbox" name="Orange_Order" value="Yes" />Orange
     <br />
     <input type="checkbox" name="Banana_Order" value="Yes" />Banana
     
     <input type="submit" name="Select" value="submit" />
     </form>


Bookmarks

Posting Permissions

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