Click to See Complete Forum and Search --> : validate web address


kproc
10-29-2006, 06:57 PM
Hi I have a form were users enter a web address, is there a way to validate the web address when the form is submited

themarty
10-30-2006, 03:52 AM
you could try to open it with fsockopen() (http://www.php.net/fsocopen).

knowj
10-30-2006, 04:08 AM
also a preg_match() on the url to check it follows a pattern would help

http://uk2.php.net/preg-match

netbuddy
10-31-2006, 06:12 PM
You could even do it on the clients PC... Oooh err misses!

Use AJAX to test the domain exists prior to allowing the user to upload.

It is all very well submitting the data to a server, it does help you more when the client-side of things is used to ensure that the data is "Clean" meaning that you have checked and processed anything prior to posting to the server.

Your server-sides then will have less coding as you offloaded that portion of the checking and validation on the client, no workload for your server so you serve more people!

pcthug
11-01-2006, 12:52 AM
You could even do it on the clients PC... Oooh err misses!

Use AJAX to test the domain exists prior to allowing the user to upload.

It is all very well submitting the data to a server, it does help you more when the client-side of things is used to ensure that the data is "Clean" meaning that you have checked and processed anything prior to posting to the server.

Your server-sides then will have less coding as you offloaded that portion of the checking and validation on the client, no workload for your server so you serve more people!What happens if the client does not have an AJAX compatible browser (i.e. JavaScript is turned off, etc.)?

Use a relevant domain socket connect function, fsockopen() (http://au3.php.net/manual/en/function.fsockopen.php)

bokeh
11-01-2006, 09:10 AM
Use AJAX to test the domain exists prior to allowing the user to upload.You cannot use AJAX to send requests to domains other than the domain of the host page.

netbuddy
11-01-2006, 09:36 AM
What happens if the client does not have an AJAX compatible browser (i.e. JavaScript is turned off, etc.)?

Use a relevant domain socket connect function, fsockopen() (http://au3.php.net/manual/en/function.fsockopen.php)

Same old argument, same old answer... If they want to live in paranoia and fear then let them.

However the form STILL can be submited to the server.... Duh! but no validation has taken place.

netbuddy
11-01-2006, 11:10 AM
You cannot use AJAX to send requests to domains other than the domain of the host page.

Cant find it, I had a URL to an article that dealt with domain checking using AJAX, something to do with email addresses, which as you know has a domain.tld address on it.

bokeh
11-01-2006, 12:53 PM
Cant find it, I had a URL to an article that dealt with domain checking using AJAX, something to do with email addresses, which as you know has a domain.tld address on it.It is not possible to use AJAX to liase with third party sites due to the security risk. What you are suggesting is impossible. The only way it would be possible is if the request went via the host site, which would still need the code suggested above and be pretty pointless (due to the increased complexity for no reward).