mjgdunne Posted April 18, 2008 Share Posted April 18, 2008 Hi i have this forgot password script which asks the user for their email address and username and if they are correct their details will be sent to their email address which they are registered with. Forgot.html <TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=30%> <tr> <TD ALIGN=CENTER VALIGN=TOP WIDTH=50> </TD> <TD ALIGN=LEFT VALIGN=TOP WIDTH=83%> </TABLE> <TABLE BGCOLOR="#F0F8FF" WIDTH=30%> <TR><TD ALIGN="center"> <p><b>Forgot your password?</b> Enter your email address and user name below, and we will email you a new password.<br> <i>Please use the email address you provided when you registered. </i></p> <form action="forgotpassword.php" method="post"> Email: <input type="text" name="myemail" id="myemail"><br /> Username: <input type="text" name="myusername" id="myusername"><br /> <br /><br /> <input type="hidden" name="command" value="forgot"> <input type="submit" value="Send password"> </form> </TD> </TR> </TABLE> </BODY> </HTML> Checklogin.php <?php session_start(); ini_set( 'display_errors', '1' ); error_reporting ( 2047 ); $host="localhost"; // Host name $username="root"; // Mysql username $password="root"; // Mysql password $db_name="test"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "root", "root")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from signup form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result = mysql_query($sql); if($result === false){ exit('db error: ' . mysql_error()); } // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // assign $_SESSION variables: $myusername, $mypassword and redirect to file "login_success.php" $userdata = mysql_fetch_row($result); //get the user row $_SESSION["myusername"] = $myusername; $_SESSION["mypassword"] = $mypassword; $_SESSION["mylevel"] = $mylevel; $debug = true; // Turn on DEBUGGING if($debug){ //for debug only echo 'myusername: ' . $_SESSION["myusername"] . "<br />\n"; echo 'mypassword: ' . $_SESSION["mypassword"] . "<br />\n"; echo 'mylevel : ' . $_SESSION["mylevel"] . "<br />\n"; exit(); } header("location:login_success.php"); } else { header("location:login_failure.php"); // echo "Wrong Username or Password"; } exit(); ?> Quote Link to comment Share on other sites More sharing options...
haku Posted April 18, 2008 Share Posted April 18, 2008 Are you asking a question or just showing off? Quote Link to comment Share on other sites More sharing options...
mjgdunne Posted April 18, 2008 Author Share Posted April 18, 2008 Asking a question, im new to php programming so my code is a combination from books, forums and probably some basic errors of my own, any help would be appreciated. Thanks. Quote Link to comment Share on other sites More sharing options...
jonsjava Posted April 18, 2008 Share Posted April 18, 2008 um..it would help if you described the problem for us. Quote Link to comment Share on other sites More sharing options...
haku Posted April 18, 2008 Share Posted April 18, 2008 And the answer to your question is... .... .... Quote Link to comment Share on other sites More sharing options...
mjgdunne Posted April 18, 2008 Author Share Posted April 18, 2008 Sorry just realised i left out the whole question part, ok this is the code i have put together for a forgot password if the user enters incorrect details - they are asked for email add and username these are checked in the database and if they exist an email containing all of their details username password etc is sent to the email address entered, my problem is its not working.... i am getting an error : Warning: mail() [function.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:\xampp\htdocs\forgotpassword.php on line 51 Any help would be great? Quote Link to comment Share on other sites More sharing options...
jonsjava Posted April 18, 2008 Share Posted April 18, 2008 xampp needs the mail server up and running. start up Mercury (packaged with xampp) to get it working. Quote Link to comment Share on other sites More sharing options...
mjgdunne Posted April 18, 2008 Author Share Posted April 18, 2008 I have tried this but when i start up mercury it just says no internet connection? Quote Link to comment Share on other sites More sharing options...
jonsjava Posted April 18, 2008 Share Posted April 18, 2008 Unfortunately, I'm good with PHP, not so much with Mercury mail. I just set it up, and fix the problems as I see them with that program. I think the problem is no longer PHP-based, but Mercury based. I reccomend you go to his website and get some help for setting it up. sorry again. Jon Quote Link to comment Share on other sites More sharing options...
haku Posted April 18, 2008 Share Posted April 18, 2008 Either that or upload your script to a live server and test it there. Quote Link to comment Share on other sites More sharing options...
mjgdunne Posted April 18, 2008 Author Share Posted April 18, 2008 Do you think i could integrate another mail server or do you think that would be too messy, and if its possible do you recommend any? Quote Link to comment Share on other sites More sharing options...
dev Posted April 18, 2008 Share Posted April 18, 2008 Upload to hosting, and you dont need to enter SMTP. Quote Link to comment Share on other sites More sharing options...
mjgdunne Posted April 20, 2008 Author Share Posted April 20, 2008 Thanks for all your replys, i got mercury working here is a link to where i got information on how to configure all the settings: http://www.zoe.vc/2008/mercury-mail-transport-system-fur-externe-mail-konfigurieren/?lan=english Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.