Link to home
Start Free TrialLog in
Avatar of Amanda Watson
Amanda WatsonFlag for Australia

asked on

How can I add my captcha code to this php page?

Hi there,
I have a php page and I would like to add a standard captcha code in it.

The captcha code is here:

<td colspan="8"><img alt="CAPTCHA Image" src="/securimage/securimage_show.php" id="captcha" />Enter the code here <input type="text" maxlength="6" size="10" name="captcha_code" /><a onclick="document.getElementById('captcha').src = '/securimage/securimage_show.php?' + Math.random(); return false" href="#"><br />
                Reload Image</a></td>

I have used it successfully in other pages here
http://www.campsaustraliawide.com/index.php?page=17

The php page I want to add it to is here:
http://www.campsaustraliawide.com/affiliate.php

the php code of the page is attached.

So my question is, I have tried adding the above code with the php page but I get an error so I would like to know how i can add it in?
Avatar of UltraFlux
UltraFlux
Flag of Canada image

I'm not entirely sure of your requirements but I have repeatedly used

ReCaptcha
http://recaptcha.net/

Easy to use and easy to install. Saves a lot of messing around.
Avatar of Kalpan
Would you please let me know the error while you adding the captch script to your registration page

Please make sure things that path for the securimage/securimage_show.php should be correct

thanks

kalpan
Avatar of Amanda Watson

ASKER

Yes in my root folder i have a folder called secureimage and within that secureimage_show.php is within.

The php I have is in the root...so perhaps I need to remove the "/"  so its:

src="securimage/securimage_show.php"

instead of

src="/securimage/securimage_show.php"

Will that matter though?

The page that successfully uses it uses the same folder so it should be ok.

The error message is simply that I have a parsing error on the line that I insert the code i have mentioned.?

This is the error when you go to my test
http://www.campsaustraliawide.com/affiliate_test.php

Parse error: syntax error, unexpected T_LNUMBER, expecting ',' or ';' in /home/9-web/97/19/campsaustraliawide.com/public/www/affiliate_test.php on line 224

and line 224 is where i added

<td colspan="8"><img alt="CAPTCHA Image" src="/securimage/securimage_show.php" id="captcha" />Enter the code here <input type="text" maxlength="6" size="10" name="captcha_code" /><a onclick="document.getElementById('captcha').src = '/securimage/securimage_show.php?' + Math.random(); return false" href="#"><br />
                Reload Image</a></td>


so I am obviously doing something wrong.


Hello, are you able to help?
Hey there. I'm an expert from the PHP area. That Parse error you got looks like it could be a simple fix, but we need to see lines 200 - 225 from the original source code for affiliate_test.php - can you post that here?
Hi, Snowball.  Here is my captcha example.  There are three parts.  The top is the script you put into your current working directory.  The middle is the HTML you add to your form.  The bottom is the check you add to your script.  You can pretty it up if you want, but this gives you all the moving parts.

HTH, ~Ray
<?php // CAPTCHA_NUMBER.PHP GENERATES A PICTURE OF A NUMBER
 $data = base64_decode($_GET['dt']);
 $im   = imagecreate(46,13);
 $bg   = imagecolorallocate($im, 255,255,255);
 $gray = imagecolorallocate($im, 188,188,188);
 $text = imagecolorallocate($im, 178,34,34);  // firebrick
 imagestring($im,5,4,0,$data,$text);
 imageline($im,4,12,38,0,$gray);
 imagepng($im);
 imagedestroy($im);
?>






<html> <!-- GOES IN THE FORM SCRIPT -->
Type <img style="display:inline;" src=captcha_number.php?dt=<?php $x = mt_rand(1000,10000); echo base64_encode($x);?> />
here: <input type=hidden name='_newMd5' value="<?=md5($x)?>" /> &nbsp;
<input name="_newCode" type="text" maxlength="64" size="6" autocomplete="off" />







<?php // GOES IN THE ACTION SCRIPT
$newCode = $_POST["_newCode"];
$newMd5  = $_POST["_newMd5"];
$newCode = md5($newCode);
if ($newCode != $newMd5)
{
	die('Security code number did not match');
}

Open in new window

Thanks Ray,
I want to use the captcha code that I already have working on other pages.

This is the code attached...you can see where I have added in the other code.

As I said I have used this successfully on other pages, but its not working on this page.

affiliate-test.txt
This is the code of it working here:
http://www.campsaustraliawide.com/index.php?page=17

So I was trying to mimick it in affiliates.php with my affiliates_test.php page

What am I doing wrong?>

<h1>Camp Sites Feedback</h1>
<p>If you know of any campsites that you feel should be included or amended in our book, please let us know by completing the form below.</p>
<form action="http://www.campsaustraliawide.com/sendresults_cs.php" method="post" target="_blank" name="FeedbackForm">
    <input type="hidden" name="recipient" value="info@campsaustraliawide.com" />
    <table width="100%" cellspacing="3" cellpadding="4" border="0" id="Table2">
        <tbody>
            <tr>
                <td height="13" colspan="8"><!--
Start of Cell (Cell36)
-->
                <p>What would you like to do?</p>
                </td>
            </tr>
            <tr>
                <td colspan="8"><!--
Start of Cell (Cell95)
-->
                <p>Download a feedback form (pdf format) <a target="_blank" href="http://campsaustraliawide.com/Feedback_form_1.pdf">Form 1</a> (includes abbreviations), <a target="_blank" href="http://campsaustraliawide.com/Feedback_form_2.pdf">Form 2</a></p>
                </td>
            </tr>
            <tr>
                <td width="35%" height="13"><input type="checkbox" id="FormsCheckbox1" name="Add site" value="add site" /> Add a camp site</td>
                <td colspan="3"><input type="checkbox" id="FormsCheckbox2" name="Amend site" value="amend site" /> Amend a camp site</td>
                <td width="30%" colspan="3"><input type="checkbox" id="FormsCheckbox3" name="Comment" value="comment" /> Comment</td>
            </tr>
            <tr>
                <td height="13" colspan="8"><!--
Start of Cell (Cell28)
-->
                <p>Please include as much information as possible, such as site name, location, <span style="background-color: rgb(255, 102, 0);">Important please include the&nbsp;GPS co-</span><span style="background-color: rgb(255, 102, 0);">ordinates</span>, etc</p>
                </td>
            </tr>
            <tr>
                <td height="72" class="linetop" colspan="8"><!--
Start of Cell (Cell4)
-->
                <p><i>Facilities and their abbreviations currently include: Toilets (T), Showers (S), Disabled Access (DA), Water (W), Shade (SH), Picnic Tables (P), Fireplace (F), Barbeque (BQ), Fees Applicable ($), Big Rigs (B), Power (E), Maximum Stay in hours (20), (24), (48), (72), Dump Point (D), Mobile Phone (MP), Public Phone (PP), Dry Weather Access only (DW), Vista (V), Site Close to Road (N), No Pets allowed (NP), Pets Allowed (PA) </i></p>
                </td>
            </tr>
            <tr>
                <td height="166" colspan="8"><!--
Start of Cell (Cell7)
-->Your information or comments: <!--
Start of Forms Multi-Line (FormsMultiLine3)
-->
                <table width="100%" cellspacing="0" cellpadding="0" border="0" nof="TE">
                    <tbody>
                        <tr>
                            <td align="left"><!--
Start of Forms Multi-Line (FormsMultiLine3)
--><textarea id="FormsMultiLine3" rows="10" cols="63" name="Info"></textarea></td>
                        </tr>
                    </tbody>
                </table>
                </td>
            </tr>
            <tr>
                <td colspan="8"><!--
Start of Cell (Cell44)
-->Name: <!--
Start of Forms Edit Field (FormsEditField11)
-->
                <table width="528" cellspacing="0" cellpadding="0" border="0" align="left" nof="TE">
                    <tbody>
                        <tr>
                            <td><!--
Start of Forms Edit Field (FormsEditField11)
--><input type="text" id="FormsEditField11" title="Your Google Toolbar can fill this in for you. Select AutoFill" style="background-color: rgb(255, 255, 160);" maxlength="50" size="66" name="Name" /></td>
                        </tr>
                    </tbody>
                </table>
                </td>
            </tr>
            <tr>
                <td colspan="8"><!--
Start of Cell (Cell10)
-->Email address:
                <table width="528" cellspacing="0" cellpadding="0" border="0" align="left" nof="TE">
                    <tbody>
                        <tr>
                            <td><input type="text" id="FormsEditField12" title="Your Google Toolbar can fill this in for you. Select AutoFill" style="background-color: rgb(255, 255, 160);" maxlength="50" size="66" name="Email address" /></td>
                        </tr>
                    </tbody>
                </table>
                </td>
            </tr>
            <tr>
                <td colspan="8"><img alt="CAPTCHA Image" src="/securimage/securimage_show.php" id="captcha" />Enter the code here <input type="text" maxlength="6" size="10" name="captcha_code" /><a onclick="document.getElementById('captcha').src = '/securimage/securimage_show.php?' + Math.random(); return false" href="#"><br />
                Reload Image</a></td>
            </tr>
            <tr>
                <td colspan="8"><input type="submit" id="FormsButton8" name="Submitbutton" value="Submit" /> <input type="reset" id="FormsButton9" name="Resetbutton" value="Reset" /></td>
            </tr>
        </tbody>
    </table>
</form>
<p>&nbsp;</p>
<input type="hidden" id="gwProxy"><!--Session data--></input><input type="hidden" id="jsProxy" onclick="jsCall();" />
<div id="refHTML">&nbsp;</div>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of gr8gonzo
gr8gonzo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Brilliant, thank you very much!