My HTML has the following:
<input type="text" name="code" />
<input type="submit" value="Submit" />
What I want to do is redirect the user to page1.htmlwhen he / she enters, say, 12345and redirect him / her to page2.htmlwhen he / she enters 56789. How can I do this with PHP? I also use JavaScript.
Let me rephrase that (just in case). I want to write 12345in the input field and after clicking the button Submitredirect to page1.html. The same principle for 56789and page2.html.
I found this old jQuery code and modified it a bit. I would be glad to hear your suggestions on polishing and achieving what I want.
$('input').keyup(function () {
var val = $(this).val();
var newVal = val.split('1234').join('HELLO');
if (newVal !== val) {
window.open("http://localhost:8000/page1.html");
}
});
Also, is this correct (for PHP)? (not tried yet)
if ($_POST['code'] == '1234'){
header("Location: redirect_to_me.php");
}
, , .
.