Self search within files to open (hyperlink)
Hello. Let me try to explain this, and maybe somebody might help me accomplish this. I work at a design/engineering firm, and with have our own server, etc. We have all of our shop drawings in one directory: http://engineering/prints/ (Intranet)
Whereas, if we need a drawing a real example would be: http://engineering/prints/a200027.pdf
The question.. Is there a index.htm (php), etc that I can use where the the web page prompts the user: What drawing would you like? [text box]. Where the user would input a drawing number. When the user hits a 'Go' button, it would open that drawing (like a window opens from a hyperlink).
Like the above example: What drawing would you like.. and I would enter a200027 in the text box. Once I press enter or a go button, it would use the address http://engineering/prints/a200027.pdf to open a drawing?
Any help would be appreciated.. this is more for other departments who have no clue what an address is.
Thanks!
Greg K posted this at 20:53 — 12th July 2005.
He has: 2,145 posts
Joined: Nov 2003
Assuming you have PHP on your server, this is quite simple.
I didn't test this, just did it off the top of my head, give it a try:
<?
$errMessage = "";
if ($_POST['Sumit']!="")
{
// Form was submitted
// Check to make sure file exists. You will need
// to adjust the path to match your system
// Also may want to do some other validation
if (file_exists("/home/httpd/html/prints/{$_POST['fileNum']}.pdf"))
{
// Redirect them to the file
header("Location: http://engineering/prints/{$_POST['fileNum']}.pdf");
}
else
{
// Generate error message to display on form
$errMessage = "Drawing '{$_POST['fileNum']}' was not found.";
}
}
?>
<html>
<head>
<title>XYX Company | Choose Drawing</title>
</head>
<body>
<h3>XYZ Company</h3>
<form name="prints" method="POST" action="<?= $_SERVER['PHP_SELF'] ?>">
<? if ($errMessage!="") print "<p>Error: $errMessage</p>\n"; ?>
<p>Please enter the print you would like:
<input name="fileNum" type="text" size="20">
<input name="submit" type="submit" value="View Print">
</p>
</form>
</body>
</html>
-Greg
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.