Jump to content

Checkboxes by e-mail.


Kyrus

Recommended Posts

Hello people.

 

I'm working on this form where people can book their meetings online. I've got a few checkboxes there so people can choose with whom they want to meet. Thing is, the email I get here displays "Array" rather than displaying the persons that they checked. Suggestions?

 

Here is the code for the checkboxes:

 

<br />
          <input name="meet[]" type="checkbox" id="meet[]" value="Luis Guimarães" />
          Luis Guimarães <br />
          <br />
          <input name="meet[]" type="checkbox" id="meet[]" value="Carlos Gonçalves" />
          Carlos Gonçalves <br />
          <input name="meet[]" type="checkbox" id="meet[]" value="Francisco Pestana" />
        Francisco Pestana<br />
        <input name="meet[]2" type="checkbox" id="meet[]2" value="Carla João Ribeiro" />
        Carla João Ribeiro<br />
        <input name="meet[]3" type="checkbox" id="meet[]3" value="Vitália Barros" />
        Vitália Barros<br />
        <input name="meet[]4" type="checkbox" id="meet[]4" value="Isabel Calisto" />
        Isabel Calisto</p>
        <p align="left" class="style23">
          <input name="meet[]5" type="checkbox" id="meet[]5" value="Luís Vasconcelos" />
          Luís Vasconcelos<br />
          <input name="meet[]6" type="checkbox" id="meet[]6" value="Raquel Ribeiro" />
          Raquel Ribeiro</p>
        <p align="left" class="style23">
            <input name="meet[]7" type="checkbox" id="meet[]7" value="Miguel Guimarães" />
          Miguel Guimarães</p>
        <p align="left" class="style23">
            <input name="meet[]8" type="checkbox" id="meet[]8" value="Vasco Guimarães" />
          Vasco Guimarães<br />
          <input name="meet[]9" type="checkbox" id="meet[]9" value="Rita Ferreira" />
          Rita Ferreira<br />
          <input name="meet[]10" type="checkbox" id="meet[]10" value="Teresa Santos" />
          Teresa Santos</p>
        <p align="left" class="style23">
            <input name="meet[]11" type="checkbox" id="meet[]11" value="Jaime Membrive" />
          Jaime Membrive<br />
          <input name="meet[]12" type="checkbox" id="meet[]12" value="Cristina Torruella " />
          Cristina Torruella 

 

An here is the send_from.php:

 

 <?php 
$to = "pedropeixoto@live.com"; //
$name = $_POST['name']; 
$company = $_POST['company']; 
$email = $_POST['email'];
$meet = $_POST['meet'];
$hour = $_POST['hour'];
$quote = $_POST['quote'];
$day = $_POST['day'];
$sub = "On-line Medica 2008 meeting booking.";
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "Meeting information:";
$EmailBody = "Name: $name\nCompany: $company\nE-mail: $email\n[b]Meeting with: &meet[/b]\n On the $day at $hour\nAdditional details: $quote\n"; 

//if(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z­]{2,3})$", 
//$email)) { 
  //    echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h3>O Email que foi inserido não tem um formato valido, por favor insira um email valido</h3></font></div>";
//echo " <meta http-equiv=\"refresh\" content=\"3;URL=catalogo.php\"> ";
  //exit;
//}


if(empty($company)) { 
      echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h3>You didn't fill in the COMPANY which is required to book a meeting with us.</h3></font></div>";
	  echo " <meta http-equiv=\"refresh\" content=\"3;URL=form.php\"> ";
  exit;
} 

else { 

      mail($to, $sub, $EmailBody, $headers); 
      echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h2>Thank you ".$name.", your information has been sent. </h2></font></div>";
	echo " <meta http-equiv=\"refresh\" content=\"3;URL=http://www.bastosviegas.com/\"> ";	  
} 


?>

 

An this is the e-mail i get:

 

Meeting information:

 

Name: Pedro Peixoto

Company: Company of Heroes

E-mail: blabla@live.com

Wants to meet with: Array

On the November 20th at 10:00

Additional details: Additional notes? Please write here.

 

Thank you in advance.

Link to comment
Share on other sites

Can your users only select one person to meet with?

 

If so change the name of your checkboxes to the same name ie. meet

 

The the selected value will be $_POST['meet'] If more than on can be selected you will have to scroll through the array.

 

Users would be able to select more than one eprson to meet. Here's the link: www.bastosviegas.com/form.php

 

Scroll through the array. That's what I can't figure out. Could you give me an example? If possible applicable to this code.

 

Thank you.

 

Link to comment
Share on other sites

Hi again.

 

I did what you said and here's the code now:

 

<?php 

$to = "pedropeixoto@live.com"; //
$name = $_POST['name']; 
$company = $_POST['company']; 
$email = $_POST['email'];
$meet = $_POST['meet'];

foreach ($meet as $value) {
   strip_tags($value)";
   echo "$value<br>";
}
$hour = $_POST['hour'];
$quote = $_POST['quote'];
$day = $_POST['day'];
$sub = "On-line Medica 2008 meeting booking.";
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "Meeting information:";
$EmailBody = "Name: $name\nCompany: $company\nE-mail: $email\nMeeting with: &meet\n On the $day at $hour\nAdditional details: $quote\n"; 


//if(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z­]{2,3})$", 
//$email)) { 
  //    echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h3>O Email que foi inserido não tem um formato valido, por favor insira um email valido</h3></font></div>";
//echo " <meta http-equiv=\"refresh\" content=\"3;URL=catalogo.php\"> ";
  //exit;
//}

if(empty($name)) { 
      echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h3>You didn't fill in the NAME which is required to book a meeting with us.</h3></font></div>";
	  echo " <meta http-equiv=\"refresh\" content=\"3;URL=form.php\"> ";
  exit;
} 

if(empty($company)) { 
      echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h3>You didn't fill in the COMPANY which is required to book a meeting with us.</h3></font></div>";
	  echo " <meta http-equiv=\"refresh\" content=\"3;URL=form.php\"> ";
  exit;
} 

if(empty($email)) { 
      echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h3>You didn't fill in the E-MAIL which is required to book a meeting with us.</h3></font></div>";
	  echo " <meta http-equiv=\"refresh\" content=\"3;URL=form.php\"> ";
  exit;
} 

if(empty($meet)) { 
      echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h3>You didn't check in the PERSON WITH WHOM YOU WANT TO MEET, which is required to book a meeting with us.</h3></font></div>";
	  echo " <meta http-equiv=\"refresh\" content=\"3;URL=form.php\"> ";
  exit;
} 

if(empty($hour)) { 
      echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h3>You didn't fill in the TIME which is required to book a meeting with us.</h3></font></div>";
	  echo " <meta http-equiv=\"refresh\" content=\"3;URL=form.php\"> ";
  exit;
} 

if(empty($day)) { 
      echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h3>You didn't fill in the DAY which is required to book a meeting with us.</h3></font></div>";
	  echo " <meta http-equiv=\"refresh\" content=\"3;URL=form.php\"> ";
  exit;
} 

else { 




      mail($to, $sub, $EmailBody, $headers); 
      echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h2>Thank you ".$name.", your information has been sent. </h2></font></div>";
	echo " <meta http-equiv=\"refresh\" content=\"3;URL=http://www.bastosviegas.com/\"> ";	  
} 

 

Problem is, it's giving me a programming error. I'm not sure where to put the "foreach" and I'm positive it shouldn't be like this. Apolagize my ignorance but could you please elaborate?

Link to comment
Share on other sites

Ok I got something working now. The following code displays the last name checked (not all yet, but least something is working):

 

$to = "pedropeixoto@live.com"; //
$name = $_POST['name']; 
$company = $_POST['company']; 
$email = $_POST['email'];
$meet = $_POST['meet'];
foreach ($meet as $m)
$hour = $_POST['hour'];
$quote = $_POST['quote'];
$day = $_POST['day'];
$sub = "On-line Medica 2008 meeting booking.";
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "Meeting information:";
$EmailBody = "Name: $name\nCompany: $company\nE-mail: $email\nMeeting with: $m. \nOn the $day at $hour\nAdditional details: $quote\n";

mail($to, $sub, $EmailBody, $headers); 
      echo "<div align='center'><font color='#1F451E' size=9 face='Verdana, Arial, Helvetica, sans-serif'><h2>Thank you ".$name.", your information has been sent. </h2></font></div>";
	echo " <meta http-equiv=\"refresh\" content=\"3;URL=http://www.bastosviegas.com/\"> ";	  
} 

 

The problem might be the way i output it in $emailBody variable.

 

$EmailBody = "Meeting with: $m. \n"; 

 

Is this correct?

 

 

Link to comment
Share on other sites

Hmm You need th have your checkboxes name or they won't get put in the array correctly

 

You code:

<input name="meet[]2" type="checkbox" id="meet[]2" value="Carla João Ribeiro" />
  Carla João Ribeiro<br />
<input name="meet[]3" type="checkbox" id="meet[]3" value="Vitália Barros" />
  Vitália Barros<br />

 

The meet[]2 and meet[]3 should be just meet[].

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.