I have a proxy script and I want that the user inserts http:// before he surfs, but let's say he doesn't enter it I want it to be added, but if he doesn't I don't want to end up with http://http://www.website.com
So please can anyone help me? I have a text box in index.html to write the URL and then a php script to surf the website in a frame.
Can anyone help please?
Thanks.
Need help with proxy script please
Started by TcM, May 16 2007 04:37 AM
4 replies to this topic
#1
Posted 16 May 2007 - 04:37 AM
|
|
|
#2
Posted 16 May 2007 - 05:53 AM
What about putting "http://" as standard value in the inputbox? Then the user will probably right the URL after the "http://". It can easily be done by setting a value-attribute at the tag.
<input ... value="http://" />Then of course some users will probably remove the "http://", so you still have to find away of checking for "http://". For this you can use the PHP-function strpos. The function will return false if the string didn't got found, and else the position.
$input = $_GET["input_from_user"]; $haystack = strtolower($input); $needle = "http://"; $position = strpos($haystack, $needle); // Check if "http://" wasn't in the page if($position === false) $page = "http://" . $haystack; else $page = $haystack; // Continue with the job to be done
#3
Posted 16 May 2007 - 06:33 AM
I have already done the one with the value, now I will try the other bit of code..
Will let you know, I'm trying it.
*EDIT* Wow man, it works perfectly. if no URL is given it always displays that the URL is wrong, Thanks! I had to edit it a little bit, although I don't know any PHP, but I figured it out as I know some programming. Anyways thanks!!
Will let you know, I'm trying it.
*EDIT* Wow man, it works perfectly. if no URL is given it always displays that the URL is wrong, Thanks! I had to edit it a little bit, although I don't know any PHP, but I figured it out as I know some programming. Anyways thanks!!
#4
Posted 16 May 2007 - 06:45 AM
I'm glad, you could use it.
To make the validation for the input even more secure, try look into some Regular Expressions. It's a short, clean - but also a bit hard way to validate your input in only a line, or maybe a little more. There's tons of information about Regular Expressions "out there", and also for many different languages.
A good place to start, would be here:
Regular-Expressions.info - Regex Tutorial, Examples and Reference - Regexp Patterns
To make the validation for the input even more secure, try look into some Regular Expressions. It's a short, clean - but also a bit hard way to validate your input in only a line, or maybe a little more. There's tons of information about Regular Expressions "out there", and also for many different languages.
A good place to start, would be here:
Regular-Expressions.info - Regex Tutorial, Examples and Reference - Regexp Patterns
#5
Posted 16 May 2007 - 06:54 AM
v0id said:
I'm glad, you could use it.
To make the validation for the input even more secure, try look into some Regular Expressions. It's a short, clean - but also a bit hard way to validate your input in only a line, or maybe a little more. There's tons of information about Regular Expressions "out there", and also for many different languages.
A good place to start, would be here:
Regular-Expressions.info - Regex Tutorial, Examples and Reference - Regexp Patterns
To make the validation for the input even more secure, try look into some Regular Expressions. It's a short, clean - but also a bit hard way to validate your input in only a line, or maybe a little more. There's tons of information about Regular Expressions "out there", and also for many different languages.
A good place to start, would be here:
Regular-Expressions.info - Regex Tutorial, Examples and Reference - Regexp Patterns
Discovered one problem, it clashes with the Google Search of Adwords!! it displays invalid URL!!


Sign In
Create Account


Back to top









