WilliamGrant Posted October 10, 2010 Share Posted October 10, 2010 Hey guys, So basically I created a page where people fill out some information such as their name, e-mail, phonenumer etc. This works perfectly by now. I also would like them to be able to check 6 checkboxes as optional fields something like: "I like to eat : (checkbox 1 ) cookies - (checkbox 2 ) chocolate .. etc" So when I give each html checkbox a name and id such as "cookies" how do I process this information in my php formscript? would it look like this? <?php session_start(); if(isset($_POST['Submit'])) { $youremail = '[email protected]'; $fromsubject = 'subject email'; $chocolate = $_POST['chocolate']; $cookies = $_POST['cookies']; $to = $youremail; $mailsubject = ''.$fromsubject.' actionpage'; $body = $fromsubject.' Cookies: '.$cookies.' ?> The idea is that I will receive an e-mail that will tell me whether a box was checked or not and I am not sure how to make it work exactly. any help would be really awesome! William Link to comment https://forums.phpfreaks.com/topic/215563-how-can-i-add-various-checkboxes-to-my-form-fillout-page/ Share on other sites More sharing options...
ChadNomad Posted October 10, 2010 Share Posted October 10, 2010 I think* you would need a unique name for each checkbox. If a checkbox is ticked/tiked it posts as "on". So... if($_POST['checkbox_name'] == "on") { // It's checked } Link to comment https://forums.phpfreaks.com/topic/215563-how-can-i-add-various-checkboxes-to-my-form-fillout-page/#findComment-1120863 Share on other sites More sharing options...
WilliamGrant Posted October 10, 2010 Author Share Posted October 10, 2010 Hi Chad! Thanks for you reply! This certainly looks like the direction I need. Would you mind expanding a little bit on this idea? I'll be honest, I'm a graphic designer and learning my way into PHP but I'm really not that good at it (yet) haha Anyway, If you could direct me a little in where I should I place that "if statement" and how I can make it appear in my e-mail box like you said, I would technically be done with my website finally :-) right now the output of a mail being sent to me through the form looks something like: Name : jreklgfjer Address : fjerkfn Phone : 572348953 So I think when a box was checked it should appear something like this in my mailbox additional boxes checked: Cookies Chocolate Pie I hope this makes sense lol Much thanks! William Link to comment https://forums.phpfreaks.com/topic/215563-how-can-i-add-various-checkboxes-to-my-form-fillout-page/#findComment-1120866 Share on other sites More sharing options...
chmpdog Posted October 11, 2010 Share Posted October 11, 2010 well if your going to email it you need a mail function. Link to comment https://forums.phpfreaks.com/topic/215563-how-can-i-add-various-checkboxes-to-my-form-fillout-page/#findComment-1120960 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.