Search
Left Quote    A clever person solves a problem. A wise person avoids it.
- Einstein    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: verify user e-mail
  This user is offline  lingh0e
  Subject: "verify user e-mail" Posted: @ 11:57 am on Mar 03 2007   

Member #: 291
Rank: User - (29)
Since: 03/03/07
Posts: 29
From: Ohio

Rather than allow multiple accounts with one e-mail, I tried to duplicate the "check if username exists" snippit to work with e-mail.

I came up with this

Code:
$q2 = mysql_query(&qu ot;SELECT * FROM `members` WHERE `user_email` = '".$_POST[ 'email']." '");
$q3 = mysql_fetch_obj ect($q2);

if($q3->emai l == $_POST['user_em ail']) {
die('<BR> ;<BR>Sorr y, but the email "'.$q3-> ;user_email.'&q uot; is already in use, please choose another.');
}



I placed it directly underneath the username check portion. It works like a charm if the e-mail really does exist, but if it is a unique e-mail I get the response "Sorry, but the email "" is already in use, please choose another." Any advice on what I may be doing wrong?




Feel free to kick me if I get annoying
    Viewed: 13,372 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: verify user e-mail" Posted: @ 4:11 pm on Mar 03 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Hrm, im not sure maybe you can try something like this:


Code:


$q2 = mysql_query(&q uot;SELECT * FROM `members` WHERE `user_email` = '".$_POS T['email'].& quot;'") ;
$q3 = mysql_fetch_obj ect($q2);

if(mysql_num_ro ws($q2) >= 1) {
if($q3->emai l == $_POST['user_e mail']) {
die('<BR> ;<BR>Sorr y, but the email "'.$q3-& gt;user_email. '" is already in use, please choose another.');
}
}



Also, maybe characters such as '.' and '@' could be mis-interpreted or if its CaSeSeNsItIvE. To be sure you could do

if(strtolower(u rlencode($q3-&g t;email)) == strtolower(urle ncode($_POST[' user_email'])) }




-bs0d | AllSyntax.com

    Viewed: 13,364 Times | Reply to This | To top
  This user is offline  gravy
  Subject: "re: verify user e-mail" Posted: @ 11:47 pm on Mar 07 2007    

Member #: 294
Rank: User - (63)
Since: 03/07/07
Posts: 66
From: MN

So has anyone tested this code above, or is it in LIMBO? This feature interests me....




Photo Hosting Scripts? It's what I do....

    Viewed: 13,311 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: verify user e-mail" Posted: @ 11:53 pm on Mar 07 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Give the code I suggested a shot. It should work exactly like the username check. If you feel invalid characters are interfering with the conditioning, try str_replace for "@" and "." with maybe |at| and |dot| then you are comparing two strings without extra characters. Remember to pass the email through a junk array (excluding "@" and "."< img src=http://www. allsyntax.com/f orums/images/sm ilies/wink.gif border=0> to throw out the bad from the beginning.



Edited at 11:57:20 pm on 03/07/07


-bs0d | AllSyntax.com

    Viewed: 13,307 Times | Reply to This | To top
  This user is offline  gravy
  Subject: "re: verify user e-mail" Posted: @ 12:02 am on Mar 08 2007    

Member #: 294
Rank: User - (63)
Since: 03/07/07
Posts: 66
From: MN

will do, I will let everyone know if I get it working. oh yea, I will let you know if I don't.




Photo Hosting Scripts? It's what I do....

    Viewed: 13,302 Times | Reply to This | To top
  This user is offline  gravy
  Subject: "re: verify user e-mail" Posted: @ 1:59 am on Mar 08 2007    

Member #: 294
Rank: User - (63)
Since: 03/07/07
Posts: 66
From: MN

Heya,
bs0d's code works perfectly for me. Awesome job!




Photo Hosting Scripts? It's what I do....

    Viewed: 13,296 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: verify user e-mail" Posted: @ 3:53 am on Mar 08 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Nice! Thanks for the update.




-bs0d | AllSyntax.com

    Viewed: 13,290 Times | Reply to This | To top
  This user is offline  lingh0e
  Subject: "re: verify user e-mail" Posted: @ 4:31 am on Mar 08 2007    

Member #: 291
Rank: User - (29)
Since: 03/03/07
Posts: 29
From: Ohio

Works like a charm. Thanks!

I am slowly getting the hang of coding.




Feel free to kick me if I get annoying

    Viewed: 13,286 Times | Reply to This | To top
  This user is offline  gravy
  Subject: "re: verify user e-mail" Posted: @ 7:44 pm on Mar 08 2007    

Member #: 294
Rank: User - (63)
Since: 03/07/07
Posts: 66
From: MN

  lingh0e said...

< i> Works like a charm. Thanks!

I am slowly getting the hang of coding.


i know what you mean, i dont miss the days before php, but i am such a rockhead when it comes to it. i guess i am just to old of a dog for new tricks. hang in there, cause their are guys who are more than willing to help ya out.




Photo Hosting Scripts? It's what I do....

    Viewed: 13,260 Times | Reply to This | To top
  This user is offline  lingh0e
  Subject: "re: verify user e-mail" Posted: @ 1:47 pm on Mar 09 2007    

Member #: 291
Rank: User - (29)
Since: 03/03/07
Posts: 29
From: Ohio

edited until I can figure this out on my own a little more.

I am trying to figure out the functions for validating e-mail addresses, but I can't seem to get around it.



Edited at 03:14:25 pm on 03/09/07


Feel free to kick me if I get annoying

    Viewed: 13,233 Times | Reply to This | To top
  This user is offline  misterhaan
  Subject: "re: verify user e-mail" Posted: @ 3:16 pm on Mar 09 2007    

Member #: 5
Rank: User - (213)
Since: 02/11/05
Posts: 148
From: chair

the only real way to validate an e-mail is to send a code to it and have the user enter the code or click a link with the code in it.

but you can check if it's in the format A@B.C using regular expressions, or with something like this:

Code:

function checkemailforma t($email) {
$check = explode('@', $email); // turn the e-mail into an array, with the parts before and after the @ symbol. it should have 2 parts
if(count($check ) != 2)
return false;
return count(explode( '.', $check[1])) > 1; // make sure the part after the @ symbol has at least one dot
}



and to be complete, here's regular expressions:

Code:
function checkemailforma t($email) {
return preg_match('/^ .+@.+\..+$/', $email) > 0;
}



i'm not sure if one preg_match is faster or slower than two explodes




please note that the above post is likely made up in its entirety.

    Viewed: 13,226 Times | Reply to This | To top
  This user is offline  lingh0e
  Subject: "re: verify user e-mail" Posted: @ 5:05 pm on Mar 09 2007    

Member #: 291
Rank: User - (29)
Since: 03/03/07
Posts: 29
From: Ohio

  misterhaan said...

< i> the only real way to validate an e-mail is to send a code to it and have the user enter the code or click a link with the code in it.< /div>

That is what I am currently working on.

Here is my plan. I added two new fields to the members table: "user_sta tus" and "user_tim estamp". When a user registers, user_status will be set to "0" and user_timestamp will be given a value of the current time passed through the md5 encryption. I will then pull the user_id and combine it with the user_timestamp to generate the verification code. Upon verification, user_status will be upgraded to 1.

Seeing as how I have a very rudimentary understanding of PHP and SQL, I am sure this is quite an undertaking. To give you an idea of how slow going this is gonna be for me, I just now figured out how to insert the single digit "0" into the user_status field. Through trial and error, I finally figured out I had to set it to "tinyint ". So yeah, it's going to take awhile, but I have nothing better to do today.




Feel free to kick me if I get annoying

    Viewed: 13,220 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank