kimikai Posted March 14, 2014 Share Posted March 14, 2014 Got most of my form done and everything works perfectly...but since i set all values to be returned after error it seems like it wont read the error for my checkbox anymore, and it doesnt show in my mail anymore either (before it would be "Accept: on") does anyone know how this is possible? cuz i believe theres nothing wrong about my code... Error check for the checkbox 'akkoord' if (!empty($_POST['akkoord'])) { $akkoord = $_POST['akkoord']; } else { $error .= "- U moet akkoord gaan met de voorwaarden voordat u het bericht kunt versturen. <br />";} } This is to set it should send the info (aka it has been ticked) within the mail $message .= 'Akkoord: ' .$akkoord . "\n"; And this is the HTML for the checkbox: <input type="checkbox" name="akkoord" id="akkoord" /> <label for="akkoord">Ik ga akkoord met de voorwaarden</label> Just in case something else is wrong and wants to check the full code ill add it as an attachment test.php Quote Link to comment https://forums.phpfreaks.com/topic/286969-my-accept-agreement-doesnt-show-up-in-mail-anymore/ Share on other sites More sharing options...
Ch0cu3r Posted March 14, 2014 Share Posted March 14, 2014 This is not quite right <input type="checkbox" name="akkoord" id="akkoord" value="<?php if(isset($_POST['akkoord'])) echo 'checked="checked"'; ?> />"> The php code should be outside of the value <input type="checkbox" name="akkoord" id="akkoord" value="Ja" <?php if(isset($_POST['akkoord'])) echo 'checked="checked"'; ?> /> Quote Link to comment https://forums.phpfreaks.com/topic/286969-my-accept-agreement-doesnt-show-up-in-mail-anymore/#findComment-1472619 Share on other sites More sharing options...
kimikai Posted March 15, 2014 Author Share Posted March 15, 2014 is that all thats bothering it, cuz w/o the echo it didnt work either... Quote Link to comment https://forums.phpfreaks.com/topic/286969-my-accept-agreement-doesnt-show-up-in-mail-anymore/#findComment-1472690 Share on other sites More sharing options...
Ch0cu3r Posted March 15, 2014 Share Posted March 15, 2014 (edited) You say the checkbox value is not being set in the message. This is because with your original code no value is being set for that checkbox. checked="checked" is not the value, it is an attribute to mark the checkbox as checked when the form is reloaded again if your form did not pass validation. My code sets a value for the checkbox ( value="Ja" ) Ja should show up next to Akkoord: in the message Edited March 15, 2014 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/286969-my-accept-agreement-doesnt-show-up-in-mail-anymore/#findComment-1472691 Share on other sites More sharing options...
kimikai Posted March 15, 2014 Author Share Posted March 15, 2014 ahhh okay, now i get you haha darn really need to get more comfortable with php thnx for the amazing help Quote Link to comment https://forums.phpfreaks.com/topic/286969-my-accept-agreement-doesnt-show-up-in-mail-anymore/#findComment-1472700 Share on other sites More sharing options...
kimikai Posted March 15, 2014 Author Share Posted March 15, 2014 nope still not working, i literally copied your code and replaced mine with it. and indeed it does keep the checkbox ticked now when form submission fails... but im still having the same trouble with the rest as before, It still doesnt show the error set for "akkoord" at the top with the rest of the errors, basically now it doesnt matter whether or not i check the box or not, it sends the form anyway. and the value set for it still doesnt show up in the mail... im really at a loss for whats wrong I also tried the code without the echo for the checkbox but it gives me the same results you can send it w/ or w/o checking the box and the value wont show on the mail Quote Link to comment https://forums.phpfreaks.com/topic/286969-my-accept-agreement-doesnt-show-up-in-mail-anymore/#findComment-1472701 Share on other sites More sharing options...
Ansego Posted March 15, 2014 Share Posted March 15, 2014 Just curious what's .= do? The dot before? Also seen :: ?? Quote Link to comment https://forums.phpfreaks.com/topic/286969-my-accept-agreement-doesnt-show-up-in-mail-anymore/#findComment-1472702 Share on other sites More sharing options...
Solution Ch0cu3r Posted March 15, 2014 Solution Share Posted March 15, 2014 (edited) Gone through your code and their is a closing brace out of place. The } on line 160 should be on line 136. This is what is causing the value of akkoord and many other fields to not be included in the message. Just curious what's .= do? it is the concatenation assignment operator. Also seen :: ?? it is for accessing a static method/property within a class. It is mainly used in OOP (Object Oriented Programming) Edited March 15, 2014 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/286969-my-accept-agreement-doesnt-show-up-in-mail-anymore/#findComment-1472705 Share on other sites More sharing options...
Ansego Posted March 15, 2014 Share Posted March 15, 2014 Cheers thanks @Ch0cu3r - Sorry to high jack this thread. Quote Link to comment https://forums.phpfreaks.com/topic/286969-my-accept-agreement-doesnt-show-up-in-mail-anymore/#findComment-1472708 Share on other sites More sharing options...
kimikai Posted March 15, 2014 Author Share Posted March 15, 2014 you're amazing O_O thats all there was indeed Quote Link to comment https://forums.phpfreaks.com/topic/286969-my-accept-agreement-doesnt-show-up-in-mail-anymore/#findComment-1472716 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.