Hi Guys,
I am new to web developing. I found it fun and interesting so i start learning now. I created a Form using HTML with checkboxes and I managed to send it to email using PHP by creating one php file. Everything was fine but i noticed that i was not able to capture those values i selected within a checkboxes.
How can i get the value of my checkboxes from HTML Form to my PHP?
Thanks a lot in advance!
8 Replies - 776 Views - Last Post: 04 August 2009 - 01:35 AM
#1
Getting the value of checkboxes from HTML form to PHP
Posted 03 August 2009 - 09:27 PM
Replies To: Getting the value of checkboxes from HTML form to PHP
#2
Re: Getting the value of checkboxes from HTML form to PHP
Posted 03 August 2009 - 09:28 PM
Can you post your code?
You will need to reference the input names in your $_POST or $_GET array. It's going to be hard to assist you with out seeing what you have thus far.
You will need to reference the input names in your $_POST or $_GET array. It's going to be hard to assist you with out seeing what you have thus far.
#3
Re: Getting the value of checkboxes from HTML form to PHP
Posted 03 August 2009 - 09:28 PM
Why not start by showing us how you're attempting to do this (your code) then we can proceed from there
#4
Re: Getting the value of checkboxes from HTML form to PHP
Posted 03 August 2009 - 11:01 PM
Thanks a lot for your response and sorry if i was not able to show my codes. Below are my codes.
//here are my PHP codes
If my visitor choose 1 or more motortype, on email sent from the form those selected checkboxes should also be included.
Thanks again!
Mod Edit: Please use code tags when posting your code. Code tags are used like so =>
Thanks,
PsychoCoder
//here are my PHP codes
<?php $motortype1 = $_POST['motortype1']; $motortype2 = $_POST['motortype2']; $motortype3 = $_POST['motortype3']; $motortype4 = $_POST['motortype4']; $motortype5 = $_POST['motortype5']; $company_email = 'myemail@yahoo.com'; $subject = 'Online Registration'; $headers .= "Online Registration Request:\n"; $msg .= "If yes, what type?: \n $motortype1\n"; mail($company_email, $subject, $msg, $headers); ?> //and here are my HTML code for my Form <tr> <td height="32" class="style11"> <div align="left">If yes, what type? </div></td> <td width="90" height="28" class="style11"> <div align="left"> <input type="checkbox" name="motortype1" value="Cruiser" /> Cruiser </div></td> <td width="84" class="style11"> <div align="left"> <input type="checkbox" name="motortype2" value="Tourer" /> Tourer </div></td> <td height="28" class="style11"> <div align="left"> <input type="checkbox" name="motortype3" value="Sports Tourer" /> Sports Tourer </div></td> <td width="69" height="28" class="style11"> <div align="left"> <input type="checkbox" name="motortype4" value="Sport" /> Sport </div></td> <td width="81" height="32" class="style11"> <div align="left"> <input type="checkbox" name="motortype5" value="Other" /> Other </div></td> </tr>
If my visitor choose 1 or more motortype, on email sent from the form those selected checkboxes should also be included.
Thanks again!
Mod Edit: Please use code tags when posting your code. Code tags are used like so =>
Thanks,
PsychoCoder
#5
Re: Getting the value of checkboxes from HTML form to PHP
Posted 04 August 2009 - 12:18 AM
change your PHP code
and also is this your all HTML code?
<?php $motortype1 = isset($_POST['motortype1']) ? $_POST['motortype1'] : 0; $motortype2 = isset($_POST['motortype2']) ? $_POST['motortype2'] : 0; $motortype3 = isset($_POST['motortype3']) ? $_POST['motortype3'] : 0; $motortype4 = isset($_POST['motortype4']) ? $_POST['motortype4'] : 0; $motortype5 = isset($_POST['motortype5']) ? $_POST['motortype5'] : 0; $company_email = 'myemail@yahoo.com'; $subject = 'Online Registration'; $headers .= "Online Registration Request:\n"; $msg = "If yes, what type?: \n $motortype1\n"; mail($company_email, $subject, $msg, $headers); ?>
and also is this your all HTML code?
This post has been edited by noorahmad: 04 August 2009 - 12:47 AM
#6
Re: Getting the value of checkboxes from HTML form to PHP
Posted 04 August 2009 - 12:39 AM
The variable $MSG must exist before you can concatenate to it.
#7
Re: Getting the value of checkboxes from HTML form to PHP
Posted 04 August 2009 - 12:48 AM
Opps.!!!!!!!!!!!!!! changed.
This post has been edited by noorahmad: 04 August 2009 - 12:50 AM
#8
Re: Getting the value of checkboxes from HTML form to PHP
Posted 04 August 2009 - 01:05 AM
Project done. Thanks a lot guys! you are all helpful.
#9
Re: Getting the value of checkboxes from HTML form to PHP
Posted 04 August 2009 - 01:35 AM
Glad to see that you got it working
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|