Jump to content

Please help...Need a simple code, but I don't know how to do it.


amandas

Recommended Posts

Hi guys. I don't really know PHP all that well, but I have been trying all night to do the following: A user submits their URL to form and the form then redirects the user to a new url with the submitted URL.

 

Example: User enters www.mydomain.com and then submits the form. The person is then redirected to www.mydomain.com/folder.

 

Any ideas on how to do this?

 

I have tried several things, but no luck.

 

My most recent attempt was:

 

if ( $submitme == 1 ) {
$link = "http://www." .$url ."/folder";  <--- I am pretty sure that is wrong
header('location:'. $link);
exit;
} 

 

Please don't laugh. :(

 

Thanks for looking.

-Amanda

Hard-coding "/folder" will only work if you know all your users' domains have a folder with that name.

 

eg http://www.google.com/folder will give a page not found error.

 

Also, register_globals is usually OFF by default so you have to get the $_GET or $_POST values from the form.

 

try

<?php
if (isset($_GET['submit'])) {
    if (!empty($_GET['url'])) {
        $link = 'http://www.' . $_GET['url'] . '/' . $_GET['folder'] ;
        header ('location:' . $link) ;
    }
}
?>
<form>
URL http://www.<input type='text' name='url' size='40'> / <input type='text' name='folder' size='20'><br>
<input type='submit' name='submit' value='Submit'>
</form>   

Thanks! I'll give it a try and let you know how it works. All of my clients have a folder on their account of the same name, but I want them to access it from my website since most of them forget all of the features they have. :)

 

Amanda

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.