Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    IF Statement for Submit Button

    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.

    Code:
    <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

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    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
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Yeah, so thats why I wanted to switch that javascript to PHP. PHP is server side coding right?

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Quote Originally Posted by puraw View Post
    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.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •