Jump to content


Photo

Sending values of combo boxes by email


  • Please log in to reply
8 replies to this topic

#1 maciek4

maciek4
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 04 May 2006 - 10:40 AM

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?

$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";}

<form action="analize_rq.html" method="post" name="order">

<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>


#2 ansarka

ansarka
  • Members
  • PipPipPip
  • Advanced Member
  • 128 posts
  • LocationCochin, Kerala, India

Posted 04 May 2006 - 11:22 AM

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


EVEN THE WORD IMPOSSIBLE IS SAYING I' M' POSSIBLE

#3 maciek4

maciek4
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 04 May 2006 - 11:28 AM

[!--quoteo(post=371203:date=May 4 2006, 01:22 PM:name=anuka)--][div class=\'quotetop\']QUOTE(anuka @ May 4 2006, 01:22 PM) View Post[/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


#4 ansarka

ansarka
  • Members
  • PipPipPip
  • Advanced Member
  • 128 posts
  • LocationCochin, Kerala, India

Posted 04 May 2006 - 11:31 AM

<?
$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>

TRY THIS CODE
EVEN THE WORD IMPOSSIBLE IS SAYING I' M' POSSIBLE

#5 maciek4

maciek4
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 04 May 2006 - 11:45 AM

[!--quoteo(post=371206:date=May 4 2006, 01:31 PM:name=anuka)--][div class=\'quotetop\']QUOTE(anuka @ May 4 2006, 01:31 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
<?
$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>

TRY THIS CODE
[/quote]



so what has changed in the code? I don't see any changes.

#6 ansarka

ansarka
  • Members
  • PipPipPip
  • Advanced Member
  • 128 posts
  • LocationCochin, Kerala, India

Posted 04 May 2006 - 11:52 AM

[!--quoteo(post=371208:date=May 4 2006, 06:45 AM:name=Poland)--][div class=\'quotetop\']QUOTE(Poland @ May 4 2006, 06:45 AM) View Post[/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

EVEN THE WORD IMPOSSIBLE IS SAYING I' M' POSSIBLE

#7 maciek4

maciek4
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 04 May 2006 - 12:08 PM

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.

#8 ansarka

ansarka
  • Members
  • PipPipPip
  • Advanced Member
  • 128 posts
  • LocationCochin, Kerala, India

Posted 04 May 2006 - 12:42 PM

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";
}

EVEN THE WORD IMPOSSIBLE IS SAYING I' M' POSSIBLE

#9 maciek4

maciek4
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 04 May 2006 - 12:47 PM

[!--quoteo(post=371224:date=May 4 2006, 02:42 PM:name=anuka)--][div class=\'quotetop\']QUOTE(anuka @ May 4 2006, 02:42 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
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";
}
[/quote]

$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";}

same thing. Already have it.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users