Add to Google

Gahhh This Isn't Going Well Please Help! - It's a forgot password form in php!

Pages: 1, 2
free web hosting

Read Latest Entries..: (Post #12) by tracdoor on Jun 1 2008, 08:20 PM. (Line Breaks Removed)
Why don't you use Mysql query? that would make it a lot easier!Don't jump in at the deep end trying to make a super secure login script with loads of features, a simple register, login and logout is fine for a first try! from there you can make more adjustments to it later. Also i noticed you don't seem to have a members page yet, what use is a forgotten password script if your... read more.
Read the FIRST post of this Topic. - Express your Opinion! Contribute Knowledge :-).

Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Gahhh This Isn't Going Well Please Help! - It's a forgot password form in php!

chappill
CODE
<?
// database connection details stored here
include "database.php";
?>
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>Thanks!</title>
</head>
<body bgcolor="#ffffff" text="#000000">
<?
$email=mysql_real_escape_string($email);
$status = "OK";
$msg="";
//error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR);
if (!stristr($email,"@") OR !stristr($email,".")) {
$msg="Your email address is not correct<BR>";
$status= "NOTOK";}
echo "<br><br>";
if($status=="OK"){ $query="SELECT * FROM users WHERE password = '$email'";
$st=mysql_query($query);
$recs=mysql_num_rows($st);
$row=mysql_fetch_object($st);
$em=$row->email;// email is stored to a variable
if ($recs == 0) { echo

That's a snippet of code from my forgot password form on my site...I don't know why it doesn't work. Here's a few links you may need to help:
http://chappill.trap17.com/test/test/login.php
http://chappill.trap17.com/test/test/register.php
http://chappill.trap17.com/test/test/forgot.php

Login is the login page, register is the register page and forgot is the forgotten password page, I hope you can help!
The problem is when you click submit on the forgotten password page it takes you off to the next page (like it should) but the next page displays
QUOTE
Your email address is not correct
Even though I know It's right... so there must be something wrong wth the way the script gets the information out of the MySQL database, heres the full code: http://www.chappill.trap17.com/test/test/lookhere.txt

 

 

 


Reply

rvalkass
The problem lies with the way you check for the pattern of an email address:
CODE
if (!stristr($email,"@") OR !stristr($email,".")) {


I would take a look at using regexp to detect email addresses, rather than stristr. preg_match will use a regular expression, and tell you whether a given string matches that regular expression.

There is a lot of information on validating email addresses using regular expressions here: http://www.regular-expressions.info/email.html

Reply

chappill
Hmmm now that's confused me :S So I change
CODE
if (!stristr($email,"@") OR !stristr($email,".")) {
to this
CODE
if (!regexp($email,"@") OR !regexp($email,".")) {
??? Or is that wrong, help I'm lost!!!

But thanks for trying, i get into al sorts of problem with my scripts lol.

Reply

rvalkass
No, regexp isn't a function tongue.gif

Regexp stands for regular expressions, and is a way of checking if a string matches a certain pattern. In PHP, the easiest way to use regular expressions is with preg_match. You use it like this:
CODE
preg_match("regexp here", "string to check here");

It will return 0 for no matches, or 1 for a match.

The most difficult part is writing the regexp - the pattern the email address has to match to be classed as valid. Regular expressions are tricky to understand to start with, but incredibly powerful.

Reply

chappill
Gahhhh my head hurts I need another break already but I'm not off!

I now have:
CODE
preg_match("$email,"@"", "$email,"."");

Instead of:
CODE
if (!stristr($email,"@") OR !stristr($email,".")) {


And that produces the error:
QUOTE
Parse error: syntax error, unexpected '@' in /home/chappill/public_html/test/test/forgot-passwordck.php on line 36

Line 36 is that very line above...It's still screwed and It's all because I'm a retard =[

Reply

rvalkass
What you want that line to say is this:

CODE
if ( preg_match("^[-._%+A-Za-z0-9]+@[-.A-Za-z0-9]+\.[A-Za-z]{2,4}$", $email) == 0 ) {


The most difficult part to understand is the regexp string, which I will try to explain below. It is basically a pattern that the variable $email must fit to be declared valid. If it fits the pattern, preg_match returns 1, and the email address is valid. If it doesn't fit the pattern, preg_match returns 0, and the email address is invalid.

So, to explain that huge jumble of characters:
  • ^ - The start of the string
  • [-._%+A-Za-z0-9] - Look for the -, ., _, % and + characters, along with characters in the ranges A-Z, a-z and 0-9...
  • + - ...repeated any number of times...
  • @ - ...followed by the @ sign...
  • [-.A-Za-z0-9] - ...then more letters...
  • + - ...repeated any number of times...
  • \. - ...followed by a dot...
  • [A-Za-z] - ...then the letters A-Z and a-z...
  • {2,4} - ...repeated between 2 and 4 times (the domain, like .COM or .UK or something)...
  • $ - ...and then the end of the string.

 

 

 


Reply

chappill
Sorry it's been about 3 days just got off holidays =].
I put that line in and as I thought it would go ape over
QUOTE
Warning: preg_match() [function.preg-match]: No ending delimiter '^' found in /home/chappill/public_html/test/test/forgot-passwordck.php on line 47


Your email address is not correct
the little ^ thats in there, should that not be something else?

Reply

rvalkass
Sorry, PHP, for some reason, needs slashes added:

CODE
if ( preg_match("/^[-._%+A-Za-z0-9]+@[-.A-Za-z0-9]+\.[A-Za-z]{2,4}$/", $email) == 0 ) {


Just tested it, and it seems to work. Let us know.

Reply

chappill
Dude your a star =] Thanks so much for putting up with my dodgy scripts and finding and solving the problem, without you I would be lost, it works, thanks very much =]

Oh wait, I think theres something wrong with the way it's pulling the information from the MySQL. I have:
CODE
echo "<br><br>";

if($status=="OK"){ $query="SELECT * FROM users WHERE password = '$email'";

$st=mysql_query($query);

$recs=mysql_num_rows($st);

$row=mysql_fetch_object($st);

$em=$row->email;// email is stored to a variable

That as the code, my MySQL table is set up like this, users as the table name which i presumed was FROM, and then username, password and email as my fields. Should this be changed?

Reply

rvalkass
Either you have a very weird and confusing way of naming variables, or this line is wrong:

CODE
{ $query="SELECT * FROM users WHERE password = '$email'";


Any reason the password would be the same as their email address?

Reply

Latest Entries

tracdoor
Why don't you use Mysql query? that would make it a lot easier!

Don't jump in at the deep end trying to make a super secure login script with loads of features, a simple register, login and logout is fine for a first try! from there you can make more adjustments to it later. Also i noticed you don't seem to have a members page yet, what use is a forgotten password script if your visitors have no reason to come back!.

Like I said don't jump in at the deep end, simple Mysql query's are fine! if you do that there's little chance of errors, and the errors that you do get are simple mistakes, ones that a novice could correct easily.

Reply

rvalkass
QUOTE(chappill @ May 31 2008, 09:34 PM) *
Good point lol I have absolutely no idea, a friend recommended
CODE
{ $query="SELECT email,password,username FROM users WHERE password = '$email'";


But i can't see that working either and it didn't!


You've still got password equal to email...?

Surely that line should either be:
CODE
{ $query="SELECT * FROM users WHERE email = '$email'";


Or:
CODE
{ $query="SELECT * FROM users WHERE password = '$encryptedPassword'";


Identifying users by their password seems somewhat bizarre, so I assume you want the first example - getting a list of people with the email address you want.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Pages: 1, 2
Recent Queries:-
  1. forget password php - 222.76 hr back. (1)
  2. $_files preg_match english letter only - 927.08 hr back. (1)
  3. php forgot password script - 958.53 hr back. (1)
  4. php preg_match check repeat characters - 1046.21 hr back. (1)
  5. how can i use deep freezer in command prompt - 1966.39 hr back. (1)
Similar Topics

Keywords : gahhh, isnt, forgot, password, form, php

  1. Registration Form?!
    Password Issue??? (6)
  2. A Simple Password Page
    I can't make one!!! (3)
    I'm trying to make a simple password page for one of my PHP experiments. Every time I try to
    post a password, however, it returns an error that the connection was "closed by the server". The
    entire code is only 3 pages. password.php: $rightuser = ""; $rightpass = ""; include
    ('getpassword.php'); if $_POST !== $rightuser { if $rightuser == '' { ?>The
    username is incorrect. It should be blank. } else { ?>The username is incorrect. It should be .
    } } else { if $_POST !== $rightpass { if $rightpass == '' { ?>The password is i....
  3. Phpbb Password Protector
    Any Good Ones Out There? (3)
    I have searched and searhed and searched for a good Password Protection Mod for the PHPBB Forums,
    but i cannot find one that will work, i have uploaded the files necessary to the Admin/mods section,
    then i do what it says in the file that tells me how to do it, but they never work for me.. im
    Getting this.. QUOTE Warning: main(./extension.inc): failed to open stream: No such file or
    directory in /home/phillip/public_html/rpg/admin/mods/Password-protected forums
    0.5.1/phpbb_root_path/db_update.php on line 22 Warning: main(./extension.inc): failed to open
    stream: No....
  4. Password Strength / User Availablity Scripts ?
    (2)
    many of u guys would already have noticed that now a days , on most of the websites , when some one
    sign in...as he puts his desired username in the textbox , the page shows that it is not available
    or it is available...without pushing any button etc.. and the second thing , when some one writes
    the password , on the same screen , it shows that password is weak or password is strong... i think
    it is done with php ... can some one give me a link to any page where i can access these scripts ?
    or some one can help me regarding this ?? Thanks for helping always.....
  5. Requesting Php Mailing List Script
    That isn't detected as Spam (3)
    hello guys...i was looking for a script that sends mails to my frineds at once or to send like 50
    mails at once and i saw that actually fantastico has a script already pre-installed, but it is not
    as good as i expected it would. The mails are send as spam and that is not actually a good solution
    since many companies well ok hotmail deletes that kind of mails, and yahoo! send'em to the spam
    too. And i never could have the mailing list properly working. So i would like to have a easier to
    use script and also that the mails host doesnt think it is all spam and somethi....
  6. Mysql Password
    (2)
    Hey guys quick question about trap 17s mysql version. How do i change the password to the database?
    I cant seem to find online help for this version anywhere. Any help is very apperciated!....
  7. creat password with php?
    (6)
    how....

    1. Looking for gahhh, isnt, forgot, password, form, php






*SIMILAR VIDEOS*
Searching Video's for gahhh, isnt, forgot, password, form, php

*MORE FROM TRAP17.COM*
advertisement



Gahhh This Isn't Going Well Please Help! - It's a forgot password form in php!



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE