View Full Version : Passing a URL through a form

04-19-2005, 03:46 PM
I would like to pass an URL through a form, I use the Post method and the other fields work but the URL does not. I know this does has something to do with how the // and the : are encoded but how can I repair that without doing a whole bunch of work?

The big picture of what I am trying to do is have an adminstration interface to a site where I can post an url into a mysql database and use it in the future with a out.php type script.


04-19-2005, 04:01 PM
How is the url field coming out the other end after the form is posted? It should come out just as it's been entered in I think.

04-19-2005, 04:09 PM
well, when I was using GET I was getting all sorts weired characters, using POST i cannot see exactly what the characters are. The URL does not go into my database but the name of the site does.

With GET it looked like http://www.x.com/a.php?name=car&URL=%%32cars/32com
Note: Those are not the real characters but that is sorta of what it looked like.

04-20-2005, 12:19 PM
not sure i understand 100% without seeing it... i'm assuming you have something like this:

<form action="<?=$PHP_SELF;?>" method="POST">
<input type="text" name="url" size="30">
<input type="submit" name="submit" value="Submit">

the http shouldn't be a problem, but i'd recommend doing one of two things:
before adding the url to your database add this line:
<?$url = str_replace('http://', '', $url);?>

the other thing you can do is change this line: <input type="text" name="url" size="30">
to: http://<input type="text" name="url" size="30">
so that the user knows not to type http:// when entering the url

like i said i'm not entirely sure i understand the question, but hopefully this will help...

04-20-2005, 12:35 PM
yes, that does help. Thank you. I figured it out.