Go to a page via PHP

Wow im sorry guys. Maybe I should get some sleep :lol:

Actually, I tried the code and again no matter what I do, it (the browser) goes to phpInputParser.php uri/url/file-location and doesn’t execute the code in phpInputParser.php if the input was not ‘intro’ or ‘introduction’ nor does it go to introduction.html if the input is.

To simply the code, I deleted all the syntax in phpInputParser.php (I have a back up), and just had it echo the $intro variable, but the issue i mentioned above still occurs :frowning:

Here is the code in search.php:


<!Doctype HTML>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>go to page on type in input</title>
    </head>
    <body>
        <form action="phpInputParser.php" method="post" name="frmsearch">
            <input type="text" name="search" autocomplete="off" value="" />
            <input type="submit" name="btnsubmit" value="Submit" />
        </form>
    </body>
</html>

and here is the code in phpInputParser.php:


<?php
if( isset($_POST['btnsearch']) ){
    $intro = trim($_POST['search']);
    // check if they typed introduction or intro then redirect them to introduction.html page.
    if( $intro === 'introduction' || $intro === 'intro' ){
        header("Location: introduction.html");
        exit();
    }
    else{
        // write the code in here that you wanted to do in phpInputParser.php file.
        echo $intro;
    }
}
?>

Am I doing something stupid or wrong or is there a problem with the code?

Regards,
Team 1504

Do nothing, just change the name of the submit button:
<input type=“submit” name=“btnsubmit” value=“Submit” />
To
<input type=“submit” name=“btnsearch” value=“Submit” />

And check what you see…!

It works! :weee: :slight_smile: Thank you all very much! Now that just the echo works, I will develop and put the code that is phpInputParser.php in the else condition— hopefully that will go well.

I apologise for the stupid mistakes that I made by not reading carefully and thank you for your help, all of you, very much!

Regards,
Team 1504