Skip to main content
Known Participant
November 19, 2009
Question

Designing a Contact Form in PHP/ checkbox?

  • November 19, 2009
  • 1 reply
  • 659 views

Hi,

I am working on a very basic dynamic application.

It is a form I've put together from 2 different tutorials.

So please disregard the content.

Most of it is working.

The trouble I am having is coding the check box.

If you test the form at: ---visit Contact button

http://www.modernmortgagedirect.com

Select the contact button.

The from generates a results page, but it doesn't accurately display the selections for the the question - "What are your interests?"

The choices are Twisting, Juggling, and Clowning.

They are check boxes. No matter how many of them, are sleeted only one response displays in the result page.

I am not sure how to code these and create an appropriate bidding.

It seems like I need to make the the 3 of these choices unique even though they are part of one group.

I am not sure the best way to execute.

Thanks foray input you might offer.

This topic has been closed for replies.

1 reply

Inspiring
November 19, 2009

I inspected the code for your contact form. If you want all of the selected check boxes to appear you must give each one a unique name or id, otherwise they will work like a radio group. Just give them a different name and id and it will work just fine!

Known Participant
November 20, 2009

Hello-

That is great! My form works- do you think you might be able to clue me in

on writing a simple 'if' statement?

For the same group of check boxes and questions.

I would like to have an if statement. If nothing is checked than on the

results page I want the subheading with the question - what are your

interests not to appear.

Here is link to contact page:

http://modernmortgagedirect.com/contact2.php

Thank you for the help!

I inspected the code for your contact form. If you want all of the selected

check boxes to appear you must give each one a unique name or id, otherwise

they will work like a radio group. Just give them a different name and id and

it will work just fine!

>

Inspiring
November 20, 2009

Hey thanks again!

I am going to come back to this -

D you know if it is possible to display all the infomration gathered from a

form in an email generated when the user submits it?

I am using this script to generate an email:

<?php

$to = "thomas@reelcreative.tv";

$subject = $_POST['subject'];

$body = $_POST['messageBody'];

$headers = "From: " . $_POST['emailAddress'] .

"\n";

mail($to,$subject,$body,$headers);

?>

But it will only display text entered into the comments field which I have

labeled as 'messageBody".

How would I get all of my results to display in an email generatted by the

from being submitted?

Thank You so much in Advance!

Sure it would be something like this:

 

<?php if ($totalRows_**YourRecordsetName** > 0) {  ?>

What Are Your Interests?

 

User Input

 

<?php } ?>

>


Ya would look similar to this:

<?php

if (array_key_exists('***FormButton***', $_POST)) {

  $to = 'thomas@reelcreative.tv';

  $subject = $_POST['subject'];

  $name = $_POST['firstname'];

  $email = $_POST['emailAddress'];

  $comments = $_POST['messageBody'];

  $twister = $_POST['ballontwister'];

  $performer = $_POST['performerquestion'];

  $twisting = $_POST['twisting'];

  $juggling = $_POST['juggling'];

  $clowning = $_POST['clowning'];

  $typeofballons = $_POST['typeofballons']; 

  $message = "Name: $name\n\n";

  $message .= "Email: $email\n\n";

  $message .= "Comments: $comments";

  $message .= "Twisting: $twisting\n\n";

   //so on and so forth

  $mailSent = mail($to, $subject, $message);

  }

?>