...

View Full Version : IF Statement for Submit Button



puraw
12-10-2010, 03:33 PM
OK I have very limited knowledge of PHP. I am trying to have a if statement for a submit button. So if the textbox says the correct promo code, then the user can submit and get to the page, if not it will print a small text error. I have it in javascript, but it is very unsecure, so I need to switch it to PHP.

Here is my Javascript code if that helps.



<input type="text" id ="txtBox" />
<input type="button" name="btnButton" value="Submit" onclick="checkValue()" />

<script type="text/JavaScript">
function checkValue() {
var secretcode = document.getElementById("txtBox").value;
if (secretcode == "1234"){
window.location.href = 'secret.html';
}
}
</script>


I don't expect anyone to write me the code, if they do that's great. But can anyone point me in the right direction of where to start?

Thanks

abduraooft
12-10-2010, 03:44 PM
So if the textbox says the correct promo code, then the user can submit and get to the page, if not it will print a small text error. It's not worth to check such things from the client side, since users can easily view the source of the page and get the value from there. You'd need to use a serverside code to do this

puraw
12-10-2010, 03:48 PM
Yeah, so thats why I wanted to switch that javascript to PHP. PHP is server side coding right?

abduraooft
12-10-2010, 04:23 PM
Yeah, so thats why I wanted to switch that javascript to PHP. PHP is server side coding right? Yes. You may use a form to submit the data to a serverside page.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum