I want help from you this is the question If you type "freewebspace" in a search box and click on a button The browser should display the "freewebspace.html" within the same directory
This will do what you want: <?php if (isset($_POST["submit"])) { if ($_POST["filename"] == "") { echo "Please enter a file name"; } else { header('Location:' . $_POST["filename"] . ".html"); } } else { echo "<form action=\"". $_SERVER['PHP_SELF'] ."\" method=\"post\" enctype=\"multipart/form-data\"> <input name=\"filename\" type=\"text\" /> <input name=\"submit\" type=\"submit\" /> </form>"; } ?> Code (markup): Let me know if you have any problems.
Thank you I will try out it Excellent ! I will contact you for some surprise gift to you If you have a website PM me I will add your site as a Featured links in my directory
No problem Website address PM'ed. P.S Oh by the way I added a little extra to the code above. Not sure if you got it or not, so amend the file to the above code
I don't know if this is a problem, but since POST is provided by the user, would you benefit from a tiny bit of moderation on your post vars? I cant think of anyway to exploit that code currently but you are including with no moderation at all. if the user used a ' or " or . it may break the script, not sure. Hope it all works out for ya.
Luke is right ; header('Location:' . $_POST["filename"] . ".html"); should be header('Location:' . stripslashes(trim($_POST["filename"] )) . ".html");
sorry for bumping this If the file suppose does not exist I want to go to it the main page what should i do?
<?php if (isset($_POST["submit"])) { if ($_POST["filename"] == "") { echo "Please enter a file name"; } elseif(!file_exists(stripslashes(trim($_POST['filename'] )). ".html")) { header("location: mainpage.php"); exit; } else { header('Location:' . stripslashes(trim($_POST["filename"] )) . ".html"); exit; } } else { echo "<form action=\"". $_SERVER['PHP_SELF'] ."\" method=\"post\" enctype=\"multipart/form-data\"> <input name=\"filename\" type=\"text\" /> <input name=\"submit\" type=\"submit\" /> </form>"; } ?> PHP: