Lost Password?


Go Back   CodeCall Programming Forum > Web Development Forum > PHP Forum

PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-16-2007, 08:37 AM
TcM's Avatar   
TcM TcM is offline
Code Warrior
 
Join Date: Aug 2006
Location: In a technologic world :p
Posts: 8,332
Rep Power: 68
TcM is a glorious beacon of lightTcM is a glorious beacon of lightTcM is a glorious beacon of lightTcM is a glorious beacon of lightTcM is a glorious beacon of light
Default Need help with proxy script please

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 05-16-2007, 09:53 AM
v0id's Avatar   
v0id v0id is offline
Retired
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,635
Last Blog:
CherryPy(thon)
Rep Power: 28
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default

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.
Code:
<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.
Code:
$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
__________________
05-03-2007 - 11-13-2008
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-16-2007, 10:33 AM
TcM's Avatar   
TcM TcM is offline
Code Warrior
 
Join Date: Aug 2006
Location: In a technologic world :p
Posts: 8,332
Rep Power: 68
TcM is a glorious beacon of lightTcM is a glorious beacon of lightTcM is a glorious beacon of lightTcM is a glorious beacon of lightTcM is a glorious beacon of light
Default

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!!

Last edited by TcM; 05-16-2007 at 10:41 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-16-2007, 10:45 AM
v0id's Avatar   
v0id v0id is offline
Retired
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,635
Last Blog:
CherryPy(thon)
Rep Power: 28
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default

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
__________________
05-03-2007 - 11-13-2008
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-16-2007, 10:54 AM
TcM's Avatar   
TcM TcM is offline
Code Warrior
 
Join Date: Aug 2006
Location: In a technologic world :p
Posts: 8,332
Rep Power: 68
TcM is a glorious beacon of lightTcM is a glorious beacon of lightTcM is a glorious beacon of lightTcM is a glorious beacon of lightTcM is a glorious beacon of light
Default

Quote:
Originally Posted by v0id View Post
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
Well I don't need to verifiy if it is a real URL or not, it's up to the user!!
Discovered one problem, it clashes with the Google Search of Adwords!! it displays invalid URL!!

Last edited by TcM; 05-16-2007 at 10:57 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
JavaScript:Tutorial, Using an External Script TcM Javascript 7 09-11-2007 08:39 AM
(Script) Copy content to clipboard, how? annannienann Visual Basic Programming 0 06-19-2007 06:20 PM
Tutorial: Proxy Servers Lop Tutorials 7 01-02-2007 04:53 AM
Proxy usage TcM Computer Software/OS 2 11-02-2006 01:00 PM


All times are GMT -5. The time now is 04:31 PM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 98%

Ads