Jump to content

Compare javascript variable to PHP variable? Not working.


brady123

Recommended Posts

This is both javascript and PHP, so I'll try here.

 

I'm trying to validate a form using a generated key but I can't get the form to validate. I'm even looking in the source code of the generated page, taking the key that is generated, but the form is still not validated. If I substitute the PHP part for an arbitrary word the form will validate,  but it won't validate against the PHP variable.

 

Here is my code. Anyone know why this wouldn't work? Thanks for your help!

 

if (document.forms["frm"]["captcha"].value != "<?php echo $_SESSION['key']; ?>") {
	document.getElementById('response').innerHTML = "Text did not match image.";
	frm.captcha.focus()
	return false;
}

If the benefit is great enough, the hacker behind the bot script will enter the regular expression necessary to scrape that value out of the page so that the bot script can automatically submit to your site.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.