Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Designing a Contact Form in PHP/ checkbox?

New Here ,
Nov 19, 2009 Nov 19, 2009

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.

TOPICS
Server side applications
660
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 19, 2009 Nov 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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 19, 2009 Nov 19, 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!

>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 19, 2009 Nov 19, 2009

Sure it would be something like this:

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

What Are Your Interests?

User Input


<?php } ?>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 19, 2009 Nov 19, 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 } ?>

>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 19, 2009 Nov 19, 2009

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

  }

?>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 19, 2009 Nov 19, 2009
LATEST

Hey,

I am sorry to have so many questions.

But my code is pretty simple. And it works.

As soon as I add a snippet of code from below it stops working.

Can we try I again? Starting with the input textfield for name, which I've

labeled - firstName

What code should I add to below to make the name field information appear in

the generated email? I am going to try an go slow because I can;t seem to

get it all at once.

Current code below:

<?php

$to = "thomas@reelcreative.tv";

$subject = $_POST['subject'];

$name = $_POST['firstName'];

$body = $_POST['messageBody'];

$headers = "From: " .

$_POST['emailAddress'] . "\n";

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

?>

Suggested code below:

It doesn't seem to work for me?

Ya would look similar to this:

 

<?php

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

  $to = 'mailto: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);

  }

?>

>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 19, 2009 Nov 19, 2009

Can you show me the if statement?

Sorry -

My current code is:

What are your interests?





I don't see how this code would be written correctly?

Is the recordset name the name as my database name?

I am using the name modernmortgage as my database.

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

What Are Your Interests?

 

User Input

 

<?php } ?>

What are your interests?





</p

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines