A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: forgot password email only code tweak help

  1. #1
    Senior Member
    Join Date
    Oct 2000
    Location
    Kansas City MO
    Posts
    231

    forgot password email only code tweak help

    I have a working flash and php script combo that works in sending user and password info via requests for forgotton passwords.

    I did not build it and my skill is limited. I only want the user to submit thier email and then the script sends user the password to thier email. or send both user and a password as is now...but the only requirment is email.

    Currently user has to submit user both user name and email... I only want email reqirment. Can someone look at the code and help me out a bit? FLASH AND PHP CODE BELOW.

    php is:
    -------------------------------
    <?php
    include("conn.php");

    $success = 1;

    $username = $HTTP_POST_VARS['username'];
    $email = $HTTP_POST_VARS['email'];

    $sql = "SELECT vchPassWord FROM tUser WHERE vchUserName = '".$username."' AND vchEmail = '".$email."'";

    $rs = mysql_query($sql, $conn) or die(mysql_error());
    $row = mysql_fetch_assoc($rs);

    if(!$row){
    //The user dont exists
    $success = 0;
    $msg = 'The user doesn´t exists or the username and e-mail don´t match.';
    echo '&success='.$success.'&msg='.$msg.'&';
    } else {
    //The user exists
    $password = $row["vchPassWord"];

    $subject = "Your MyCompany.com user information";
    $message = "Here is your user information for MyCompany.com:\r\n\r\n";
    $message .= "Username: ".$username."\r\n";
    $message .= "Password: ".$password."\r\n";
    $message .= "E-mail: ".$email."\r\n\r\n";
    $message .= "Log on to: http://www.mycompany\r\n";
    $footer = "From: MyCompany.com";

    $formsent = mail($email, $subject, $message, $footer);

    if($formsent == 1) {
    $msg = "Thank you, your password has been sent to ".$email;
    } else {
    $success = 0;
    $msg = "We are sorry, but your password could not be sent to ".$email;
    }
    echo '&success='.$success.'&msg='.$msg.'&';
    }

    mysql_close($conn);

    ?>
    -------------------------------------------------------

    flash is:
    ----------------------------------------------------------
    Selection.setFocus(inpUserName);
    this.inpUserName.tabIndex = 0;
    this.inpEmail.tabIndex = 1;

    this.btnSubmit.onRelease = function(){
    this._parent.submit();
    }

    this.btnClose.onRelease = function(){
    gRoot.loadContent("home.swf", null, false);
    }

    function submit(){
    if(this.inpUserName.text != "" && this.inpEmail.text != ""){
    if(gRoot.checkEmail(this.inpEmail.text)){
    this.txtResponse.text = "Sending message...";
    var tVars = new LoadVars();
    tVars.owner = this;
    tVars.username = this.inpUserName.text;
    tVars.email = this.inpEmail.text;
    tVars.onLoad = function(){
    this.owner.txtResponse.text = this.msg;
    }
    tVars.sendAndLoad(gSystemPath + "forgot_password.php", tVars, "POST");
    } else {
    this.txtResponse.text = "Please enter a valid email address.";
    }
    } else {
    this.txtResponse.text = "Please fill in all fields and try again.";
    }
    }

    stop();

    -------------------------------------


    Any help would be greatly appreciated.

    Thank you

    m.
    ChickenSoupforTheFlasher

  2. #2
    Member
    Join Date
    Jun 2006
    Posts
    43
    just rip out the username.

  3. #3
    Senior Member
    Join Date
    Oct 2000
    Location
    Kansas City MO
    Posts
    231
    Quote Originally Posted by dnsi
    just rip out the username.
    In flash or php?
    If in flash an error occures or actually it will check to see if you put it in. If not it will not submit until you do.

    Not for sure how to "rip it out" of php. With making a mess of things.

    I appreciate the thought though. Unless im missing something you said that really is the key.
    ChickenSoupforTheFlasher

  4. #4
    Senior Member
    Join Date
    Oct 2000
    Location
    Kansas City MO
    Posts
    231

    anything else?

    Anything more specific? Anybody... i just want to elimanate the need for user and just requrie email with the scripts i posted.

    An advanced thank you to anyone that can help!!!
    ChickenSoupforTheFlasher

  5. #5
    Senior Member
    Join Date
    Apr 2005
    Location
    FL, USA
    Posts
    442
    If e-mail was the only requirement, then how would the script know which password to send? It needs to use the username as a filter (WHERE) in the SQL query here:
    Code:
    $sql = "SELECT vchPassWord FROM tUser WHERE vchUserName = '".$username."' AND vchEmail = '".$email."'";
    But if you really want to send login info (un, pw, or both) to an e-mail without any authentication (not recommended), it is possible to do this:
    Code:
    $sql = "SELECT vchPassWord,vchUserName FROM tUser WHERE vchEmail = '".$email."'";
    ...and....
    Code:
    //The user exists
    $password = $row["vchPassWord"];
    $username = $row["vchUserName"];

  6. #6
    Senior Member
    Join Date
    Oct 2000
    Location
    Kansas City MO
    Posts
    231

    Thanks

    Thanks Bob! I have it going now...
    ChickenSoupforTheFlasher

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center