Form 2 Address<

liunx

Guest
Hi,

Is there anyway you could have an input box which the user enters, say, "XYZ" and is taken to exampledomain.com/XYZ ?

Thanks,
Glenseeing as I'm just learning, I could be wrong, but couldn't you, take the data from the form and set it equal to a variable, ie $variable ...then set up a java redirect, except when you're doing the url for the redirect, do it like: echo ('a href=http://www.htmlforums.com/archive/index.php/"http://www.exampledomain.com/"$variable');


I'm not exactly sure on that, or how to do the redirect code, but it's an idea...perhaps someone else will pop in with a more concrete answer :)<?php
if (isset($_POST['name']))
{
header('Location: <!-- m --><a class="postlink" href="http://mydomain.com/'.$_POST">http://mydomain.com/'.$_POST</a><!-- m -->['name']);
exit();
}
?>
<html>
<body>
<form method="post">
<input type="text" name="name">
<input type="submit">
</form>
</body>
</html>Hi,

Thanks for the quick reply - it works like a charm!


Thanks!,
GlenOne more thing,

What code would I use to redirect to like an error page if certain illegal characters were entered? (e.g. !@#$ or if it was left blank)if the $_POST['name'] is empty it will go to the html page.

<?php
if (isset($_POST['name']) AND (preg_match('/[A-Za-z]$/i', $_POST['pass'])))
{
header('Location: <!-- m --><a class="postlink" href="http://mydomain.com/'.$_POST">http://mydomain.com/'.$_POST</a><!-- m -->['name']);
exit();
}
?>
<html>
<body>
<form method="post">
<input type="text" name="name">
<input type="submit">
</form>
</body>
</html><?php
if (isset($_POST['name'])) {
if (!empty($_POST['name']) AND preg_match('/[A-Za-z]$/i',$_POST['name'])) {
header('Location: <!-- m --><a class="postlink" href="http://mydomain.com/'.$_POST">http://mydomain.com/'.$_POST</a><!-- m -->['name']);
exit();
}
else {
$error=1;
}
}
?>
<html>
<body>
<form method="post">
<?php
if (isset($error)) {
echo '<b>Invalid Carater!</b><br>';
}
?>
<input type="text" name="name">
<input type="submit">
</form>
</body>
</html>isn't that redundant?

if it isset then it won't be empty, right?i didn't think about it,
but your right!
 
Back
Top