Jump to content

Hampe

Members
  • Posts

    34
  • Joined

  • Last visited

Profile Information

  • Gender
    Male
  • Location
    Sweden

Hampe's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Sorry, I got the mail now. Delay... But the change password still dont work
  2. This is the code right know: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php if(!isset($_GET['email'])){ // no get variable - display the form echo'<form action=""> Email: <input type="text" name="email" /> <input type="submit" value="Ändra lösenord" /> </form>'; exit(); } // the form has been submitted $email=$_GET['email']; include("settings.php"); connect(); $q=sprintf("SELECT email2 from hm_accounts where accountaddress='%s'", mysql_real_escape_string($email) ); $r=mysql_query($q); $n=mysql_num_rows($r); if($n==0) { echo "Emailadressen finns inte <br /> <button onclick='javascript:history.go(-1)'>Gå tillbaka</button>"; die(); } list($email2) = mysql_fetch_array($r); $token=getRandomString(20); $q="INSERT into tokens (token,email) values ('$token','$email2')"; mysql_query($q); mailresetlink($email2,$token); function getRandomString($length) { $validCharacters = "ABCDEFGHIJKLMNPQRSTUXYVWZabcdefghijklmnopqrstuvwxyz123456789"; $validCharNumber = strlen($validCharacters); $result = ""; for ($i = 0; $i < $length; $i++) { $index = mt_rand(0, $validCharNumber - 1); $result .= $validCharacters[$index]; } return $result; } function mailresetlink($to,$token){ $subject = "Glömt lösenord - Website"; $uri = 'http://'. $_SERVER['HTTP_HOST'] ; $message = ' <html> <head> <title>Glömt lösenord - Website</title> </head> <body> <p>Klicka på länken för att ändra ditt lösenord, <a href="'.$uri.'/test/reset.php?token='.$token.'">LÄNK</a></p> </body> </html> '; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $headers .= 'From: NiceMail<noreply@domain.se>' . "\r\n"; $headers .= 'Cc: Admin@example.com' . "\r\n"; if(mail($to,$subject,$message,$headers)){ echo "Mailet med länken för att ändra ditt lösenord är skickat till <b>".$to."</b>"; } } ?> It finds the emailaddress, and insert a token, which is good. But I dont get any mail with the link. And even if I take the token from the database and type it in browser and change my password, I can´t login.. Something just dont want to work in some way.. I think of something.. Shouldn´t this line: $q="INSERT into tokens (token,email) values ('$token','$email2')"; be: $q="INSERT into tokens (token,email) values ('$token','$email')"; ? Because $email2 contains the mailaddress where the mail will be sent, and $email is the mailaddress that will be changed. Or am I wrong?
  3. It didn´t go so well... I´m out of ideas, and my English failed for a bit.. mac_gyver: Thank you! I´m sure you did tell me exactly how to do, but as I said... My English failed for a bit. So, any tips or helping hands would be very good! // Hampe
  4. Uhmm. I think I know what you mean, but I´m not really sure.. (My English isn´t that good) I will try to do what I think you are telling me.. // Hampe
  5. Well, still not working.. Here is the code, with the changes: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php //fil namn: forgotpassword.php //Titel: Glömt lösenord if(!isset($_GET['email'])){ echo'<form action=""> Email: <input type="text" name="email" /> <input type="submit" value="Ändra lösenord" /> </form>'; exit(); } $email=$_GET['email']; include("settings.php"); connect(); //$q="SELECT accountaddress from hm_accounts where accountaddress='".$email."'"; $q="SELECT * from hm_accounts where accountaddress='".$email."' and email2='".$email2."'"; $r=mysql_query($q); $n=mysql_num_rows($r); if($n==0){echo "Emailadressen finns inte <br /> <button onclick='javascript:history.go(-1)'>Gå tillbaka</button>";die();} $token=getRandomString(20); $q="INSERT into tokens (token,email) values ('".$token."','".$email."')"; mysql_query($q); function getRandomString($length) { $validCharacters = "ABCDEFGHIJKLMNPQRSTUXYVWZabcdefghijklmnopqrstuvwxyz123456789"; $validCharNumber = strlen($validCharacters); $result = ""; for ($i = 0; $i < $length; $i++) { $index = mt_rand(0, $validCharNumber - 1); $result .= $validCharacters[$index]; } return $result;} function mailresetlink($to,$token){ $subject = "Glömt lösenord - NiceMail"; $uri = 'http://'. $_SERVER['HTTP_HOST'] ; $message = ' <html> <head> <title>Glömt lösenord - NiceMail</title> </head> <body> <p>Klicka på länken för att ändra ditt lösenord, <a href="'.$uri.'/test/reset.php?token='.$token.'">LÄNK</a></p> </body> </html> '; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $headers .= 'From: NiceMail<noreply@domain.se>' . "\r\n"; $headers .= 'Cc: Admin@example.com' . "\r\n"; if(mail($email2,$subject,$message,$headers)){ echo "Mailet med länken för att ändra ditt lösenord är skickat till <b>".$email2."</b>"; }} if(isset($_GET['email']))mailresetlink($email,$token); ?>
  6. You mean like this? if(isset($_GET['email']))mailresetlink($email2,$token);
  7. It is the script to create the mailaccount. I just showed you the form setup so you could see the input names.. mail.php doesn´t have anything to do with the Forgot Password function
  8. If I use $to instead of $email2, I can echo it. But then I echo the email address that I want to recover, which is wrong
  9. If the "if mail" is: if(mail($to,$subject,$message,$headers)) I can send a mail. But if I use "$to", the mail will be sent to the "created" email address. The mail should be sent to the "private" email address to recover the "created". (I hope you understand) And yes, I am able to use the mail function, IF I use: $q="SELECT accountaddress from hm_accounts where accountaddress='".$email."'"; Instead of: $q="SELECT * from hm_accounts where accountaddress='".$email."' and email2='".$email2."'"; And if(mail($to,$subject,$message,$headers)) Instead of: if(mail($email2,$subject,$message,$headers))
  10. Hi guys! I have a Forgot Password script that works, but not with the new codelines.. My create script: <b>NOTERA:</b> Fälten märkta med <span style="color:red">*</span> måste fyllas i <br /><br /> <form action="mail.php" method="POST" id="mailSetupForm" name="mailform"> <table style="font-size:14px;color:#535353;"> <tr><td><b>Ditt namn:</b></td><td><input type="text" name="name" size="10"> </td></tr> <tr><td><b>E-Mail: <span style="color:red">*</span></b></td><td><input type="text" name="user" id="user" size="10"><b> @ <select name="domain" id="domain"> <option id="1" value="domain.se">domain.se</option></select></b> </td></tr> <tr><td><b>Din privata E-Mail: <span style="color:red">*</span></b></td><td><input type="text" name="email2" id="email2" size="10"> <i>För återställning av lösenord</i></td></tr> <tr><td><b>Lösenord: <span style="color:red">*</span></b></td><td><input type="password" name="pass1" size="10"> <i>Välj ett säkert lösenord. Använd gärna både tecken och bokstäver</i></td></tr> <tr><td><b>Lösenord igen: <span style="color:red">*</span></b></td><td><input type="password" name="pass2" size="10"> <i>(Bekräftelse)</i></td></tr> <tr><td><b>Kod:</b></td><td><input type="text" name="kod" size="10" value="<?php echo $a ?>" readonly="readonly"> <i>Spara koden! Används när du requestar nytt lösenord</i></td></tr> <tr><td> <div align="left"><input type="submit" name="submit" id="button" value="Skapa"></div></td></tr></table> </fieldset> </form> The Forgot Pass form looks like this: <form action=""> Email: <input type="text" name="email" /> <input type="submit" value="Ändra lösenord" /> </form> Forgot Pass Script: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php if(!isset($_GET['email'])){ echo'<form action=""> Email: <input type="text" name="email" /> <input type="submit" value="Ändra lösenord" /> </form>'; exit(); } $email=$_GET['email']; include("settings.php"); connect(); //$q="SELECT accountaddress from hm_accounts where accountaddress='".$email."'"; $q="SELECT * from hm_accounts where accountaddress='".$email."' and email2='".$email2."'"; $r=mysql_query($q); $n=mysql_num_rows($r); if($n==0){echo "Emailadressen finns inte <br /> <button onclick='javascript:history.go(-1)'>Gå tillbaka</button>";die();} $token=getRandomString(20); $q="INSERT into tokens (token,email) values ('".$token."','".$email."')"; mysql_query($q); function getRandomString($length) { $validCharacters = "ABCDEFGHIJKLMNPQRSTUXYVWZabcdefghijklmnopqrstuvwxyz123456789"; $validCharNumber = strlen($validCharacters); $result = ""; for ($i = 0; $i < $length; $i++) { $index = mt_rand(0, $validCharNumber - 1); $result .= $validCharacters[$index]; } return $result;} function mailresetlink($to,$token){ $subject = "Glömt lösenord - Website"; $uri = 'http://'. $_SERVER['HTTP_HOST'] ; $message = ' <html> <head> <title>Glömt lösenord - Website</title> </head> <body> <p>Klicka på länken för att ändra ditt lösenord, <a href="'.$uri.'/test/reset.php?token='.$token.'">LÄNK</a></p> </body> </html> '; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $headers .= 'From: NiceMail<noreply@domain.se>' . "\r\n"; $headers .= 'Cc: Admin@example.com' . "\r\n"; if(mail($email2,$subject,$message,$headers)){ echo "Mailet med länken för att ändra ditt lösenord är skickat till <b>".$email2."</b>"; }} if(isset($_GET['email']))mailresetlink($email,$token); ?> Now, then a user want to request a new password, they type in the "new" emailaddress. From that table it should get their private email (email2) and send the mail there, but it wont... Do you guys have any idea? PS: If the info is bad, just name it and I will try to tell you the problem better.. // Hampe
  11. That´s odd, because I´ve been using it, before I made my own reg script
  12. joshua0000 The script works without any problems. 4 easy steps: 1. Download it 2. Upload it to your webserver 3. Upload the sql_dump.txt to your database 4. Edit the "config.php" with your databaselogin Now you are up and running! // Hampus
  13. The error messages are shown on the same way like when a account is created, via "Modal" echo <<<HTML <div id="modal"> <div id="heading"> Error! </div> <div id="boxcontent"> <p>You did not fill in both passwords</p> <a href="#" class="button red close"><img src="../popup/images/cross.png">Close</a> </div> </div> HTML;
  14. Clear the form, but only when the account is successfully created, and not when it's an error message
  15. Well, it does clear the form, but I just want it to be cleared if the account is successfully created. I also use the Popupbox for the error messeges, but it should now clear the form if an error messege pop up
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.