PeteMcC Posted July 22, 2013 Share Posted July 22, 2013 Hoping some of you guys can help me, I'm not overly familiar with coding and such but I've been asked to design a website for a friend, I'm using Dreamweaver CS4 and I need a form with three text fields and two check boxes. I've managed to find an online resource that allows you to create your own form in HTML with a php command script to email it to me, but only with text fields. When I've tried to insert check boxes in the HTML and alter the php it just messes everything up and the script doesn't work. does anyone know an easy way to create a form in HTML and a command script in php which will send it to an email address without redirecting the visitor to their email package? I've attached a screen shot of the form I've created and the feedback.php file that I got from the free site. Basically I want to know what I need to do to that php file to make it work, or will it ever work? do I need to go down another route to get this to happen. I must have lost two days to this and anyone I've spoken to who would know assures me that it should be straightforward but 'doesn't have time to look at it'.. any help gratefully received! feedback.php Quote Link to comment https://forums.phpfreaks.com/topic/280384-help-with-a-simple-form/ Share on other sites More sharing options...
Solution mac_gyver Posted July 22, 2013 Solution Share Posted July 22, 2013 whatever name you gave each check-box form field will be set when the check-box is checked and won't be set if it is not checked. you would then probably want to have a conditionally statement to produce a yes/no indication to insert into your email message for each check-box. php has an instruction to test if a variable is set, surprisingly its called - isset() $ck1 = 'no'; // default to no/not checked if(isset($_POST['your_check_box_name_1'])){ $ck1 = 'yes'; } $ck2 = 'no'; // default to no/not checked if(isset($_POST['your_check_box_name_2'])){ $ck2 = 'yes'; } // then just include the $ck1,$ck2 strings when building your email message "some legend for check-box 1: $ck1" . $content_nl . "some legend for check-box 2: $ck2" . $content_nl . Quote Link to comment https://forums.phpfreaks.com/topic/280384-help-with-a-simple-form/#findComment-1441634 Share on other sites More sharing options...
PeteMcC Posted July 22, 2013 Author Share Posted July 22, 2013 Thanks for the reply, I've been looking at stuff like this before, but when I try and place any of it into the php code I already have it causes it to fail ad not send a mail, can you tell me where I need to place what? Apologies if this sounds dumb as I'm a total noob to this sort of thing. Quote Link to comment https://forums.phpfreaks.com/topic/280384-help-with-a-simple-form/#findComment-1441641 Share on other sites More sharing options...
cyberRobot Posted July 22, 2013 Share Posted July 22, 2013 Have you considered using a third-party alternative? Google forms, for example, are free and can be embedded within an existing website. https://support.google.com/drive/answer/87809?hl=en JotForm is another nice option. They have a free service plan and can be embedded. http://www.jotform.com/ If you still want to build your own form (or download one from the Web), be mindful that there are risks. For example, online forms will likely be targeted for injection attacks. If you're interested, there are many tips online for avoiding e-mail injection: https://www.google.com/search?q=email+injection+php Note that I didn't download your code, so perhaps this is already taken care of. Quote Link to comment https://forums.phpfreaks.com/topic/280384-help-with-a-simple-form/#findComment-1441660 Share on other sites More sharing options...
mac_gyver Posted July 22, 2013 Share Posted July 22, 2013 can you tell me where I need to place what? afraid not. if you are not at the point that you will even make an attempt, you are not yet ready to leave the temple, grasshopper... Quote Link to comment https://forums.phpfreaks.com/topic/280384-help-with-a-simple-form/#findComment-1441668 Share on other sites More sharing options...
PeteMcC Posted July 22, 2013 Author Share Posted July 22, 2013 whatever name you gave each check-box form field will be set when the check-box is checked and won't be set if it is not checked. you would then probably want to have a conditionally statement to produce a yes/no indication to insert into your email message for each check-box. php has an instruction to test if a variable is set, surprisingly its called - isset() $ck1 = 'no'; // default to no/not checked if(isset($_POST['your_check_box_name_1'])){ $ck1 = 'yes'; } $ck2 = 'no'; // default to no/not checked if(isset($_POST['your_check_box_name_2'])){ $ck2 = 'yes'; } // then just include the $ck1,$ck2 strings when building your email message "some legend for check-box 1: $ck1" . $content_nl . "some legend for check-box 2: $ck2" . $content_nl . afraid not. if you are not at the point that you will even make an attempt, you are not yet ready to leave the temple, grasshopper... Fair enough! I was just trying to save myself a bit more head melting! (I'm a graphic designer, not a web guy) I was just about to post you a message, I figured it out anyway, so I really appreciate what you've done, thank you so much. It works! I'm a happy man! You're a saint Quote Link to comment https://forums.phpfreaks.com/topic/280384-help-with-a-simple-form/#findComment-1441701 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.