5, September 2008

URL & Email Check - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Validate_fields Class (Moderator: Olaf)
Topic: URL & Email Check
« previous next »
Pages: [1] Print

Author Topic: URL & Email Check  (Read 1993 times)
What a dork
*
Posts: 15
112 credits
Members referred : 0


« on: Oct 01, 2006, 03:03:13 AM »

URL
a bug: it's better to do a short modif in this function.
for example if you type the following URLs:
1) mydomain.com/~mypage    (to see a user's homepage in a unix server)
2) mydomain.com/mypage.shtml
it will give you an "Invalid Url" message! but both of them are correct and ordinary!!!

Email
i have seen a sample script in your website to check if an email address exist,
but this script is not included in the Email Check function of validation field class.
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6309
38674 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Oct 01, 2006, 12:44:48 PM »

hello,

Thank you for pointing me on this regex errors/  problems:

Quote
1) mydomain.com/~mypage    (to see a user's homepage in a unix server)
is this public type url? it looks more like a url for a homepage provided for free by your ISP, right?

Quote
2) mydomain.com/mypage.shtml
this was easy:
Code:
$url_pattern .= "((\/[\w\-\.]+\.[[:alnum:]]{2,5})?"; // filename like index.(s)html

Quote
i have seen a sample script in your website to check if an email address exist,
but this script is not included in the Email Check function of validation field class.

thats right the email address check Visit through proxy is different.

the regex from the class is more advanced and the snippet is using checkdns (which is not working on windows)
maybe I will combine them later...


Last blog : Is your website is down? Know before your visitors do!
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8037
41179 credits
Members referred : 3



« Reply #2 on: Oct 01, 2006, 12:52:43 PM »

Olaf I checked your snippet (about the email), and I think that the MX lookup is not recommended, as the mail server can reject your request in many cases (eg. the ip you are connecting has no reverse DNS entry)

I am not sure if this is happening often, but in case you have problems with this mail validation code you can use this email validation function Visit through proxy.

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : MIA - Where Nick and Tim
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6309
38674 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: Oct 01, 2006, 01:15:37 PM »

Olaf I checked your snippet (about the email), and I think that the MX lookup is not recommended, as the mail server can reject your request in many cases (eg. the ip you are connecting has no reverse DNS entry)

I am not sure if this is happening often, but in case you have problems with this mail validation code you can use this email validation function Visit through proxy.

that's why I used a regex only function in the validation class with this pattern: Wink
Code:
<?php
if (preg_match("/^[0-9a-z]+(([\.\-_])[0-9a-z]+)*@[0-9a-z]+(([\.\-])[0-9a-z-]+)*\.[a-z]{2,4}$/i"$mail_address)) {
return true;
} else {
$this->messages[] = $this->error_text(11$field);
return false;


Last blog : Is your website is down? Know before your visitors do!
What a dork
*
Posts: 15
112 credits
Members referred : 0


« Reply #4 on: Oct 01, 2006, 04:18:02 PM »

thanks for your care  Smiley
about: mydomain.com/~mypage:
yes! in most of universities, you can see the home page of students in this format. so your system should save this format of user's home page in the database.

i think you have make a good class, but it is better to do more work on the URL check. also using the pages whit script (like: /mypage.html?user="myname"..)

about check4htmltags option, it let the user to have such tages in the textbox: <b> my text </b>. is it true?
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6309
38674 credits
Members referred : 374


It's time to use PHP5!


« Reply #5 on: Oct 01, 2006, 04:27:52 PM »

check below:

Quote
about: mydomain.com/~mypage:
yes! in most of universities, you can see the home page of students in this format. so your system should save this format of user's home page in the database.
I know, I got this question before from some guy using the free webspace provided by a ISP, will add this later...(maybe Wink)

Quote
i think you have make a good class, but it is better to do more work on the URL check. also using the pages whit script (like: /mypage.html?user="myname"..)
querystrings are fine but you example is not valid, remove the quotes...

Quote
about check4htmltags option, it let the user to have such tages in the textbox: <b> my text </b>. is it true?
no all html is invalid, use ubb tags...


Last blog : Is your website is down? Know before your visitors do!
What a dork
*
Posts: 15
112 credits
Members referred : 0


« Reply #6 on: Oct 01, 2006, 08:52:34 PM »

when i install validate_fields_1-35 on my local windows server with Apache:
Open the Original validation_demo.php
(while $example->check_4html = true;)

Please Put the following text in "Simple_text":
this is a <b> text </b> for check the Html tages!

then submit the form.
you will see the from accept it! without returning any error!
i checked with "<h1> some text </h1>" too, but i had no error!
but there are HTML tages in the text fields!

but when i check http://www.finalwebsites.com/demos/form_field_validation.php Visit through proxy
for above item, it works! and returns the error message
but for the following text:
"hi  a test <h1> hi </h1>"

again it says All form fields are valid! and doesn't return any error message! as you see there are HTML tages in the statment, isn't it?

Please check
1) this is a <b> text </b> for check the Html tages!
2) hi  a test <h1> hi </h1>
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6309
38674 credits
Members referred : 374


It's time to use PHP5!


« Reply #7 on: Oct 01, 2006, 09:46:21 PM »

... you're right I forgot the number for the header tags.

I wrote the html check to prevent links etc. never thought about to test for a header... Wink

use this function until the next update:

Code:
<?php
function 
check_html_tags($value$field) {
if (preg_match("/<[a-z1-6]+((\s[a-z]{2,}=['\"]?(.*)['\"]?)+(\s?\/)?)*>(<\/[a-z1-6]>)?/i"$value)) {
$this->messages[] = $this->error_text(15$field);
return false;
} else {
return true;
}
}



Last blog : Is your website is down? Know before your visitors do!
What a dork
*
Posts: 15
112 credits
Members referred : 0


« Reply #8 on: Oct 03, 2006, 04:23:10 PM »

i checked the new code and get the following results:

1) when you type: hi <b> olaf! </b> it works.
2) when you type: hi <b > olaf! </b > it Doesn't work!
3) when you type: hi <h1 > olaf! again it Doesn't work!
« Last Edit: Oct 03, 2006, 04:25:27 PM by rouge et noire »
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6309
38674 credits
Members referred : 374


It's time to use PHP5!


« Reply #9 on: Oct 03, 2006, 04:51:01 PM »

i checked the new code and get the following results:

1) when you type: hi <b> olaf! </b> it works.
2) when you type: hi <b > olaf! </b > it Doesn't work!
3) when you type: hi <h1 > olaf! again it Doesn't work!

is this about unvalid html code? use strip_tags() instead


Last blog : Is your website is down? Know before your visitors do!
What a dork
*
Posts: 15
112 credits
Members referred : 0


« Reply #10 on: Oct 04, 2006, 04:55:21 AM »

when we put <b   > a text </b   >
it's not invalid HTML tag, since that tag works in a webpage.
so what's your opinion to prevent user to type any "<" or ">" characters or using like htmlspecialchar() or htmlentities() or like you told, strip_tages()?
in your opinion, what way is better?
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6309
38674 credits
Members referred : 374


It's time to use PHP5!


« Reply #11 on: Oct 04, 2006, 09:05:49 AM »

when we put <b   > a text </b   >
it's not invalid HTML tag, since that tag works in a webpage.
so what's your opinion to prevent user to type any "<" or ">" characters or using like htmlspecialchar() or htmlentities() or like you told, strip_tages()?
in your opinion, what way is better?

You know how more code is valid after the regex check how more problems you can except. I think that I would use strip_tags in addition, but that depends on the application (moderated form post or not)


Last blog : Is your website is down? Know before your visitors do!
What a dork
*
Posts: 15
112 credits
Members referred : 0


« Reply #12 on: Oct 04, 2006, 01:22:23 PM »

oh yes. i think you have made a good code at all.
and we are just trying to make it better and more perfetc.
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=4306
Tags : html databases snippets dns email Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Validate_fields Class (Moderator: Olaf)
Topic: URL & Email Check
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Sep 05, 2008, 06:17:56 PM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 36.293
Total Topics: 7.476
Total Members: 3.899
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: speedy5044

31 Guests, 5 Users online :

13 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.