GreenSpark Posted March 2, 2013 Share Posted March 2, 2013 (edited) Hey fellas, I recently decided to start my personal database on monsters in a game and have a website with forms etc where I can enter new monsters. Now I've made a start, but I'm getting a line 15 error when trying to execute the form without having an input button ticket. The file including the form that's related to the error (newmonster.php): </tr><tr> <td>Attribute:</td> <td><input type="radio" name="attribute" value="dark" />Dark <input type="radio" name="attribute" value="earth" />Earth <input type="radio" name="attribute" value="fire" />Fire <input type="radio" name="attribute" value="light" />Light <input type="radio" name="attribute" value="water" />Water <input type="radio" name="attribute" value="wind" />Wind</td> And this is the part of the file it's submitting the form to: Line 15 is the line between $type and $attack. The one with $attribute declaration. function invoer_schoonmaken($tekst) { $tekst = strip_tags($tekst); $tekst = htmlspecialchars($tekst); return $tekst; } $naam = invoer_schoonmaken($_POST["naam"]); $type = invoer_schoonmaken($_POST["type"]); $attribute = invoer_schoonmaken($_POST["attribute"]); $attack = invoer_schoonmaken($_POST["attack"]); $defense = invoer_schoonmaken($_POST["defense"]); $stars = invoer_schoonmaken($_POST["stars"]); $description = invoer_schoonmaken($_POST["description"]); $booster = invoer_schoonmaken($_POST["booster"]); The error is gives: So basically, what have I done wrong with the coding here? I'm not skilled in php in any way so I'm just trying to brush it up a bit with some MySQL later, so any constructive help would be greatly appreciated. Edited March 2, 2013 by GreenSpark Quote Link to comment https://forums.phpfreaks.com/topic/275122-radio-buttons-input-error/ Share on other sites More sharing options...
rgopal101 Posted March 2, 2013 Share Posted March 2, 2013 try this, $attribute = invoer_schoonmaken($_POST['attribute']); or $attribute = $_POST['attribute']; $attribute=invoer_schoonmaken($attribute); Quote Link to comment https://forums.phpfreaks.com/topic/275122-radio-buttons-input-error/#findComment-1416000 Share on other sites More sharing options...
GreenSpark Posted March 2, 2013 Author Share Posted March 2, 2013 Thanks, I tried both but it doesn't seem to have a better result. The other options in the form I used <option> method and that doesn't seem to bug, maybe i'll use that instead. Still this should also be possible I guess, so please do assist if you think you have the solution Quote Link to comment https://forums.phpfreaks.com/topic/275122-radio-buttons-input-error/#findComment-1416005 Share on other sites More sharing options...
Jessica Posted March 2, 2013 Share Posted March 2, 2013 You need to check if it's set before trying to use it. isset. Quote Link to comment https://forums.phpfreaks.com/topic/275122-radio-buttons-input-error/#findComment-1416006 Share on other sites More sharing options...
Solution GreenSpark Posted March 2, 2013 Author Solution Share Posted March 2, 2013 Cheers, that did the trick! New code: $type = invoer_schoonmaken($_POST["type"]); $error_msg=""; if (!isset($_POST['attribute'])) { $error_msg.="<li >Geen attribute gekozen.</li>"; } else { $attribute = invoer_schoonmaken($_POST['attribute']); } $attack = invoer_schoonmaken($_POST["attack"]); Quote Link to comment https://forums.phpfreaks.com/topic/275122-radio-buttons-input-error/#findComment-1416008 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.