0

I am currently trying to make a small world cup pool for a few friends of mine, and I want to create a simple PHP form with drop down boxes to select the games for ease of access.

I want the form to have a field for Name, and then a drop down for each game.

I was trying to edit a stock contact form I found online - but it has more PHP than I know what to do with, and I cannot seem to find one specifically with drop down menus only.

I know the HTML/CSS Side of things, but cannot figure out how to make it submit the form content to my email.

Could anyone point me in the right direction, or provide me a template to work with?

THANKS!

EDIT:

Awesome, thanks @David Corbin & @Cody (http://www.kirupa.com/web/php_contact_form3.htm)

I've got it too work, appreciate everyone's help so far and Ill post it when I got it working.

PHP (mailer2.php)

$to = "email@email.com";
$subject = "World Cup Challenge";
$name_field = $_POST['name'];
$email= $_POST['email'];
$match_name= $_POST['match_name'];

$check_msg ="";
foreach($_POST['check'] as $value) {
$check_msg .= "Checked: $value\n";
}
$body = "Match: $match_name\n $check_msg"; 
$body = "From: $name_field - ($email) \n $check_msg";

mail($to, $subject, $body);
echo "Data has been submitted to $to!";

} else {
echo "blarg!";
}
?>

HTML

<head>
<title>World Cup Challenge</title>
<style>
BODY{color:#000000; font-size: 8pt; font-family: Verdana}
.button {background-color: rgb(128,128,128); color:#ffffff; font-size: 8pt;}
.inputc {font-size: 8pt;}
.style3 {font-size: xx-small}
</style>
</head>

<form method="POST" action="mailer2.php">
Name:
<input type="text" name="name" size=""><br>
<br>
<input type="text" name="email" size=""><br>
<br>
 Brazil VS Cameroon
<input type="hidden" name="match_name" value="Brazil VS Cameroon"> 
<br>
<input type="checkbox" name="check[]" value="Brazil"> Brazil<br>
<input type="checkbox" name="check[]" value="Cameroon"> Cameroon<br>
<br>
<input type="submit" value="Submit" name="submit">
</form>

It submits to me the value, but how can I also make it submit to me the name of the Matchup? (eg. Brazil VS Cameroon)

Thanks!

Cody
  • 905
  • 1
  • 8
  • 14
Colin
  • 329
  • 2
  • 6
  • 16
  • This is way too basic. Google search will throw up tons of tutorials. Just search for `php form email` and you would be good to go. Btw, the question title doesn't seem to match the content – asprin May 28 '14 at 04:25
  • @Zonik He's obviously new to stack overflow. At least give him some helpful feedback, even if it boils down to "do your own research". – Cully May 28 '14 at 04:29
  • I am new, and it is ok - I presumed to be scrutinized a bit for my lack of knowledge. I have done a fair bit of searching around. The duplicate post you linked @CullyLarson seems to be exactly what I need. Thanks again! – Colin May 28 '14 at 04:32
  • That is working well, I just cannot understand adding the drop down menus and having that content send, I do not need a message, user email, or firstname last name. Just drop down menus - is that an easy edit? – Colin May 28 '14 at 04:36
  • @CGKeaton I guess, This may be the one you needed . follow the link bellow. http://www.kirupa.com/web/php_contact_form3.htm – Cody May 28 '14 at 04:39
  • @Cody thats awesome, is it easy to make them drop downs, or only make 1 box selectable? THANKS! – Colin May 28 '14 at 04:47
  • @CGKeaton since they are checkboxes it can be selected by multiples, what do you mean by dropdowns? – Cody May 28 '14 at 05:09
  • Hey @Cody please checky my updated question! Thanks for all your help so far. – Colin May 28 '14 at 05:12
  • @CGKeaton yes, any errors you are getting? – Cody May 28 '14 at 05:13
  • Nope! The email sends perfect, but I want to receive in the email, NAME, Match NAME (Team A VS Team B), and the users pick! All I get currently is the Name (of player) and the checked box. Thanks! – Colin May 28 '14 at 05:15
  • @CGKeaton i edited your answer. just check it out. – Cody May 28 '14 at 05:25
  • Hey @Cody that adds an email field, and does not send the match name. I am not sure why! NVM - I got it by adding $match_name to the mailto field. – Colin May 28 '14 at 06:58
  • Now how can I add multiple on one page? as I will need roughly 50 options/matches? – Colin May 28 '14 at 07:08
  • @CGKeaton you can repeat checkboxes as you want. – Cody May 28 '14 at 08:31
  • It doesnt seem to work, it only gives me the name of 1 match (maybe because its match_name?) Thanks – Colin May 28 '14 at 20:22

1 Answers1

0

If you have the form you want, then all you need to do is be able to send it to a server and then mail it.

Make sure your form has an action and method attribute. For example, <form action="submit.php" method="post">

Then you need to write a server-side php script for parsing the text passed to it. Create submit.php and add in it

<?php
    print_r($_POST);

This script should direct you to a page that shows you all your form data. Once your there your well on your way to getting a working form.

To get the form to be able to be emailed, look into the php mail() function.

David Corbin
  • 524
  • 2
  • 11
  • 25