Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
How do, simply, build a URL link that requires a portion of it to contain input from the user. For example (with spaces removed obviously)
http // mailservername. <<mailfilename>> .blahblah
The URL will always be the same except <<mailfilename>> will change and be input by the viewer of the page. Is this an easy thing to do?
Thanks

(I'm going to show this in PHP)
Ok im understanding it as the user inputs a filename and the page either outputs the text of the link or goes directly to that link.
INPUT PAGE (only partial code and just the HTML)
<form method="post" action="url_script.php">
<input type="text" name="url" size="20" />
<input type="submit" value="Submit" />
</form>SCRIPT 1 (Redirect)
<?php
$url = $_POST['url'];
header("Location: http://mailservername" . $url . "blahblah");
?>SCRIPT 2 (Output/Print)
<?php
$url = $_POST['url'];
echo 'Link';
?>That what your looking for? Don't forget to add some security to these scripts, such as filtering the input etc...
Developers have a sense of humour, it's just commented out.

Sorry forgot to add that if spaces are used in the input, you should use a function to remove spaces from the input. This function should do the job nicely. Good luck.
function remove_spaces($text)
{
$text_len = strlen($text);
$fixed_text = "";
for($i=0;$i<$text_len;$i++)
{
if(substr($text,$i,1) != " ")
{
$fixed_text = $fixed_text . substr($text,$i,1);
}
}
return $fixed_text;
}
return $fixed_text;
}
?>Developers have a sense of humour, it's just commented out.

I really should plan a post before I dig into it. If you need to replace the spaces with %20 then here is a function to do that also.
function replace_spaces($text)
{
$text_len = strlen($text);
$fixed_text = "";
for($i=0;$i<$text_len;$i++)
{
if(substr($text,$i,1) == " ")
{
$fixed_text = $fixed_text . "%20";
}
else
{
$fixed_text = $fixed_text . substr($text,$i,1);
}
}
return $fixed_text;
}Developers have a sense of humour, it's just commented out.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |