|
-
Apr 15th, 2007, 06:24 PM
#1
Thread Starter
Junior Member
How to do forgot password?
Hi all i have done a system using php but in my login page made a forgot password link, but dont have any domain name can anyone tell me how i can do that make it work, as in my php when user if forgot the password they system will send a random password to there system but cannot do that. Here is blow my code Thanks all.
PHP Code:
<?php
session_start();
// 'Forget your Member Password' script
// Include Files
require_once ("database.php");
require_once ("globals.php");
require_once ("loginlib.php");
$title = $g_system_name . " -- Password reset";
ShowHeader ($title);
echo "<body>";
ShowLinks (3);
$header="User password reset";
$comment = "";
if (isset($_POST['state'])) {
$custemail = $_POST['email'];
// ·-·
$sql_stm = "select cu_user, cu_fname from customer where cu_email = '$custemail'";
$result = mysql_query($sql_stm);
$status = 0;
if($result && (mysql_numrows($result) >= 1)){
$dbarray = mysql_fetch_array($result);
$custname = $dbarray['cu_fname'];
$userid = $dbarray['cu_user'];
$username = GetusernameXID ($userid);
$password = GetRandomPassword();
UpdatePassword ($userid, $password); // update the password in the database
$from = ""; [QUOTE] what shall i put inside that "" so send user random password[/QUOTE]
$ccText = "";
$bccText = "";
$msg = "Hi $custname,\n\nYou have recently requested that a new password be sent to your email address.
Your Login is: $username\n\nYour new Password is: $password\nClick the link below to log in.\n
http://127.0.0.1/login.php\n\nSincerely,\n\nWeb Space Management system Team";
$title="PhpMail";
$toText=$custemail;
$subjectText="Your Random Member Password";
mail($toText, $subjectText, $msg,"To: $toText <$toText>\n" ."From: $from <$from>\n" .$ccText.$bccText. "X-Mailer: PHP 4.x");
$comment = "Email sent!";
} else {
$comment = "No such member account found. Please try a different email";
}
}
?>
<CENTER>
<TABLE WIDTH=400 BORDER=0 CELLPADDING=0 CELLSPACING=0>
<TR VALIGN=TOP>
<TD WIDTH=400 BGCOLOR="#3bb2d9">
 
<center>
<font face=arial size=4>
<b>
<?php
echo "<h1><font size='4'><font color='#FFFF00'>$header</font></font></h1>";
if (strlen($comment = trim($comment)) > 0)
echo "<p>$comment</p>";
?>
</b></font>
</center>
<form method="POST" action="passreset.php">
<table width=400 border=0 cellspacing=10 cellpadding=0>
<tr>
<td colspan='2' valign=top align=left>
Enter your member email address below,
and we'll send you a new password.</td></tr>
<tr>
<td valign=top align=left>
<font face=arial size=-1>
<b>Member Email:</b></font></td>
<td valign=top align=center>
<input type=text name="email" size=25>
</td>
</tr>
<tr><td colspan='2' valign=top align=center>
<input type="submit" value="Send">
<input type="hidden" name="state" value="1">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</center>
</BODY>
</HTML>
-
Apr 15th, 2007, 07:25 PM
#2
Re: How to do forgot password?
well, you don't need your own domain name to send someone an email. you just need a mail server, mostly. if you are on a shared hosting package and have a sub domain (eg. yourname.somehost.tld), then if you send email it will usually be from "[email protected]".
oh. I just noticed that you tried to write something inside your code. you can't use tags inside PHP tags; so that will not be apparent. you should have just asked in the first place what you're supposed to put as your domain name. uhh. just try putting your personal email there and see what it does.
if that doesn't work, what is the actual problem? can you not send email because you don't have a mail server available to you? if that's the case, then.. well, you're out of luck. you can't send email without a mail server. or, is your script returning an error? you didn't really provide much detail.
-
Apr 16th, 2007, 01:56 PM
#3
Thread Starter
Junior Member
Re: How to do forgot password?
Hi it gives me this error tho and I found the line which saying line 39 here is the code for that line
Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in c:\program files\easyphp1-8\www\passreset.php on line 39
And this is the lines 39 which saying the error happen to:
PHP Code:
mail($toText, $subjectText, $msg,"To: $toText <$toText>\n" ."From: $from <$from>\n" .$ccText.$bccText. "X-Mailer: PHP 4.x");
Hi thanks for replay can u explain what u mean about that mail server as u see above I thing that is the problem though I have email with my tiscali internet provider will that help I did use my email but still did not work
well, you don't need your own domain name to send someone an email. you just need a mail server, mostly. if you are on a shared hosting package and have a sub domain (eg. yourname.somehost.tld), then if you send email it will usually be from "[email protected]".
I really be very grateful if you can help me how to sort out that problem thanks in advance a lot.
-
Apr 16th, 2007, 03:00 PM
#4
Re: How to do forgot password?
what are you running this from? your home? do you not have a webserver hosted by some company, or are you just planning on hosting this from your house?
if you're going to be hosting it from your house, then you need to either point to an SMTP server in your "php.ini" file, or install an SMTP server on your own system. I would advise that you use your ISP's, because if you don't set up an SMTP server correctly, a spammer could exploit it and use it to send mass emails. so, to do this, you need to open up your PHP.ini file, usually located in either the directory you installed PHP to, or in your "C:/windows" directory. then, you want to look for the line that reads "[mail function]" (CTRL+F in Notepad to find it). you should see something like this:
Code:
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
;sendmail_from = [email protected]
you'll want to change all of these. the "SMTP" setting is the address to your mail server. if you're using your ISP's mail server, you will want to put their OUTGOING mail server here (usually something like smtp.ispname.tld, or mail.ispname.tld). by default, an SMTP server has a port of 25, but your ISP may not have it set up this way.. so just fill in the SMTP server port. next, you'll need to change sendmail_from to whatever email you want it to come from. you should use your own email, ideally. then, they can reply to you.
of course, there is a catch to all of this -- to use your ISP's SMTP server they must not have any authentication needed (authentication is generally not needed for users of their personal network; simply because they know you're already a customer of theirs). so, if that doesn't work, you might want to look into something like PHPMailer. It will let you authenticate with an SMTP server (opening up many possibilities, including using google's mail server to send email, for example -- or you could just use your ISP's). I've never used it, only heard about it.. and it looks like it's got plenty of good stuff.. I have no clue how to use it, either. you'll have to read the documentation and try to piece it together.
check it out at sourceforge here.
alternatively, if you want to install your own SMTP server, then I also have no recommendations as to what you'd want to get. I usually use the SMTP service in Windows 2003 Server, but I assume you aren't using it and don't have an extra machine to host your lowly website/mail server on. soo, you'll have to look into that yourself.
hope that helps.
Last edited by kows; Apr 16th, 2007 at 03:08 PM.
-
Apr 16th, 2007, 03:17 PM
#5
Thread Starter
Junior Member
Re: How to do forgot password?
Ok well iam really really very very grateful for your help and time thanks alot it is alot of information thought i have to read it over and over again and tried some it ok but thanks very much for all that i will let know if worked ok thanks.
-
Apr 16th, 2007, 03:18 PM
#6
Thread Starter
Junior Member
Re: How to do forgot password?
And yes iam running it from home.
-
Apr 16th, 2007, 03:31 PM
#7
Thread Starter
Junior Member
Re: How to do forgot password?
Hi couldnt find that PHP.ini and also coludnot find it in my C: window either can u plz let me know more i have installed my Easyphp 1.8 inside c;/program files so i have folder there in my program file called Easyphp1.8 but went throught didnt found any php.ini there thanks for your help.
-
Apr 16th, 2007, 05:09 PM
#8
Re: How to do forgot password?
I don't know where it installs to (and with limited searching I couldn't find out where, either), I've never used "easyphp" :/ try doing a search on your computer for "php.ini"?
If you can't find it, then I'm not about to install it to figure it out for you :/ so if all else fails, uninstall it and install Apache, PHP and MySQL by themselves. it does have a learning curve, though.
-
Apr 16th, 2007, 06:33 PM
#9
Thread Starter
Junior Member
Re: How to do forgot password?
Hi i did found it and made these changes but still not working can u please tell me is it correct or not and if not can u chaged for it beacuse it didnt works after changes here is what i have in my php.ini and this is after i changed ok thanks alot i really apperciated.
[mail function]
; For Win32 only.
SMTP = ntlworld.com
; For Win32 only.
sendmail_from = [email protected]
-
Apr 16th, 2007, 09:07 PM
#10
Re: How to do forgot password?
you need an smtp_port, too. well -- I don't know if you need one, because it might just make a default 25.
either way, I told you what to do in the post above this if it didn't work. look at the PHPMailer class. it supports SMTP authentication, and the mail() function does not. there's nothing else I can really do for you other than that :/
-
Apr 17th, 2007, 11:12 AM
#11
Thread Starter
Junior Member
Re: How to do forgot password?
Ok thanks alot for your time and help sorry bother you and apperciate it your help thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|