Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    Dec 2006
    Posts
    16
    Member #
    14537
    I added a form to a website where there is a long list of products (about 200) and there is a quantity box next to each of them. When the form is sent The email contains all of the products and the ones that were selected have the quantity number next to them. Is it possible to only have the ones that were selected sent? It works fine if I use a check box instead of a text box but I need to have a quantity with it. Also the script I am using to send is PHP.

    Thanks

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,715
    Member #
    5580
    Liked
    717 times
    Yes,
    If you check the variable (less than one) it would mean no quantity
    is selected, so it would not send that one. Hard to see it though
    without seeing the form (a link to your URL) and a copy of the PHP script.


  4. #3
    Junior Member
    Join Date
    Dec 2006
    Posts
    16
    Member #
    14537
    http://temphost.webofamerica.net/mid.../products.html

    It is on a temp domain for right now. and the flash at the top will not load.

    This is the php script

    PHP Code:
    <?php
    //--------------------------Set these paramaters--------------------------

    // Subject of email sent to you.
    $subject 'Results from Contact form';

    // Your email address. This is where the form information will be sent.
    $emailadd 'design@webofamerica.net';

    // Where to redirect after form is processed.
    $url 'http://www.google.com;

    // Makes all fields required. If set to '
    1' no field can not be empty. If set to '0' any or all fields can be empty.
    $req = '
    0';

    // --------------------------Do not edit below this line--------------------------
    $text = "Results from form:\n\n";
    $space = ' ';
    $line = '
    ';
    foreach ($_POST as $key => $value)
    {
    if ($req == '
    1')
    {
    if ($value == '')
    {echo "$key is empty";die;}
    }
    $j = strlen($key);
    if ($j >= 20)
    {echo "Name of form element $key cannot be longer than 20 characters";die;}
    $j = 20 - $j;
    for ($i = 1; $i <= $j; $i++)
    {$space .= ' ';}
    $value = str_replace('
    \n', "$line", $value);
    $conc = "{$key}:$space{$value}$line";
    $text .= $conc;
    $space = ' ';
    }
    mail($emailadd, $subject, $text, '
    From'.$emailadd.'');
    echo '
    <META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
    ?>

  5. #4
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,715
    Member #
    5580
    Liked
    717 times
    See the changes:

    if(strlen($value)>0){
    $value = str_replace('\n', "$line", $value);
    $conc = "{$key}:$space{$value}$line";
    $text .= $conc;
    }


    PHP Code:
    // --------------------------Do not edit below this line--------------------------
    $text "Results from form:\n\n";
    $space ' ';
    $line '
    '
    ;
    foreach (
    $_POST as $key => $value)
    {
    if (
    $req == '1')
    {
    if (
    $value == '')
    {echo 
    "$key is empty";die;}
    }
    $j strlen($key);
    if (
    $j >= 20)
    {echo 
    "Name of form element $key cannot be longer than 20 characters";die;}
    $j 20 $j;
    for (
    $i 1$i <= $j$i++)
    {
    $space .= ' ';}
    if(
    strlen($value)>0){
    $value str_replace('\n'"$line"$value);
    $conc "{$key}:$space{$value}$line";
    $text .= $conc;
    }
    $space ' ';
    }
    mail($emailadd$subject$text'From: '.$emailadd.'');
    echo 
    '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'
    It checks for a string length greater than zero.
    A blank QTY box will have a string length = zero.

    Also, you need to replace newlines '\n' not the letter 'n' ...

    Finally, in case this was a typo on here but not in your script:
    $url = 'http://www.google.com';

    missing the closing single quote.



Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:23 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com