runnerjp Posted May 31, 2008 Share Posted May 31, 2008 $check = ''; if($forumlock==1) { $check = "CHECKED"; } <input type='checkbox' name='forumlock' $check /> but it does not check if checked :S Quote Link to comment Share on other sites More sharing options...
paulman888888 Posted May 31, 2008 Share Posted May 31, 2008 Explain more please and put your code in tags. You seem to be buliding your own forum system but why can't you use already made ones. Quote Link to comment Share on other sites More sharing options...
blueman378 Posted May 31, 2008 Share Posted May 31, 2008 you are not getting it from the form, is your form using post or get? anway you will need this: $check = ''; $forumlock = $_GET['forumlock']; // use this line if it is get $forumlock = $_POST['forumlock']; // use this line if it is post if($forumlock==1) { $check = "CHECKED"; } <input type='checkbox' name='forumlock' /> i believe thats what you are after, oh and to answer paulman8888888's question about the forum, building a forum is a good exercise to get better at your php skills as it involves alot of different techniques, i know i did it myself purly because i could. Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 31, 2008 Author Share Posted May 31, 2008 hey blueman... ur correct i want it to A. be able to teach my php more as im still poor lol and its helping alot and B. make the froum how I want it ok what you said above wont work as it needs to collect the value from my db... <?php $forumlock=0;// default value if it's not set if (isset($_POST['edit'])) { if(isset($_POST['forumlock'])){ $forumlock=1; }else{ $forumlock=0; } $title = $_POST['title']; $query = "UPDATE forumtutorial_posts SET forumlock = '$forumlock', title = '$title' WHERE postid='$getthreads3[postid]' "; mysql_query($query) or die('Error, query failed'); echo "Your title is ". $title . "<br />"; }else{ $check = ''; if($forumlock==1) { $check = "CHECKED"; } ?> <h4> </h4> <form name='input' action='index.php?page=forum&forum=<?php echo $forum ?>' method='post'> Title: <input class='input' name='title' type='text' value='<?php echo $getthreads3[title];?>' /> <br/> <input type='checkbox' name='forumlock' $check> Lock a Room<br/> <input type='submit' name='edit' value='edit'/> </form> <? } ?> Quote Link to comment Share on other sites More sharing options...
thebadbad Posted May 31, 2008 Share Posted May 31, 2008 The correct (X)HTML is checked="checked" and not "CHECKED". Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 31, 2008 Author Share Posted May 31, 2008 this still shows by checkbox unchecked even if it checked Quote Link to comment Share on other sites More sharing options...
thebadbad Posted May 31, 2008 Share Posted May 31, 2008 Learn to do some error checking. Echo the variables concerned, and see if they contain what you expect. Quote Link to comment Share on other sites More sharing options...
thebadbad Posted May 31, 2008 Share Posted May 31, 2008 And remember single or double quotes around strings. You forgot that in your query and further down: $getthreads3[postid] should be $getthreads3['postid']. And of course, the single quotes will break your syntax if you're not rearranging things a bit (in the query). Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 31, 2008 Author Share Posted May 31, 2008 and i also forgot the main thing on why it was not working = <? echo $check ?> Quote Link to comment 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.