Need help for multiple checkbox on php mail

Discussion in 'PHP' started by asit.ashmit, Dec 2, 2008.

  1. #1
    Dear Programmer,

    I need small help from your site. Below code written on my php page.

    <?
    $to = 'xyz@netsoftindia.in';
    $subject = "impacterp.com website inquiry";
    $name = $_REQUEST['name'] ;
    $comp = $_REQUEST['comp'] ;
    $email = $_REQUEST['email'] ;
    $inquiry = $_REQUEST['inquiry'];
    $enquiry = $_REQUEST['subject'] ;
    $message = "Name=".$name."\n"."Email=".$email."\n"."Requirement=".$inquiry."\n"."Company Name=".$comp."\n"."Comment=".$enquiry;
    $headers = "From: $email";
    $sent = mail($to, $subject, $message, $headers) ;
    if($sent)
    {}
    else
    {print "We encountered an error sending your mail"; }
    ?>

    $inquiry is multiple checkbox properties

    here is the link:- http://www.impacterp.com/enquiry.htm

    I need when fillin the form and check boxes then

    Name= fas df
    Email=
    Requirement= Banking
    Company Name= sf dsf sd
    Comment= sdf dsfsdfsda


    The above should be done in a table format then the format shall be very good.
    Don’t use = use :
    Requirement should have the details with comma seperated

    Kindly suggest me asap

    Thanks
    Asit
     
    asit.ashmit, Dec 2, 2008 IP
  2. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #2
    All your checkboxes should have the name "inquiry[]".

    All checked boxes will be added to that array.

    You process it with:
    
    for($i=0;$i<count($inquiry);$i++){
    $selected = $selected . $inquiry[$i] . ", ";
    }
    
    PHP:
     
    elias_sorensen, Dec 2, 2008 IP
  3. asit.ashmit

    asit.ashmit Banned

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for suggestion. I made change like this

    <?
    $to = 'alok@netsoftindia.in';
    $subject = "impacterp.com website inquiry";
    $name = $_REQUEST['name'] ;
    $comp = $_REQUEST['comp'] ;
    $email = $_REQUEST['email'] ;
    for($i=0;$i<count($inquiry);$i++){
    $selected = $selected . $inquiry[$i] . ", ";
    }
    $enquiry = $_REQUEST['subject'] ;
    $message = "Name=".$name."\n"."Email=".$email."\n"."Requirement=".$inquiry."\n"."Company Name=".$comp."\n"."Comment=".$enquiry;
    $headers = "From: $email";
    $sent = mail($to, $subject, $message, $headers) ;
    if($sent)
    {}
    else
    {print "We encountered an error sending your mail"; }
    ?>

    Please check this code, let me know it is ok or not.

    After submitted i got this type of mail

    Name=sdfsdf
    Email=sdfsdfsdf@dfgdfg.com
    Requirement=
    Company Name=ssdfsdf
    Comment=fdfgdfg

    Kinldy check it
     
    asit.ashmit, Dec 2, 2008 IP
  4. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #4
    Okay, caizai just got reported there ;)

    Do NEVER post such advertising thingys in threads...

    To the thread's question:

    You have to change the line:
    $message = "Name=".$name."\n"."Email=".$email."\n"."Requirement=".$inquiry."\n"."Company Name=".$comp."\n"."Comment=".$enquiry;
    PHP:
    with:
    $message = "Name=".$name."\n"."Email=".$email."\n"."Requirement=".$selected."\n"."Company Name=".$comp."\n"."Comment=".$enquiry;
    PHP:
    :)
     
    elias_sorensen, Dec 2, 2008 IP
  5. asit.ashmit

    asit.ashmit Banned

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Still i'm getting mail like:
    Name=Alok
    Email=alok@alok.com
    Requirement=
    Company Name=netsoft
    Comment=testing

    On html page i written like this:

    inquiry=document.getElementById('inquiry').checked;

    Is it ok?
     
    asit.ashmit, Dec 2, 2008 IP
  6. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #6
    It's NOT your job to post spam/advertising in here, you won't even get a visit on your webpage by posting here. I personally wouldn't buy ANYTHING from people spamming on forums to increase their sales.

    I've reported you two times for those messages you wrote here.

    If you really got so nice products, people would visit your store automatically, and you wouldn't have to spam forums and use admins' time to ban your user.

    That's a pretty egoistic way of thinking you got here. You won't get long with it.
     
    elias_sorensen, Dec 2, 2008 IP
  7. asit.ashmit

    asit.ashmit Banned

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Kindly request to all don't post any spam here plz. Try to solve my problem asap.

    Thanks
    Asit
     
    asit.ashmit, Dec 3, 2008 IP
  8. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #8
    And on ALL your checkboxes, you got name="inquiry[]" ?
     
    elias_sorensen, Dec 3, 2008 IP
  9. asit.ashmit

    asit.ashmit Banned

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9

    Yes, i did name="inquiry[]"
     
    asit.ashmit, Dec 3, 2008 IP
  10. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #10
    In your form element... Are you using method="post"?

    If you do so, please change all $_REQUEST to $_POST
     
    elias_sorensen, Dec 3, 2008 IP
  11. asit.ashmit

    asit.ashmit Banned

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11

    NO, in form element i'm using like:
    <form action="enquiry1.php" name="sbi" onSubmit="return checkForm(this);">
     
    asit.ashmit, Dec 3, 2008 IP
  12. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #12
    Ah... Do you submit your form with ajax? Or do you simply write some new content to the page?
     
    elias_sorensen, Dec 3, 2008 IP
  13. asit.ashmit

    asit.ashmit Banned

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13

    Can u give me ur email id plz? so i can send both html page and php page to u.
     
    asit.ashmit, Dec 3, 2008 IP