1 Reply Latest reply on Jul 23, 2010 6:57 AM by selangov

    RE : Having troubles with a form

    spliffster42

      Hi Guys,


      Its been a while since i posted here. The company I work for has a website designed by the former guy from marketing. So all upadtes and fix ups ar eup to me to fix. As I have said before, my skills in php/html/flash are a little above basic. I can understand coding and can work my way around a website.


      With that said, There is a form on the website to register as a VIP for our company. Now, It works fine, it sends to my email and all, so I assume the php code is ok. The problem is this, all the info that is typed in a input box shows up in the email, but all the info thats under a check box and radio button do not work. It shows up in the email as [object Object].


      Here is the email that sends out after clicking submit:


      Name: TEST21
      Telephone: 2890
      Email: spliff@yahoo.com
      Address: 222
      Birthday (year month day): 1985 12 12
      Company: july 21 12 50pm
      Title: TEST
      No of kids: undefined
      Gender (True = Male): false
      Reward Selection: [object Object]
      Newsletter(True = yes): false
      Existing Cardholder: [object Object]
      Marital Status: [object Object]
      Interest:
      Age: [object Object]


      As you can see most of it sends through except for the radio buttons. I managed to fix (kind of) the GENDER and NEWSLETTER to send as true or false. But this won't do. I tried clicking both Male and Female for gender and it both shows up as false. I feel I'm so close to the answer, I managed to code something that the Gender sends as M or F. But I wasnt able to save the file. So I'm back to ground zero. Need help please.


      I can paste the code here from the submit button on the form and the PHP code for anyones reference. THANKS IN ADVANCE.


      on(release){
         
          allownewsleter=allownewsletter_yes.value
          gender=gender_male.value
         
          //db_year="2006;"
          //db_month="08";
          //db_day="30";
         
         
         
      _root.firstname=firstname;
      //_root.lastname=lastname;

       

      _root.phone=phone;
      _root.address=address;
      _root.email=email;
      _root.db_year=db_year;
      _root.db_month=db_month;
      _root.db_day=db_day;
      _root.company=companynames;
      _root.title=title;
      _root.kid_no=kid_no;   
      _root.gender=gender;
      _root.reward=reward;
      _root.allownewsleter=allownewsleter;
      _root.cardholder=cardholder;
      _root.marital=marital;
      _root.interest=interest;
      _root.age=age;

       

      //trace ("gender_male.value++++++++++" + gender_male.value);
      //trace ("gender_female.value++++++++++" + gender_female.value);

       

       

       

      if (gender_male.selected) {
      trace("gender is set to male");
        gender_male.value = "M";
      } else {
      trace("gender is set to female");
        gender_female.value = "F"; 
      }


       

      if (reward_1.value==true)
      {
        _root.reward="1"
      }
      else if (reward_2.value==true)
      {
      _root.reward="2"
      }
      else
      {
      _root.reward=""
      }

       

       

       

       

       

       

       

      if (allownewsletter_yes.value==true)
      {
      _root.allownewsleter="1"
      }
      else if (allownewsletter_no.value==true)
      {
      _root.allownewsleter="2"
      }
      else
      {
      _root.allownewsleter=""
      }

       

       

       

       

       

       

       

      if (cardholder_yes.value==true)
      {
        _root.cardholder="1"
      }
      else if (cardholder_no.value==true)
      {
      _root.cardholder="0"
      }
      else
      {
      _root.cardholder=""
      }

       

       

       

       

       

       

       


      if ((marital_yes.value==false) and (marital_no.value==false))
      {
      _root.marital=""

      }
      else
      {
      _root.marital=marital_yes.value
      }

       

       

       

      if (marital_yes.value==true)
      {
        _root.marital="M"
      }
      else if (marital_no.value==true)
      {
      _root.marital="S"
      }
      else
      {
      _root.marital=""
      }

       

       

       

       

       

      if (interest_1.value==true)
      {
         
        _root.interest_1="1"
      }
      else
      {
        _root.interest_1="0"
      }

       


      if (interest_2.value==true)
      {
         
      _root.interest_2="1"
      }
      else
      {
        _root.interest_2="0"
      }

       


      if (interest_3.value==true)
      {
         
        _root.interest_3="1"
      }
      else
      {
        _root.interest_3="0"
      }

       

       

       

      if (interest_4.value==true)
      {
         
        _root.interest_4="1"
      }
      else
      {
        _root.interest_4="0"
      }

       


      if (interest_5.value==true)
      {
         
        _root.interest_5="1"
      }
      else
      {
        _root.interest_5="0"
      }

       


      if (interest_6.value==true)
      {
        if (other_interest==undefined)
        {
          _root.interest_6="" 
        }
        else
        {
          _root.interest_6=other_interest
        }
      }
      else
      {
        _root.interest_6="0"
      }

       

       

       


      //trace ("interest_1.value='''''''''''''''''''''''''''" +interest_1.value)

       

       

       

      if (age_1.value==true)
      {
        _root.age="1"
      }
      else if (age_2.value==true)
      {
      _root.age="2"
      }
      else if (age_3.value==true)
      {
      _root.age="3"
      }
      else if (age_4.value==true)
      {
      _root.age="4"
      }
      else
      {
      _root.age=""
      }

       


           message_movie._visible=false;
          trace ("_root.firstname=" + firstname)
          trace ("_root.lastname=" + lastname)
          trace ("_root.gender12345=" + _root.gender)
          trace ("_root.phone=" + phone)
          trace ("_root.address=" + address)
          trace ("_root.email=" + email)
          trace ("_root.db_year=" + db_year)
          trace ("_root.db_month=" + db_month)
          trace ("_root.db_day=" + db_day)
          trace ("_root.company=" + companynames)
          trace ("_root.title=" + title)
          trace ("_root.phone=" + phone)
          trace ("_root.kid_no=" + kid_no)
          trace ("_root.allownewsleter=" + _root.allownewsleter)
          //trace ("allownewsletter_yes=" + allownewsletter_yes.value)
          trace ("gender=" + _root.gender    )
          trace ("db_year=" + db_year.value )
          trace ("CARDHOLDER=====" + _root.cardholder )
          trace ("marital=====" + _root.marital )
          trace ("_root.interest========" + _root.interest )
          trace ("_root.age========" + _root.age )
          trace ("_root.reward========" + _root.reward )
         
         
         
          trace("//////////////")
          trace ("_root.firstname=" + _root.firstname)
          trace ("_root.gender=" + _root.gender)
          trace ("_root.phone=" + _root.phone)
          trace ("_root.address=" + _root.address)
          trace ("_root.email=" + _root.email)
          trace ("_root.db_year=" + _root.db_year)
          trace ("_root.db_month=" + _root.db_month)
          trace ("_root.db_day=" + _root.db_day)
          trace ("_root.company=" +_root.company)
         
          if (_root.kid_no==undefined)
          {
              _root.kid_no=""
          }
         
          if ((_root.firstname=="")  or (_root.gender=="") or (_root.phone=="")  or (_root.address=="")  or (_root.email=="")  or (_root.db_month=="")  or (_root.db_day=="")   or (_root.age=="") )
          {
           message_movie.messagevalue=    "Please fill in all mandatory fields!"
            message_movie._visible=true;
          }
          else
          {
           LoginProgress.gotoAndPlay("StartLogin");
         
          URL = "email_vip.php?firstname=" + firstname + "&lastname=" + lastname + "&email=" + email + "&phone=" + phone   + "&area_id=" + area + "&address=" + address +
                  "&db_year=" + db_year + "&db_month=" + db_month + "&db_day=" + db_day + "&companynames=" + companynames + "&titles=" + titles + "&kid_no=" + kid_no +
                  "&gender=" + gender + "&reward=" + reward + "&allownewsleter=" + allownewsleter + "&cardholder=" + cardholder + "&marital=" + marital + "&interest" + interest +
                  "&age=" + age ;
          loadVariablesNum(URL , 0, "GET");
              //getURL (URL);
          gotoAndStop("send_finished");
         }
         
      }




      PHP CODE

      <?php
      $area =array("","Hong Kong Island","Kowloon","New Territoris","Outlying Islands","Mainland China","Overseas");
      $gender =array("","Male","Female");

       


      $firstname=stripslashes($_GET['firstname']);
      $lastname=stripslashes($_GET['lastname']);
      $phone=stripslashes($_GET['phone']);
      $email=stripslashes($_GET['email']);
      $area_id=stripslashes($_GET['area_id']);
      $address=stripslashes($_GET['address']);
      $db_year=stripslashes($_GET['db_year']);
      $db_month=stripslashes($_GET['db_month']);
      $db_day=stripslashes($_GET['db_day']);
      $db_year=stripslashes($_GET['db_year']);
      $companynames=stripslashes($_GET['companynames']);
      $title=stripslashes($_GET['title']);
      $kid_no=stripslashes($_GET['kid_no']);
      $gender=stripslashes($_GET['gender']);
      $reward=stripslashes($_GET['reward']);
      $allownewsleter=stripslashes($_GET['allownewsleter']);
      $cardholder=stripslashes($_GET['cardholder']);
      $marital=stripslashes($_GET['marital']);
      $interest=stripslashes($_GET['interest']);
      $age=stripslashes($_GET['age']);
      //echo "firstname=$firstname";
          $smtp_server = "localhost";
          //$from        = "Igor's Group<yoyo@ixzon.com>";
          $from        = "Igor's Group<info@igors.com>";
          $subject     = "Elite Card Registration";
          $to          = "anton@igors.com";
          //$to          = "anton@igors.com";
          $headers = "Content-type: text/html; charset=utf-8\nFrom: $from\r\nReply-To: $from";

       

          $body= "Name: $firstname<br>";
          $body=$body . "Telephone: $phone<br>";
          $body=$body . "Email: $email<br>";
          $body=$body . "Address: $address<br>";
          $body=$body . "Birthday (year month day): $db_year $db_month $db_day<br>";
          $body=$body . "Company: $companynames<br>";
          $body=$body . "Title: $title<br>";
          $body=$body . "No of kids: $kid_no<br>";
          $body=$body . "Gender (True = Male): $gender<br>";
          $body=$body . "Reward Selection: $reward<br>";
          $body=$body . "Newsletter(True = yes): $allownewsleter<br>";
          $body=$body . "Existing Cardholder: $cardholder<br>";
          $body=$body . "Marital Status: $marital<br>";
          $body=$body . "Interest: $interest<br>";
          $body=$body . "Age: $age";

       

          mail($to,$subject,$body,$headers);
      ?>


      Hope to hear from you guys.



        • 1. Re: RE : Having troubles with a form
          selangov

          Hi,

           

          Your code is looking like AS2. Hence providing the AS2 code for your reference.

           

          First select your Male radio button, open component inspector and type "M" in the data field and press enter. Select your Female radio button, open component inspector and type "F" in the data field and press enter

           

          Just add the below code instead of your radio button code

           

          radio_button_listener = new Object();

          radio_button_listener.click = function (evt){

          _root.gender = evt.target.selection.data

          }

          radioGroup.addEventListener("click", radio_button_listener);

           

          The above code gives you "M" or "F" in your php output.

           

          Thanks