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. how can i use deep freezer in command prompt - 831.98 hr back. (1)
Similar Topics

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

  1. I Can't Find The Password Reset Page... [resolved]
    (5)
  2. Submitting A Form In Flex (follow Up Of Sm's Tut)
    (2)
    Now Saint Michael made an excellent 3 part tutorial that explains how to make a form HERE So if
    you need to design a form follow his nice tutorial. He did however mention he didnt know (yet) how
    to submit a form, so i did some searching last night and made my form submit to a PHP file and this
    is how its done (roughly, ive only had flex since last night so expect problems! My form is
    designed as an email contact form but at the moment because i dont have a local mail server
    configured im using the fwrite functions in PHP to illustrate that it works and to save the....
  3. Phpmyadmin Password Does Not Work
    (7)
    I have been designing my site on my desktop using XAMPP. Everything was ok until I thought I needed
    a pasword for my database which did not have a password. From the day I applied the password I have
    been unable to access my phpMyAdmin I type http://localhost/phpmyadmin/ and all I get is: QUOTE
    Error MySQL said: #1045 - Access denied for user 'root'@'localhost'
    (using password: NO) "Who said use no password?" I wonder. I have tried to clear private data
    in the Firefox but I ended up thinking it was not necessary because even IE which....
  4. Design A Contact Form In Flex Part 3
    (2)
    Design A Contact Form In Flex Part 3 Hopefully you have able to get a grasp on my first tutorials
    on how to design a flex form and then be able to stylize it with CSS. So now on to set up your form
    to validate and of course being able to reset your form as well., and before we get to the actual
    coding I break down the tags that will be used in this tutorial and what their roles are. Of course,
    since my newbieness really starts here I try my best to explain these tags. The first tag I will
    cover for setting up the validation is the tag, and since I don't underst....
  5. Design A Contact Form In Flex Part 2
    (0)
    Design A Contact Form In Flex Part 2 I hope that you learn a little bit of the Flex format with my
    first tutorial because that was the easy stuff until you get to the actual programming such as
    ActionScript and any other languages. Of course, I think this is by far the easiest part of
    designing forms or applications and that is using CSS. I will like to point out that CSS in Flex is
    a enigma and I will tell you why, because CSS in flex acts like regular CSS in html however it is
    very limited in what you can use and yet CSS in Flex is very complex because of how you ca....
  6. Password Protecting My Webpage
    Help Needed ! Can any one assist me ? (3)
    Hello friends , i have been hosting a website which has a phpBB2 forum and i have a lot of spam
    accounts inspite of the captcha which is present in the registration form . So i had already posted
    that matter and all the solutions did not stop spammers from creating a account . All that i could
    do was just stop them from posting in the forum, still spammers account ID are visible in the
    members List So now i thought of protecting the webpage itself with a password . Let me explain
    it to you clearly , my phpBB2 forum is intalled in a directory by name "phpBB2" So i trie....
  7. About Posting Form
    (2)
    Hi i had just register for free account and just think that why it is so important to post form for
    free hosting....
  8. Text Size In "fill-in" Form Blanks
    How do you change the size of the text in the fill in form entry boxes (2)
    Thanks for all the help on my previous question about adding an address to a "Submit" button.
    I've also been able to add a "print page" button through the help from group members. I now have
    another question. I've created a form using the Input commands that ask for name, address,
    state, etc. My computer is set to use 12 point text on a 800 x 600 screen resolution. When I hit the
    print screen button, everything is printed out fine, but I would like the information that people
    will be entering into the various boxes to be of a larger or bolder style. The whole re....
  9. Unable To Change Cpanel Password
    Too simplistic/systematic (5)
    ... and my password looks like "lnnnnnnnnnssnnnln" (l = letter, n = number, s = symbol like
    !@#$%?&*()) !?....
  10. Design A Contact Form In Flex Part 1
    (0)
    Design a Flex Form Part 1 Well this is my first tutorial on Adobe Flex 3 which is a great program
    if you’re interested in designing applications for the web 2.0 era. Adobe flex is the way to
    go as it combines several different programming languages in order to make the most out of this
    program. This includes HTML, CSS, XML, PHP/MySQL, XML, ActionScript, Ruby on Rails and ASP and this
    is all possible by the use of MXML or Magic eXtensible Markup Language because it is a user
    interface markup language. My three part tutorials for this form include designing the f....
  11. How To Remember Complex Passwords
    Use the BEST password system ever! (9)
    The Trap17 forums have a whole subforum devoted to those amongst use who have failed to remember
    their passwords, and have locked themselves out of their free web hosting account. If you forget
    your password, you can go to Free Web Hosting, No Ads > FREE WEB HOSTING > FREE WEB HOSTING
    REQUESTS > Free Web Hosting : Password Reset and ask the friendly admins there to reset your
    password for you. Remember the days when your password on the Internet could be something like
    andrew18 ? And you could use that same password on all three websites that you visited....
  12. The Old Games
    Have we forgot about the classics with all this new technology. (5)
    Better graphics and more pixels and 30 buttons does not mean a better game. Far from it. I think
    gameplay has gone down in many games becasue the focus was on graphics or something other then. Your
    thought.....
  13. I Think I Need A Cpan Password Reset
    (0)
    Hi guys, been a while since ive been around, luckily i build up a nice amount of credits so im still
    actively hosted. But Ive forgotten my cpanel password, im pretty sure i still know my username but i
    need to get my password reset. I couldnt find the automatic way to do this so i thought id throw up
    a post and hope someone can give me a linky or do it for me. Im assuming itll still cost me 10
    credits which is fine. So if anyone is able to start the process off go for it, i can afford the 10
    credits to do it /smile.gif" style="vertical-align:middle" emoid=":)" border="....
  14. I Forgot My Log In Information
    need help (5)
    Due to having registered to many sites lately and not logging in to my hosting account in last few
    weeks, I seem to have forgotten my log in info. Is there any way to retrieve it?....
  15. Perl For Automated Web Form Search
    (1)
    Hi all, I'd like to write a script to automate a search in order to collect data from an online
    database. The database is an archive of newspaper articles. The search is for certain words/text. It
    is searchable via a form only. The rub is that only a small portion (a month) at a time is
    searchable. I need to search every day for 50 years or so. Manually, this would take a considerable
    amount of time. I'm thinking of using perl or ruby or something similar. I am an absolute
    beginner with scripting and haven't done much formal learning in the subject since a ....
  16. How Do Uninstall Deep Freezer If I Lost Password?..
    (2)
    i have lost the password of my deep freezer instaalled to my computer and i want to install
    softwares but it is not saving cuz of the deep freezer so how can i uninstall it......i don't
    have the password......
  17. Vb 2008 Linking To Another Form..
    (0)
    if i want to link another form will i use this code or there is easier one? code : form2.show or
    hide : form2.hide is there another code to be used...? thanks....
  18. Simple Javascript And Password System
    How to protect your pages with password (9)
    The quickest way to get a password protection system up and running is to use a Prompt box in
    JavaScript that has a title like "Enter your Email Address". Only you and the relevant users know
    what the password should be, could even be one each, that can be sorted out at the next page then
    pass the "input" directly through the url by changing the .href, like
    http://www.iSource.net.nz/users/?leTmeIn= The page that then processes this should also check for
    the referring page, and three fails from an IP if you like the php (the next page): CODE
    <?php // processdo....
  19. Php Ftp Upload Form
    Adding User Directory to PHP Upload Form - Help (1)
    Alright I am trying to have a PHP FTP Upload Form that allows the user to create the directory
    folder for where they want to upload there files to. example: Main Directory: vainsoft.com There
    directory: vainsoft.com/modeling or vainsoft.com/photography But I dont want them to be able to
    upload things into the main directory, only sub-directories, is that possible with this coding that
    I have: //uses $_FILES global array //see manual for older PHP version info //This
    function will be used to get the extension from the filename function get_extension($fi....
  20. What Is A Computer Form Factor
    (1)
    As I began my hardware class in school I knew I was going to be learning some new stuff about a
    computer that I never really thought about besides the fact I use one. Hopefully what I talk about
    in this topic will help people get a better understanding of computer hardware, especially when
    might want to build one by scratch. The form factor is used to determine what power supply,
    computer cases and motherboards you can use when building a fully customized computer instead of
    getting one pre-built; such as Dell, Apple, Sony, and Alienware. There are 6 form factors (in....
  21. Have Diferences Of Performance Form Ps2 Full Console To Mini-ps2?
    (8)
    Hi. Please if anybody test a mini-ps2. Have diferences of performance form PS2 full console to
    mini-ps2? thanks.....
  22. Rpg Code And Rpg Toolkit
    oh I forgot pixeling (10)
    Has anyone ever heard of RPG Code or even RPG Toolkit. RPG Toolkit is an RPG Creation tool. And RPG
    Code is the code that you use for programming a game using RPG Toolkit. Also does anyone know a good
    site for me to learn how to draw using pixels? I really need this for Dark Times, a game that I am
    creating.....
  23. The Reason Why People Get Drunk?
    Isn't there a 1,000,000 other things you can do? (37)
    OK i'm not talking about having a glass of wine a dinner. I'm also not talking about people
    who have drinking problems. I'm talking about why do people decide to get drunk for fun?
    Don't call me a prude cause i have drank before and even gotten into trouble at school for it. I
    did all of those because it was "cool" I have never understood why people just decide to get drunk
    though. One of my friends that comes over and is also one of the the main person in the O&J
    Productions crew (http://ojproductions.net my site) Always goes," we should get wasted ton....
  24. Windows Admin Password Hack
    (3)
    Windows Admin Password Hack: Forgot your NT admin password? Reinstall? Oh no... But not any more...
    This is a utility to (re)set the password of any user that has a valid (local) account on your NT
    system. You do not need to know the old password to set a new one. It works offline, that is, you
    have to shutdown your computer and boot off a floppydisk or CD. The bootdisk includes stuff to
    access NTFS and FAT/FAT32 partitions and scripts to glue the whole thing together. Will detect and
    offer to unlock locked or disabled out user accounts! It is also an almost fully ....
  25. Forgot Password To Trend Micro Internet Security
    Is there a way to remove it? (6)
    One day I was bored so I set a password for our Web security software, Trend Micro Internet
    Security. I turned on the URL filter, and now, whenever my friends send me something funny that has
    no porn or anything in it, I get the Blocked error. I am really annoyed by this; I can't change
    other setting in the software too. Is there any way to either reset the password or remove it,
    without uninstalling Trend Micro?....
  26. What Is Mysql's Default Root Password?
    Just installed in on my Linux box (9)
    I installed SuSE Linux 9.1 Professional on an old computer recently. I installed MySQL server
    (version 4.0.18), Webmin (version 1.250) and Usermin (version 1.180). If I try to connect to the
    MySQL server with the username root and no password, I get an invalid login error from Webmin,
    Usermin and mysql-cc. What is the default password, and how can I change it? I am very excited to be
    learning Linux (after a long journey through Windows-land), but get frustrated on loopholes like
    these. Also, an a different note, why would the system stop loading after a certain point (to....
  27. Problems With Outlook Express
    My email configuration isn't working (7)
    Does anyone have a clue as to why my outgoing email isn't working with Outlook express? I can
    get incoming mail, but I'm getting an error when I try to send email. I followed the
    configuration instructions, but it still isn't working correctly. I get an error everytime.....
  28. Changing A Gmail Password
    how do u do it? (10)
    hi i have a gmail account well a couple of them and i know that someone has been getting on my
    account and screwing with it however i dont know how im supposed to get on and change my password.
    i've tried even getting them to send me information and what not when i forget my password but
    all the same i can never get to a point where i can change it and it kinda is making me upset. my ex
    gets on my account and yells at my friends telling them that i've changed and that i dont want
    anything to do with them and thats wrong i love my friends. anywayz if you know how ....
  29. Making Winrar Archives
    and adding password to winrar archives (13)
    **** This tutorial will show you how to put files into .rar Archive and pass worded (if wanted)
    **** What You Will Need Before continuing you will need a couple of thing, first of all you
    need WINRAR , which is a very powerful archive manager. It can reduce size for you email
    attachments, decompress RAR, ZIP and other types of files downloaded from the internet. You can get
    winrar at http://www.rarlabs.com The other thing is that make sure your using Windows XP because
    this is what I used to make this tutorial. I think it works with any other windows not....
  30. Free Windowsxp Sp2 Cd From Microsoft
    just fill the request form and recive it (13)
    microsoft offer 100% free windows xp sp2. just go to this link
    http://www.microsoft.com/windowsxp/downloa...us/default.mspx and fill your address they will send
    you the cd to you. I just recive the cd yesterday. /biggrin.gif' border='0'
    style='vertical-align:middle' alt='biggrin.gif' /> I see new feature like directx 9c , WMP9 ,
    firewall , and the one I like is popup blocker! /wink.gif' border='0'
    style='vertical-align:middle' alt='wink.gif' /> PS. waiting for the cd about 1-2 week if you
    write an exact address.....

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

*RANDOM STUFF*





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

*MORE FROM TRAP17.COM*
Similar
I Can't Find The Password Reset Page... [resolved]
Submitting A Form In Flex (follow Up Of Sm's Tut)
Phpmyadmin Password Does Not Work
Design A Contact Form In Flex Part 3
Design A Contact Form In Flex Part 2
Password Protecting My Webpage - Help Needed ! Can any one assist me ?
About Posting Form
Text Size In "fill-in" Form Blanks - How do you change the size of the text in the fill in form entry boxes
Unable To Change Cpanel Password - Too simplistic/systematic
Design A Contact Form In Flex Part 1
How To Remember Complex Passwords - Use the BEST password system ever!
The Old Games - Have we forgot about the classics with all this new technology.
I Think I Need A Cpan Password Reset
I Forgot My Log In Information - need help
Perl For Automated Web Form Search
How Do Uninstall Deep Freezer If I Lost Password?..
Vb 2008 Linking To Another Form..
Simple Javascript And Password System - How to protect your pages with password
Php Ftp Upload Form - Adding User Directory to PHP Upload Form - Help
What Is A Computer Form Factor
Have Diferences Of Performance Form Ps2 Full Console To Mini-ps2?
Rpg Code And Rpg Toolkit - oh I forgot pixeling
The Reason Why People Get Drunk? - Isn't there a 1,000,000 other things you can do?
Windows Admin Password Hack
Forgot Password To Trend Micro Internet Security - Is there a way to remove it?
What Is Mysql's Default Root Password? - Just installed in on my Linux box
Problems With Outlook Express - My email configuration isn't working
Changing A Gmail Password - how do u do it?
Making Winrar Archives - and adding password to winrar archives
Free Windowsxp Sp2 Cd From Microsoft - just fill the request form and recive it
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