Checkboxes not working PHP - php

I have a problem in the WP-Pro-Quiz plugin for WordPress. There are "Single Answer Options" that are visible, but not selectable. I need these options, I was thinking I might be able to get the checkboxes to function and in turn get the result I need in my quiz.
What is causing these checkboxes to be "Greyed Out"?
<?php
}
private function singleChoiceOptions($data)
{
$single = $data[0];
?>
<div class="postbox" id="singleChoiceOptions">
<h3 class="hndle"><?php _e('Single choice options', 'wp-pro-quiz'); ?></h3>
<div class="inside">
<p class="description">
<?php _e('If "Different points for each answer" is activated, you can activate a special mode.<br> This changes the calculation of the points',
'wp-pro-quiz'); ?>
</p>
<label>
<input type="checkbox" name="answerPointsDiffModusActivated"
value="1" <?php $this->checked($this->question->isAnswerPointsDiffModusActivated()); ?>>
<?php _e('Different points - modus 2 activate', 'wp-pro-quiz'); ?>
</label>
<br><br>
<p class="description">
<?php _e('Disables the distinction between correct and incorrect.', 'wp-pro-quiz'); ?><br>
</p>
<label>
<input type="checkbox" name="disableCorrect"
value="1" <?php $this->checked($this->question->isDisableCorrect()); ?>>
<?php _e('Disable correct and incorrect.', 'wp-pro-quiz'); ?>
</label>
<div style="padding-top: 20px;">
<?php _e('Explanation of points calculation', 'wp-pro-quiz'); ?>
<?php $this->answerPointDia(); ?>
</div>
</div>
</div>
<?php
}

The are gray because the are disabled by disabled="enabled", even if the value is enabled, the input gets disabled, any value will disable the input, in fact, you can just put disable and it will be disabled, latest browers just read disabled and disable the input. remove disabled="enabled" and the input will be enabled.

I figured it out, the name values weren't matching the $this value, capital letters. Plugin author must've missed it. Hopefully the function works.
<div class="inside">
<p class="description">
<?php _e('If "Different points for each answer" is activated, you can activate a special mode.<br> This changes the calculation of the points',
'wp-pro-quiz'); ?>
</p>
<label>
<input type="checkbox" name="AnswerPointsDiffModusActivated" value="1" <?php $this->checked($this->question->isAnswerPointsDiffModusActivated()); ?>>
<?php _e('Different points - modus 2 activate', 'wp-pro-quiz'); ?>
</label>
<br><br>
<p class="description">
<?php _e('Disables the distinction between correct and incorrect.', 'wp-pro-quiz'); ?><br>
</p>
<label>
<input type="checkbox" name="DisableCorrect"
value="1" <?php $this->checked($this->question->isDisableCorrect()); ?>>
<?php _e('Do not show correct and incorrect.', 'wp-pro-quiz'); ?>
</label>
<div style="padding-top: 20px;">
<?php _e('Explanation of points calculation', 'wp-pro-quiz'); ?>
<?php $this->answerPointDia(); ?>
</div>
</div>
</div>
<?php

Related

Comments are empty in WordPress

Despite that I have added the <?php comments_template(); ?> to single.php it seems like it's not working! I'm note sure, but why are the comments in the list of comments to be approved empty? The fields for name, email and URL and the content are empty for each comment.
Should the wp-comments-post.php be located together with the rest of the theme files or should it be together with the main files?
What could be the cause of this problem?
The function comments_template() looks for a file called comments.php in the root of your themes directory. The code inside comments.php should look like the following:
<!-- Display the comments -->
<?php if($comments) : ?>
<ol>
<?php foreach($comments as $comment) : ?>
<li id="comment-<?php comment_ID(); ?>">
<?php if ($comment->comment_approved == '0') : ?>
<p>Your comment is awaiting approval</p>
<?php endif; ?>
<?php comment_text(); ?>
<cite><?php comment_type(); ?> by <?php comment_author_link(); ?> on <?php comment_date(); ?> at <?php comment_time(); ?></cite>
</li>
<?php endforeach; ?>
</ol>
<?php else : ?>
<p>No comments yet</p>
<?php endif; ?>
<!-- Display the form -->
<?php if(comments_open()) : ?>
<?php if(get_option('comment_registration') && !$user_ID) : ?>
<p>You must be logged in to post a comment.</p><?php else : ?>
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<?php if($user_ID) : ?>
<p>Logged in as <?php echo $user_identity; ?>. Log out ยป</p>
<?php else : ?>
<p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" />
<label for="author"><small>Name <?php if($req) echo "(required)"; ?></small></label></p>
<p><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" />
<label for="email"><small>Mail (will not be published) <?php if($req) echo "(required)"; ?></small></label></p>
<p><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" />
<label for="url"><small>Website</small></label></p>
<?php endif; ?>
</form>
<?php endif; ?>
<?php else : ?>
<p>The comments are closed.</p>
<?php endif; ?>
however, if you have a different theme directory layout, for example a custom comments.php, you can pass its path in as the funcion parameter. For example, if your theme had a modules direcotry:
<?php comments_template('modules/custom-comments.php'); ?>
Conclusion
This could be a code problem or a misuse of the comments_template() function. I recommend you don't change any WordPress code as it will just be overriden by future updates.
This answer is based on: https://codex.wordpress.org/Function_Reference/comments_template
Code Drops taken from:
http://code.tutsplus.com/articles/unraveling-the-secrets-of-wordpress-commentsphp-file--net-28

add search ajax ability to this html form

I am stuck trying to add some ajax search ability to this php form. The form is already working but since I have many outputs, I want users to be able to search and select a profile from there. I tried jquery tablesorter and although it works, it's not quite what I was looking for.
Hope someone can help. Thanks. Here is the form.
<form action="<?php echo CRoute::getURI(); ?>" method="post" id="jomsForm" name="jomsForm" class="community-form-validate">
<div class="jsProfileType">
<ul class="unstyled">
<?php
foreach($profileTypes as $profile)
{
?>
<li class="space-12">
<label for="profile-<?php echo $profile->id;?>" class="radio">
<input id="profile-<?php echo $profile->id;?>" type="radio" value="<?php echo $profile->id;?>" name="profileType" <?php echo $default == $profile->id ? ' disabled CHECKED' :'';?> />
<strong class="bold"><?php echo $profile->name;?></strong>
</label>
<?php if( $profile->approvals ){?>
<span class="help-block"><?php echo JText::_('COM_COMMUNITY_REQUIRE_APPROVAL');?></span>
<?php } ?>
<span class="help-block">
<?php
$profile->description = JHTML::_('content.prepare',$profile->description);
echo $profile->description;?>
</span>
<?php if( $default == $profile->id ){?>
<em><?php echo JText::_('COM_COMMUNITY_ALREADY_USING_THIS_PROFILE_TYPE');?></em>
<?php } ?>
</li>
<?php
}
?>
</ul>
</div>
<?php if( (count($profileTypes) == 1 && $profileTypes[0]->id != $default) || count($profileTypes) > 1 ){?>
<div style="margin-top: 5px;">
<?php if( $showNotice ){ ?>
<span style="color: red;font-weight:700;"><?php echo JText::_('COM_COMMUNITY_NOTE');?>:</span>
<span><?php echo $message;?></span>
<?php } ?>
</div>
<table class="ccontentTable paramlist" cellspacing="1" cellpadding="0">
<tbody>
<tr>
<td class="paramlist_key" style="text-align:left">
<div id="cwin-wait" style="display:none;"></div>
<input class="btn btn-primary validateSubmit" type="submit" id="btnSubmit" value="<?php echo JText::_('COM_COMMUNITY_NEXT'); ?>" name="submit">
</td>
<td class="paramlist_value">
</td>
</tr>
</tbody>
</table>
<?php } ?>
<input type="hidden" name="id" value="0" />
<input type="hidden" name="gid" value="0" />
<input type="hidden" id="authenticate" name="authenticate" value="0" />
<input type="hidden" id="authkey" name="authkey" value="" />
</form>
I would suggest you Select2. It's a really well done jquery-based library with easy-to-use ajax and custom-rendering features. You can check the Loading Remote Data section of the documentation.
It can be configured to fetch data from the server, after N chars have been inserted by the user. Then you simply have to implement the server-side search action and with very few code you've a working (and very good looking) ajax selector.

editing HTML in Joomla pages

I'm no too used to or familiar with the Joomla system. SO I kind of need your help here. Here's my problem.
I'm building a site, but the template came with problems and the template makers refuse to accept they made a mistake. AS Templates Don't buy from these guys unless you don't care about being on your own if something happens.
Anyway, basically, the site's buttons are all out of alignment. I tried fixing them through CSS but no luck. Some things can't be fixed in the CSS files because they belong to the HTML part of it. But as some of you may know, Joomla is PHP not HTML. So my question is how do I fix an HTML line of code in Joomla?
To be specific:
I have this code in my site
<form name="logoutForm" method="post" action="/">
<button class="btl-buttonsubmit"onclick="document.logoutForm.submit();" name="Submit" style="">Log out</button>
<input type="hidden" value="com_users" name="option">
<input type="hidden" value="user.logout" name="task">
<input type="hidden" value="aW5kZXgucGhwP0l0ZW1pZD0xMDE=" name="return">
<input type="hidden" value="1" name="7b6cc3e246acff3e3943410a6f4919cf">
</form>
Since this is not PHP code or CSS I cant find it anywhere
Here are the screenshots of my two trouble areas
and
Thanks again
I'm re-editing this to add the code for the search results. Please review for me, refer to the screenshot as well to see what I see or go to my site and search for anything
<?php
defined('_JEXEC') or die;
$lang = JFactory::getLanguage();
$upper_limit = $lang->getUpperLimitSearchWord();
JHtml::_('bootstrap.tooltip');
?>
<form id="searchForm" action="<?php echo JRoute::_('index.php?option=com_search');?>" method="post">
<div class="btn-toolbar">
<div class="btn-group pull-left">
<input type="text" name="searchword" placeholder="<?php echo JText::_('COM_SEARCH_SEARCH_KEYWORD'); ?>" id="search-searchword" size="30" maxlength="<?php echo $upper_limit; ?>" value="<?php echo $this->escape($this->origkeyword); ?>" class="inputbox" />
</div>
<div class="btn group pull-left">
<button name="Search" onclick="this.form.submit()" class="button btn btn hasTooltip" title="<?php echo JText::_('COM_SEARCH_SEARCH');?>"><span class="icon-search"></span></button>
</div>
<input type="hidden" name="task" value="search" />
<div class="clearfix"></div>
</div>
<div class="searchintro<?php echo $this->params->get('pageclass_sfx'); ?>">
<?php if (!empty($this->searchword)):?>
<p><?php echo JText::plural('COM_SEARCH_SEARCH_KEYWORD_N_RESULTS', '<span class="badge badge-info">'. $this->total. '</span>');?></p>
<?php endif;?>
</div>
<fieldset class="phrases">
<legend><?php echo JText::_('COM_SEARCH_FOR');?>
</legend>
<div class="phrases-box">
<?php echo $this->lists['searchphrase']; ?>
</div>
<div class="ordering-box">
<label for="ordering" class="ordering">
<?php echo JText::_('COM_SEARCH_ORDERING');?>
</label>
<?php echo $this->lists['ordering'];?>
</div>
</fieldset>
<?php if ($this->params->get('search_areas', 1)) : ?>
<fieldset class="only">
<legend><?php echo JText::_('COM_SEARCH_SEARCH_ONLY');?></legend>
<?php foreach ($this->searchareas['search'] as $val => $txt) :
$checked = is_array($this->searchareas['active']) && in_array($val, $this->searchareas['active']) ? 'checked="checked"' : '';
?>
<label for="area-<?php echo $val;?>" class="checkbox">
<input type="checkbox" name="areas[]" value="<?php echo $val;?>" id="area-<?php echo $val;?>" <?php echo $checked;?> >
<?php echo JText::_($txt); ?>
</label>
<?php endforeach; ?>
</fieldset>
<?php endif; ?>
<?php if ($this->total > 0) : ?>
<div class="form-limit">
<label for="limit">
<?php echo JText::_('JGLOBAL_DISPLAY_NUM'); ?>
</label>
<?php echo $this->pagination->getLimitBox(); ?>
</div>
<p class="counter">
<?php echo $this->pagination->getPagesCounter(); ?>
</p>
<?php endif; ?>
</form>
mmm yea I can see what you mean. The template does have some issues. And that is not only your problem there are many places were you need to edit your stylesheet. But it's very hard to eyeball all of them and wrap all the solutions in one answer.
But as an advice you can use firebug if you are using firefox or google developer tools by pressing ctrl shift j to open them. You can edit some of your content live and see the changes that are needed to be done in specific places and then you just do them.
For example I found at the section CONTACT the upper right banner has it title popping out of the template. The fix is located in /templates/as002035/css/tmpl.custom.css line 11 by setting the padding to 0 0 20px.
When Creating an account a modal box splashes into my face. You need to fix that by editing the width and the height of that window again by using those tools.
Finally i cant see the logout button " form " since I can't register to your website due to the mail that was not sent in my e-mails. So probably you need a developer to fix all of these things.
I hope I helped a bit.
Besides the (good) advice already provided, there is a missing answer to your question: where does the HTML markup come from?
You will find it in one of two places: first check your template overrides (which I think is the case looking at your question), which would be located in
/templates/as002035/html/com_users/login/default_logout.php (logout component)
/templates/as002035/html/mod_login/ (login|logout module)
if they are not present, then the default Joomla layouts are in
/components/com_users/views/...
/modules/mod_login/tmpl
Added after clarification below, this is the answer the the comments.
you're missing a class "button" so the line of the module should be:
<input type="submit" value="Log out" class="button btn btn-primary" name="Submit">
instead of
<input type="submit" value="Log out" class="btn btn-primary" name="Submit">
(see the added "button"?). Did you find the template ? is it in the overrides? if you can just make that change you'll get the module fixed. As for the component logout form, http://www.guhlmotors.com/index.php?option=com_users
<button class="button btn" type="submit">Log out</button>
instead of
<button class="button" type="submit">Log out</button>

can't i display two session message in one page

i have been displaying two session messages in one page, rating. One message is displayed in every refresh showing the likes and dislikes. the other message in displayed once the rating form is submitted, the problem is once i submit the rating form the message displaying the rating isn't displayed. why is so??? can't i use two sessions in a page?? thanks
coding
<?php
if(!empty($_SESSION['error_msg'])){?>
<div style="text-align: center"><?php echo $_SESSION['error_msg'];?></div>
<?
session_unset($_SESSION['error_msg']);
}
?>
if(!empty($_SESSION['rate_msg'])){
echo $_SESSION['rate_msg'];
session_unset($_SESSION['rate_msg']);
}
?>
<form name="rating_form" action="" method="post">
<input type="hidden" name="g_id" value="<?php echo $ratings['gallery_id'];?>"/>
<input type="hidden" name="g_image" value="<?php echo $ratings['gallery_image'];?>"/>
<div style="text-align: center">
<input type="radio" name="rating" value="Hot" onclick="document.rating_form.submit();">Hot</input>
<input type="radio" name="rating" value="Not" onclick="document.rating_form.submit();">Not</input>
</div>
</form>
sorry i think my code is a bit confusing
my actual code looks like this
<div class="top_model">
<h1>Model Ratings</h1>
<?php
if(!empty($_SESSION['error_msg'])){?>
<div style="text-align: center"><?php echo $_SESSION['error_msg'];?></div>
<?
session_unset($_SESSION['error_msg']);
}
?>
<ul class="homemodel_thumbs">
<div style="text-align: right">
</div>
<?php
if(!empty($ratingArr)){
foreach($ratingArr as $ratings){
?>
<li><img src="<?php echo base_url();?>images/gallery/large/<?php echo $ratings['gallery_image'];?>" alt="<?php echo $ratings['gallery_image'];?>" class="center_image"/>
<p> </p>
<?php
if(!empty($_SESSION['rate_msg'])){
echo $_SESSION['rate_msg'];
//session_unset($_SESSION['rate_msg']);
}
?>
<form name="rating_form" action="" method="post">
<input type="hidden" name="g_id" value="<?php echo $ratings['gallery_id'];?>"/>
<input type="hidden" name="g_image" value="<?php echo $ratings['gallery_image'];?>"/>
<div style="text-align: center">
<input type="radio" name="rating" value="Hot" onclick="document.rating_form.submit();">Hot</input>
<input type="radio" name="rating" value="Not" onclick="document.rating_form.submit();">Not</input>
</div>
</form>
</li>
<?php
}
}
?>
</ul>
this problem is solved. of the two session message for the one i used php session while for the another one i used code igniter session. sorry if i haven't mentioned i am using ci. anyways thanks everyone for the help :)
You're unsetting your rating message after you display it:
session_unset($_SESSION['rate_msg']);
This means it's not available after you've posted back the form unless you re-populate it again.
Remove this and i suspect it'll work.
You have an excess ?> :
<?php
if(!empty($_SESSION['error_msg'])){?>
<div style="text-align: center"><?php echo $_SESSION['error_msg'];?></div>
<?
session_unset($_SESSION['error_msg']);
}
if(!empty($_SESSION['rate_msg']))
{
echo $_SESSION['rate_msg'];
session_unset($_SESSION['rate_msg']);
}
?>
You don't open php tag for last statement, (or unnesesery close it) it's treated as html
<?php
if(!empty($_SESSION['error_msg'])){?>
<div style="text-align: center"><?php echo $_SESSION['error_msg'];?></div>
<?php
session_unset($_SESSION['error_msg']);
}
?>
if(!empty($_SESSION['rate_msg'])){
echo $_SESSION['rate_msg'];
session_unset($_SESSION['rate_msg']);
}
?>
EDIT
<?php
// < HERE IS PHP >
if(!empty($_SESSION['error_msg'])){?>
<div style="text-align: center"><?php echo $_SESSION['error_msg'];?></div>
<!-- HERE IS HTML -->
<?
// < HERE IS PHP >
session_unset($_SESSION['error_msg']);
}
?> <!-- CLOSED PHP - NOW IT'S HTML - YOU SHOULD REMOVE IT -->
<!-- THIS IS NOT EXECUTED - BECAUSE IT'S HTML NOW -->
if(!empty($_SESSION['rate_msg'])){
echo $_SESSION['rate_msg'];
session_unset($_SESSION['rate_msg']);
}
?> <!-- THIS IS NOT PHP TAG BECASUE THERE IS NOT OPEN TAG -->
<form name="rating_form" action="" method="post">
<input type="hidden" name="g_id" value="<?php echo $ratings['gallery_id'];?>"/>
<input type="hidden" name="g_image" value="<?php echo $ratings['gallery_image'];?>"/>
<div style="text-align: center">
<input type="radio" name="rating" value="Hot" onclick="document.rating_form.submit();">Hot</input>
<input type="radio" name="rating" value="Not" onclick="document.rating_form.submit();">Not</input>
</div>
</form>

how to extract checkbox information and store it in database with codeigniter

I have this code in the php file. it lists all the interests as checkboxes and allows to input a text field "other". The user should select several of these interests and save. Now, when the user clicks on the submit button it should take it to the controller and controller should extract them and store it in the database. I have one file thats coded to do that, but its no good and too confusing.
Here is the form in the normal php file
<form method="post" action="<?php echo site_url("userProfile/update_bio");?>" name="editForm" id="edit-form">
<div> <!-- description start -->
<div> <p <p class="special-p">Name:</p> <hr> </div>
<p class="used-p"> <input type="text" name="name" value="<?php echo $this->dx_auth->get_username(); ?>"></textarea> </p> <!-- should be real name -->
</div> <!-- description end -->
<div> <!-- description start -->
<div> <p <p class="special-p">Description:</p> <hr> </div>
<p class="used-p"> <textarea name="description"></textarea> </p>
</div> <!-- description end -->
<div> <!-- interests start -->
<div> <p class="special-p">Interests:</p> <hr class="special-hr2"> </div>
<p class="used-p">I am interested in:</p>
<ul>
<?php
foreach ($allInterests->result() as $row){
echo '<li><input type="checkbox" name="checks1[]" value="'.$row->id.'"/> '.$row->name.'</li>';
}
?>
<li><input type="checkbox" name="checks1[]" value="other"/> Other: <input type="text" name="otherText"/></li>
</ul>
</div> <!-- interests start -->
<div>
<input id="editbutton" type="submit" value="Save" name="editBioButton" class="small green button"/>
</div>
</form>
The controller function is empty. The problem is I don't know how will it receive the checkboxes.
Thanx in advance
foreach($this->input->post(checks1) as $check)
{
echo $check;
}
But I believe that if the checkbox isn't checked, it won't appear in the $_POST array. To combat this, give each checkbox a specific index:
<?php
$count=0;
foreach ($allInterests->result() as $row){
echo '<li><input type="checkbox"
name="checks1[' . $count . ']" value="'.$row->id.'"/> '.$row->name.'</li>';
$count++;
}
may do what you require. Your controller would be:
foreach($this->input->post(checks1) as $key => $value)
{
echo $key . ' - ' . $value;
}

Categories