Jump to content

Sending values of combo boxes by email


maciek4

Recommended Posts

I have a form. The user clicks on checkbox and combo box is activated. He selects the value in the combo box from 1 to 5 (which indicated importance factor) and the value is sent by email. the problem is that the value is not sent and I dont know why. Anybody knows how to fix it?

[code]
$need = array();
$importance = array();

    $importance[0] = $_POST["importance"];
    $importance[1] = $_POST["importance1"];[/code]

[code]
$mailBody .= "I need english to:\n\n";
        if(isset($need['friend'])) {$mailBody .= "- social reasons\n";
        $mailBody .= "Importance: ".$importance[0]."\n\n";}
        if(isset($need['sell'])) {$mailBody .= "- sale and negotiations\n";
        $mailBody .= "Importance: ".$importance[1]."\n\n";}[/code]

[code]
<form action="analize_rq.html" method="post" name="order">
[/code]

[code]
<INPUT TYPE="checkbox" NAME="need[friend]" value="friend" onclick="javascript:document.order.importance.disabled=false" <? echo isset($need['friend']) ? 'checked' : ''; ?> >&nbsp;social reasons<br>

<select disabled="true" name="importance">
    <option value="0" <? echo ($importance[0] == '0' ? 'selected' : '') ?>>-</option>
    <option value="1" <? echo ($importance[0] == '1' ? 'selected' : '') ?>>1</option>
    <option value="2" <? echo ($importance[0] == '2' ? 'selected' : '') ?>>2</option>
    <option value="3" <? echo ($importance[0] == '3' ? 'selected' : '') ?>>3</option>
    <option value="4" <? echo ($importance[0] == '4' ? 'selected' : '') ?>>4</option>
    <option value="5" <? echo ($importance[0] == '5' ? 'selected' : '') ?>>5</option>
    </select>

<INPUT TYPE="checkbox" NAME="need[sell]" value="sell" onclick="javascript:document.order.importance1.disabled=false"<? echo isset($need['sell']) ? 'checked' : ''; ?>>&nbsp;sales and negotiations<br>

<select name="importance1" disabled="true">
<option value="0" <? echo ($importance[1] == '0' ? 'selected' : '') ?>>-</option>
    <option value="1" <? echo ($importance[1] == '1' ? 'selected' : '') ?>>1</option>
    <option value="2" <? echo ($importance[1] == '2' ? 'selected' : '') ?>>2</option>
    <option value="3" <? echo ($importance[1] == '3' ? 'selected' : '') ?>>3</option>
    <option value="4" <? echo ($importance[1] == '4' ? 'selected' : '') ?>>4</option>
    <option value="5" <? echo ($importance[1] == '5' ? 'selected' : '') ?>>5</option>
    </select>[/code]
Link to comment
Share on other sites

let me confirm your requirement

You have a form i which ther is two combo boxes and when i click submit the the selected combobx values should be send to the email .

I want to ask you wheather you want to select a single value from a combo box or multiple values

Link to comment
Share on other sites

[!--quoteo(post=371203:date=May 4 2006, 01:22 PM:name=anuka)--][div class=\'quotetop\']QUOTE(anuka @ May 4 2006, 01:22 PM) [snapback]371203[/snapback][/div][div class=\'quotemain\'][!--quotec--]
let me confirm your requirement

You have a form i which ther is two combo boxes and when i click submit the the selected combobx values should be send to the email .

I want to ask you wheather you want to select a single value from a combo box or multiple values
[/quote]

correct
single value.

The options are 1-5. It looks like this

social reasons (checkbox) importance (combo box)
sales and negotiations (checkbox) importance (combo box)

If I click on checkbox 1 ----> compbobox 1 is activated and I can select a value there.

If I select values 1 in combobox 1 and 5 in combobox 2, in the email I should get

social reasons:
importance: 1

sales and negotiations:
importance: 5
Link to comment
Share on other sites

[code]<?
$need = array();
$importance = array();
    $importance[0] = $_POST["importance"];
    $importance[1] = $_POST["importance1"];

    $mailBody = "I need english to:\n\n";
        if(isset($need['friend']))
        {
        $mailBody .= "- social reasons\n";
        $mailBody .= "Importance: ".$importance[0]."\n\n";
        }
        if(isset($need['sell']))
        {
        $mailBody .= "- sale and negotiations\n";
        $mailBody .= "Importance: ".$importance[1]."\n\n";
        }
        
        
$mail_to = "name@domian.com"; //To mail which is retrieved form the data base
$mail_from = "name@domian.com"; //From mail
$mail_subject = "Details12";//subject header
/* To send HTML mail, you can set the Content-type header. */
$headers  = "MIME-Version: 1.0\n";  //setting the mime version. To send the html we have to set MIME ver 1.0
########################################################################
# IMP IF THIS CODE DOESNT WORK ADD \r\n INSTEAD OF \n IN HEADERS
#######################################################################
$headers .= "Content-type: text/html; charset=iso-8859-1\n"; //for send ing the html file
/* additional headers */

$headers .= "From: Ansar<name@domian.com>\n"; //headers from address
//$headers .= "Cc: name@example.com\n";
//$headers .= "Bcc: name@example.com\n";
//$body=htmlentities($body);
//Function to send mail
mail($mail_to,$mail_subject,$mailBody,$headers);
    ?>
    
    <form action="<?=PHP_SELF?>" method="post" name="order">
    
  <p>
    <INPUT TYPE="checkbox" NAME="need[friend]" value="friend" onclick="javascript:document.order.importance.disabled=false" <? echo isset($need['friend']) ? 'checked' : ''; ?> >
    &nbsp;social reasons<br>
    <select disabled="true" name="importance">
      <option value="0" <? echo ($importance[0] == '0' ? 'selected' : '') ?>>-</option>
      <option value="1" <? echo ($importance[0] == '1' ? 'selected' : '') ?>>1</option>
      <option value="2" <? echo ($importance[0] == '2' ? 'selected' : '') ?>>2</option>
      <option value="3" <? echo ($importance[0] == '3' ? 'selected' : '') ?>>3</option>
      <option value="4" <? echo ($importance[0] == '4' ? 'selected' : '') ?>>4</option>
      <option value="5" <? echo ($importance[0] == '5' ? 'selected' : '') ?>>5</option>
    </select>
  </p>
  <p>
    <INPUT TYPE="checkbox" NAME="need[sell]" value="sell" onclick="javascript:document.order.importance1.disabled=false"<? echo isset($need['sell']) ? 'checked' : ''; ?>>
    &nbsp;sales and negotiations<br>
    <select name="importance1" disabled="true">
      <option value="0" <? echo ($importance[1] == '0' ? 'selected' : '') ?>>-</option>
      <option value="1" <? echo ($importance[1] == '1' ? 'selected' : '') ?>>1</option>
      <option value="2" <? echo ($importance[1] == '2' ? 'selected' : '') ?>>2</option>
      <option value="3" <? echo ($importance[1] == '3' ? 'selected' : '') ?>>3</option>
      <option value="4" <? echo ($importance[1] == '4' ? 'selected' : '') ?>>4</option>
      <option value="5" <? echo ($importance[1] == '5' ? 'selected' : '') ?>>5</option>
    </select>
    <input type="submit" name="Submit" value="Submit">
  </p>
</form>[/code]

TRY THIS CODE
Link to comment
Share on other sites

[!--quoteo(post=371206:date=May 4 2006, 01:31 PM:name=anuka)--][div class=\'quotetop\']QUOTE(anuka @ May 4 2006, 01:31 PM) [snapback]371206[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[code]<?
$need = array();
$importance = array();
    $importance[0] = $_POST["importance"];
    $importance[1] = $_POST["importance1"];

    $mailBody = "I need english to:\n\n";
        if(isset($need['friend']))
        {
        $mailBody .= "- social reasons\n";
        $mailBody .= "Importance: ".$importance[0]."\n\n";
        }
        if(isset($need['sell']))
        {
        $mailBody .= "- sale and negotiations\n";
        $mailBody .= "Importance: ".$importance[1]."\n\n";
        }
        
        
$mail_to = "name@domian.com"; //To mail which is retrieved form the data base
$mail_from = "name@domian.com"; //From mail
$mail_subject = "Details12";//subject header
/* To send HTML mail, you can set the Content-type header. */
$headers  = "MIME-Version: 1.0\n";  //setting the mime version. To send the html we have to set MIME ver 1.0
########################################################################
# IMP IF THIS CODE DOESNT WORK ADD \r\n INSTEAD OF \n IN HEADERS
#######################################################################
$headers .= "Content-type: text/html; charset=iso-8859-1\n"; //for send ing the html file
/* additional headers */

$headers .= "From: Ansar<name@domian.com>\n"; //headers from address
//$headers .= "Cc: name@example.com\n";
//$headers .= "Bcc: name@example.com\n";
//$body=htmlentities($body);
//Function to send mail
mail($mail_to,$mail_subject,$mailBody,$headers);
    ?>
    
    <form action="<?=PHP_SELF?>" method="post" name="order">
    
  <p>
    <INPUT TYPE="checkbox" NAME="need[friend]" value="friend" onclick="javascript:document.order.importance.disabled=false" <? echo isset($need['friend']) ? 'checked' : ''; ?> >
    &nbsp;social reasons<br>
    <select disabled="true" name="importance">
      <option value="0" <? echo ($importance[0] == '0' ? 'selected' : '') ?>>-</option>
      <option value="1" <? echo ($importance[0] == '1' ? 'selected' : '') ?>>1</option>
      <option value="2" <? echo ($importance[0] == '2' ? 'selected' : '') ?>>2</option>
      <option value="3" <? echo ($importance[0] == '3' ? 'selected' : '') ?>>3</option>
      <option value="4" <? echo ($importance[0] == '4' ? 'selected' : '') ?>>4</option>
      <option value="5" <? echo ($importance[0] == '5' ? 'selected' : '') ?>>5</option>
    </select>
  </p>
  <p>
    <INPUT TYPE="checkbox" NAME="need[sell]" value="sell" onclick="javascript:document.order.importance1.disabled=false"<? echo isset($need['sell']) ? 'checked' : ''; ?>>
    &nbsp;sales and negotiations<br>
    <select name="importance1" disabled="true">
      <option value="0" <? echo ($importance[1] == '0' ? 'selected' : '') ?>>-</option>
      <option value="1" <? echo ($importance[1] == '1' ? 'selected' : '') ?>>1</option>
      <option value="2" <? echo ($importance[1] == '2' ? 'selected' : '') ?>>2</option>
      <option value="3" <? echo ($importance[1] == '3' ? 'selected' : '') ?>>3</option>
      <option value="4" <? echo ($importance[1] == '4' ? 'selected' : '') ?>>4</option>
      <option value="5" <? echo ($importance[1] == '5' ? 'selected' : '') ?>>5</option>
    </select>
    <input type="submit" name="Submit" value="Submit">
  </p>
</form>[/code]

TRY THIS CODE
[/quote]



so what has changed in the code? I don't see any changes.
Link to comment
Share on other sites

[!--quoteo(post=371208:date=May 4 2006, 06:45 AM:name=Poland)--][div class=\'quotetop\']QUOTE(Poland @ May 4 2006, 06:45 AM) [snapback]371208[/snapback][/div][div class=\'quotemain\'][!--quotec--]
so what has changed in the code? I don't see any changes.
[/quote]


Check the code complty before making any comments
i hve added some extra code to your code plz check each and every lin in the php tag
Link to comment
Share on other sites

why not highlight the extra code? It would make it easier to find.

I believe you only added this part:

$mail_to = "name@domian.com"; //To mail which is retrieved form the data base
$mail_from = "name@domian.com"; //From mail
$mail_subject = "Details12";//subject header
/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\n"; //setting the mime version. To send the html we have to set MIME ver 1.0
########################################################################
# IMP IF THIS CODE DOESNT WORK ADD \r\n INSTEAD OF \n IN HEADERS
#######################################################################
$headers .= "Content-type: text/html; charset=iso-8859-1\n"; //for send ing the html file
/* additional headers */

$headers .= "From: Ansar<name@domian.com>\n"; //headers from address
//$headers .= "Cc: name@example.com\n";
//$headers .= "Bcc: name@example.com\n";
//$body=htmlentities($body);
//Function to send mail
mail($mail_to,$mail_subject,$mailBody,$headers);
?>

I already have a function to send mail and it works correctly, the problem that I have is that the value from the combo box is not being sent. In my email I am getting this:

Social reasons:
Importance:

Sales and negotiations:
Importance:

no value in the importance.
Link to comment
Share on other sites

if(isset($need['friend']))
{
$mailBody .= "- social reasons\n";
$mailBody .= "Importance:[i] $importance[0] [/i]\n\n";
}
if(isset($need['sell']))
{
$mailBody .= "- sale and negotiations\n";
$mailBody .= "Importance:[i] $importance[1] [/i]\n\n";
}
Link to comment
Share on other sites

[!--quoteo(post=371224:date=May 4 2006, 02:42 PM:name=anuka)--][div class=\'quotetop\']QUOTE(anuka @ May 4 2006, 02:42 PM) [snapback]371224[/snapback][/div][div class=\'quotemain\'][!--quotec--]
if(isset($need['friend']))
{
$mailBody .= "- social reasons\n";
$mailBody .= "Importance:[i] $importance[0] [/i]\n\n";
}
if(isset($need['sell']))
{
$mailBody .= "- sale and negotiations\n";
$mailBody .= "Importance:[i] $importance[1] [/i]\n\n";
}
[/quote]

[code]
$mailBody .= "I need english to:\n\n";
        if(isset($need['friend'])) {$mailBody .= "- social reasons\n";
        $mailBody .= "Importance: ".$importance[0]."\n\n";}
        if(isset($need['sell'])) {$mailBody .= "- sale and negotiations\n";
        $mailBody .= "Importance: ".$importance[1]."\n\n";}[/code]

same thing. Already have it.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.