Checkboxes

Hello,

I’m a complete noob to PHP & SQL, though I’ve done lots of HTML, CSS and various OO coding in the past.

I run a forum using Flux BB’s software with a few tweaks. I’m looking to do much more with it but I simply don;t have the understanding yet.

I’ve acquired a few PHP eBooks and intend to start teaching myself.

For now, I need help with this.

This is basically an moderator option when editing a post, to do it ‘silently’, ie no record it has been edited. By default, the checkbox is set to silent, but my mods keep forgetting to uncheck it (I want people to know when they’ve been edited and by whom), so I want to set the default to ‘unchecked’.

[php]if ($is_admmod)
{
if ((isset($_POST[‘form_sent’]) && isset($_POST[‘silent’])) || !isset($_POST[‘form_sent’]))
$checkboxes[] = ‘’.$lang_post[‘Silent edit’].’
’;
else
$checkboxes[] = ‘’.$lang_post[‘Silent edit’].’
’;
}
[/php]

I believe it is in there somewhere but as a noob I can’t figure it out.

Thanks in advance.

Try this.

[php]<?php
if ($is_admmod)
{
if ((isset($_POST[‘form_sent’]) && isset($_POST[‘silent’])) || !isset($_POST[‘form_sent’])) {
$checkboxes[] = ‘’.$lang_post[‘Silent edit’].’
’; }
else {
$checkboxes[] = ‘’.$lang_post[‘Silent edit’].’
’; }
}
?>[/php]

Let me know.

Yeah that did the trick thanks, as simple as removing the checked=“checked” bit I see.

May I ask, what the purpose of the additional {} was? I reverted back to the same format as previous, thus removing them and sticking it all in one line, is the version I put up simply a ‘shorthand’ version?

Actually I think all I did was switch the actions in your if and else expression. Instead of if x do y or else z, I made it if x do z or else y…

Code is a hassle to read if you have to scroll to the sides in addition to up and down. And if the “what I want to perform” part of an if statement lasts more than 1 line, I like to use brackets to make sure it completes everything I want done. I think the official rule is that you can have one command (or one semi colon) and you don’t need brackets. Otherwise you need them. From code I’ve read online, it seems like it’s standard practice to use brackets, although I must admit I use your shorthand form sometimes too.

Sponsor our Newsletter | Privacy Policy | Terms of Service