add recaptcha just doesn't work - recaptcha

i would like to add a recaptcha to my web form and have been following the instructions on the web but i just can't get the image to display.
i followed these steps:
- downloaded and unzipped the recaptcha folder
- uploaded recaptchalib onto my root folder (server side)
- made an account on recaptcha site
- copied the public and private key to paste into my php code
- i pasted the php code into my html code like this:
<form method="post" name="contact_form" action="contactengine.php">
<table>
<tr>
<td>
<label for="Name">Name </label>
</td>
<td>
<input id="Name" name="Name" type="text" maxlength="300" value=""/ >
</td>
</tr>
<tr>
<td>
<label for="Email">Email </label>
</td>
<td>
<input id="Email" name="Email" type="text" maxlength="300" value=""/ >
</td>
</tr>
<td class="buttons">
<input type="hidden" name="form_id" value="" />
<?php
require_once('recaptchalib.php'); // reCAPTCHA Library
$pubkey = "public-key-here"; // Public API Key
echo recaptcha_get_html($pubkey); // Display reCAPTCHA
?>
<input type="submit" name="submit" value="Submit" class="submit-button" />
</td>
</tr>
</table>
</form>
this should at least display the recaptcha image, but i just cannot get it to display.
i tried making an index.php and pasting my in there, but that doesn't even display a thing.
It should be so simple and yet i must be missing something. It's driving me crazy.
Help will be much appreciated, thanks
B

Are you getting any PHP errors in the log? Check to see if you are able to open a socket. The reCaptcha library must be able to do a fetch server side.
If you can't then enable sockets by adding "allow_url_fopen=On" to your php.ini config file.

Related

Codeigniter How to populate mult icheckbox from database

<tr>
<td>Role1</td><td>
<div class="Oinput" id="Ocheckbox">
<span class="rcs_input_label"></span>
<input type="checkbox" name="roles_method_id[]" value="1" /><span class="Olabel"></span>
</div>
</td>
</tr>
<tr>
<td>Role2</td><td>
<div class="Oinput" id="Ocheckbox">
<span class="rcs_input_label"></span>
<input type="checkbox" name="roles_method_id[]" value="2" <?php echo set_checkbox('roles_method_id', '2'); ?>
</div>
</td>
</tr>
How to get past saved check boxes with same name from database in codeigniter the data is saved but can't populate from database , if there is any way to get it from database using codeigniter or even using ajax to update

Alter multiple columns in the Database based on selected values- Hibernate

I am displaying the details of a particular table in my JSP page using a for-each loop in the following manner:
<c:forEach items="${List2}" var="alist">
<tr>
<td>
<input type="checkbox" name="check" value="${alist.check}">
</td>
<td>${alist.two}</td>
<td>${alist.three}</td>
<td>${alist.four}</td>
</tr>
</c:forEach>
<input type="radio" id="agree" value="Agree"/>Agree
<input type="radio" id="disagree" value="Disagree"/> Disagree
<input type="submit" value="Submit"/>
Now, there is no column named "check" in my DB. It is a transient field in my POJO. I do have a Agree/Disagree column in my DB. I want to check particular rows, click "Agree" or "Disagree" and on clicking Submit, the Agree/Disagree column for those records should be updated respectively. I'm using Spring MVC with Hibernate. Please tell me if any more info is required from my side.
You can do this with simple jQuery, Set class(say .chkbox here) to all checkboxes. Whenever any change event happened say,
if checked, the value of checkbox added to JS array.
If unchecked, the value will be removed from JS array.
$(document).ready(function() {
var selectedArray = [];
$('.chkbox').change(function() {
if($(this).is(":checked")) {
selectedArray.push($(this).val());
} else {
selectedArray.pop($(this).val());
}
//alert(selectedArray);
$("#textbox1").val(selectedArray);
});
});
Finally I used textbox to hold all the selected checkboxes value. You can make it into a hidden give a name attribute.
<input type="checkbox" class="chkbox" value="101"> This is 101<br />
<input type="checkbox" class="chkbox" value="102"> This is 102<br />
<input type="checkbox" class="chkbox" value="103"> This is 103<br />
<input type="checkbox" class="chkbox" value="110"> This is 110<br />
<input type="checkbox" class="chkbox" value="111"> This is 111<br />
<input type="checkbox" class="chkbox" value="112"> This is 112
<br />
<input type="hidden" id="textbox1" name="selectedArray" />
Sent it to a controller and split the values by comma (,).
Update :
In your code, you can update like this.
<c:forEach items="${List2}" var="alist">
<tr>
<td>
<input type="checkbox" class="chkbox" name="check" value="${alist.check}">
</td>
<td>${alist.two}</td>
<td>${alist.three}</td>
<td>${alist.four}</td>
</tr>
<input type="hidden" id="textbox1" name="selectedArray" />
</c:forEach>
That's all about required.
See the JS Demo how it works. Hope this helps.

Bootstrap Radio buttons not working properly in firefox

I have recently started using bootstrap to create a front end to a website. I was using chrome to develop it originally. I recently started testing on firefox and I ran into a problem. I have a few radio buttons on the front page. When I click on the one I want it looks as if it is only selecting the first one and not the one I am clicking on. If I click quickly a few times it makes the selection properly. Any ideas why this is happening? The code is here :
<form action="redirector.php" action="get">
<fieldset>
<table border="1">
<tr>
<td valign="top"><b>Please select a genome:</b><br>
<label class="radio">
<input type="radio" name ="genome" value="Acral2">Acremonium Alcalophilum<br><input type="radio" name ="genome" value="Aspni3">Aspergillus niger<br><input type="radio" name ="genome" value="Glotr1_1">Gloeophyllum trabeum<br><input type="radio" name ="genome" value="Phchr1">Phanerochaete chrysosporium<br><input type="radio" name ="genome" value="PleosPC15_2">Pleurotus ostreatus<br><input type="radio" name ="genome" value="Spoth2">Sporotrichum Thermophile<br><input type="radio" name ="genome" value="Thite2">Thielavia terrestris<br> </label>
</td>
<td valign="top">
<b>View proteins with JGI annotation of type:</b><br>
<label class="radio">
<input type="radio" name ="jgiAnnotation" value=sigPInformationView>SignalP Information<br>
<input type="radio" name ="jgiAnnotation" value=ecInformationView>EC and Pathway Information<br>
<input type="radio" name ="jgiAnnotation" value=domainInformationView>Domain Information<br>
<input type="radio" name ="jgiAnnotation" value=goInformationView>Go Information<br>
</label>
<button type="submit" class="btn">Submit</button>
</fieldset>
</form>
</td>
<td valign="top">
<form action="annotationInfoView.php" action="get">
<fieldset>
<b>View single protein:</b><br>
Enter our ID number:<input type="text" name ="ourId"><br>
(i.e. jgi_Spoth2_2293939)<br>
<button type="submit" class="btn">Submit</button>
</fieldset>
</form>
</td>
</tr>
</table>
http://jsfiddle.net/CTF2s/
The problem is you have multiple radio buttons inside of a single label.
If I click quickly a few times it makes the selection properly.
This is probably because you're clicking directly on the radio button and not the text next to the radio button. This is how all browsers will behave, including Chrome.
Check out the "Checkboxes and radios" section of Twitter Bootstrap's "Forms" documentation for a working example.

how to get xpath preceding-sibling working for this table

I have a table where I need to find if the checkbox corresponding to a cell is checked or not, see for example, I need to find out if the checkbox id=830 which is a sibling of DeviceHelp is checked or not.
Similarly for element Contact, I will have to check whether checkbox id="72" is checked / unchecked
And I can only rely on the text elements (contact, DeviceHelp, etc) to get the checkboxes state and not the checkbox ids which could change.
<tr class="row active" style="display: table-row;">
<td>
<input id="72" class="rowcheck" type="checkbox" value="true" name="ModesForUi[0].Allow" categoryid="58" disabled="">
<input type="hidden" value="false" name="ModesForUi[0].Allow">
</td>
<td> Administration - Read </td>
<td>
Contact
<input id="ModesForUi_0__ResourceID" type="hidden" value="72" name="ModesForUi[0].ResourceID">
<input id="ModesForUi_0__ModeID" type="hidden" value="12185" name="ModesForUi[0].ModeID">
</td>
<td> Controls access to Search Contacts link and to view contact details page. Navigate to Menu\Advanced\More </td>
</tr>
<tr class="row active" style="display: table-row;">
<td>
<input id="830" class="rowcheck" type="checkbox" value="true" name="ModesForUi[1].Allow" categoryid="58" disabled="">
<input type="hidden" value="false" name="ModesForUi[1].Allow">
</td>
<td> Administration - Read </td>
<td>
DeviceHelp
<input id="ModesForUi_1__ResourceID" type="hidden" value="830" name="ModesForUi[1].ResourceID">
<input id="ModesForUi_1__ModeID" type="hidden" value="12186" name="ModesForUi[1].ModeID">
</td>
<td> Controls access to Help icon displayed next to logout icon and next to the menu. </td>
</tr>
Have tried the following, but I am not getting the checkbox value
"ancestor::td[1]/input[1]/preceding-sibling::td[normalize-space(text())='DeviceHelp']")
And
//tr[position()>1]/td[normalize-space(text())='DeviceHelp*']/parent::td/preceding-sibling::td/input#value
Please xpath experts could you shine some light on what is wrong with the paths above and how to get to the checkbox ?
Thanks!
I think I know what you're trying to get here...
Try this for Device Help:
/root/tr/td[normalize-space(text())='DeviceHelp']/../td[1]/input[1]/#value
And this for Contact:
/root/tr/td[normalize-space(text())='Contact']/../td[1]/input[1]/#value
"root" is just whatever node you're starting from, I added that to test locally, as the XML snippet isn't complete.
EDIT
Try this:
//tr/td[normalize-space(text())='DeviceHelp']/../td[1]/input[1]/#value
//tr/td[normalize-space(text())='Contact']/../td[1]/input[1]/#value

Grails - Select box tied to object ID and remote field

Run into a bit of an odd problem that is increasingly frustrating
Scenario: I have a list of domain objects, each has a g:select attached to it that is rendered by a remote field.
How do I tie the status variable OR the personInstance ID to the selection box, so that when I use the renderField, I update testDiv_(number)
View:
<g:each in="${listOfPeople}" status="i" var="personInstance">
<td>
Text: <g:remoteField action="getResults" controller="person" id="" update="testDiv_${personInstance.id}" paramName="search" name="getResults" value="" />
<g:each in ="${personInstance?.choices}" var="choice" status="x">
<li>${choice}</li>
</g:each>
</td>
<td>
<g:render template="renderThisTemplate"></g:render>
</td>
</g:each>
Template:
<div id="testDiv_${personInstance.id}" class="testDiv_${personInstance.id}">
<g:select id="aChoice" name="aChoice.id" from="${allChoices}" optionKey="id" value="" />
<g:actionSubmit action="addChoice" value="Add"/>
</div>
Edit
I know that the remote call (ajax) is passing the update for testDiv_(number). The problem is with the template ID and assigning that value to the template div.
Just incase anyone needs this answer in the future. Apparently you cannot reference the instance variable (personInstance) in the g:each from the template.
So I replaced the g:render with its code and it worked:
<g:each in="${listOfPeople}" status="i" var="personInstance">
<td>
Text: <g:remoteField action="getResults" controller="person" id="" update="testDiv_${personInstance.id}" paramName="search" name="getResults" value="" />
<g:each in ="${personInstance?.choices}" var="choice" status="x">
<li>${choice}</li>
</g:each>
</td>
<td>
<div id="testDiv_${personInstance.id}" class="testDiv_${personInstance.id}">
<g:select id="aChoice" name="aChoice.id" from="${allChoices}" optionKey="id" value="" />
<g:actionSubmit action="addChoice" value="Add"/>
</div>
</td>
</g:each>

Resources