Results 1 to 4 of 4

Thread: Code Redirector

  1. #1
    Join Date
    May 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb Code Redirector

    Hiya,

    Im looking for something that is an input box where you put in a code and it redirects you to a site:

    e.g.

    If I enter 666666 it will redirect you to adress.com/666666

    and if I enter 777777 it will redirect to address.com/777777

    But if i enter an unknown code it says Incorrect Passcode.

    Thanks in advance.

    James

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 517 Times in 503 Posts
    Blog Entries
    5

    Default

    Your question is unclear.
    Please provide more information, and be as specific as possible.
    • What do you want to accomplish?
    • What have you already tried?
    • What problems did you encounter?

    Also, please be sure that you have included all relevant code and/or a link to the page in question.
    I assume is this for a webpage?
    what programming language are you using?
    how are you entering the "code" (via a form)?
    do you want to redirect to local pages, or to other websites?

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    There's a Javascript 'password' script here on DD that does all of that. The only thing it doesn't do is tell you if the password is wrong (it'll just send you to a non-existent page).
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Mar 2011
    Location
    N 11░ 19' 0.0012 E 142░ 15' 0
    Posts
    1,521
    Thanks
    41
    Thanked 89 Times in 88 Posts
    Blog Entries
    3

    Default

    Here's a quick example of how it could be done (if I undersand your question correctly)

    Javascript (Not Secure)
    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <script type="text/javascript">
    var acceptedPass=new Array(); // THESE ARE THE LIST OF ACCEPTED PASS CODES
    acceptedPass[0]="666666";
    acceptedPass[1]="777777";
    
    // DON'T EDIT AFTER HERE
    function checkPass() {
    	var i = 0;
    	var check = 0;
    	var passInput = document.getElementById('pass');
    	var AL = acceptedPass.length;
    	for (i=0;i<AL;i++) {
    		if(acceptedPass[i] == passInput.value) {
    			check = 1;
    		}
    	}
    	if(check == 1) {
    		window.location = passInput.value;
    	} else {
    		alert("Wrong Passcode");
    	}
    }
    </script>
    </head>
    <body>
    Password <input type="text" id="pass" /> <input type="button" value="Submit" onclick="checkPass()" />
    </body>
    </html>

    Php (Secure)

    Code:
    <?php
    if(isset($_POST['submit1'])) {
    	$acceptedPass[0]="666666"; // THESE ARE THE LIST OF ACCEPTED PASS CODES
    	$acceptedPass[1]="777777";
    
    	// DON'T EDIT AFTER HERE
    	$pass = mysql_real_escape_string($_POST['pass']);
    	$AL = count($acceptedPass);
    	$check = 0;
    	for ($counter = 0; $counter < $AL; $counter += 1) {
    		if($acceptedPass[$counter] == $pass) {
    			$check = 1;
    		}
    	}
    	if($check == 1) {
    		header('Location:' . $pass);
    	} else {
    		echo "Wrong Passcode";
    		echo '<input type="button" value="Back" onclick="history.back()">';
    	}
    } else {
    ?>
    <!DOCTYPE html>
    <html>
    <head>
    </head>
    <body>
    <form action="" method="post">
    Password <input type="text" name="pass" />  <input type="submit" name="submit1" value="Submit" />
    </form>
    </body>
    </html>
    <?php
    } 
    ?>
    If this wasn't what you wanted, please clarify what you meant (like traq said)

Bookmarks

Posting Permissions

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