Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    May 2009
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Pls help with the code-recover password

    I have a password recover codes.When i execute it gives me following errors

    undefined index 'h' and
    undefined index 'email'


    Please help me with this coding

    the code is as follow

    <?php
    session_start(); if(isset($_COOKIE["usNick"]) && isset($_COOKIE["usPass"])){ ?>
    <META HTTP-EQUIV="REFRESH" CONTENT="0;URL=myaccount.php">
    <?php exit();
    }
    $geth = $_GET['h']; if($geth){ include('includes/config.inc.php');
    require('includes/passgenerator.inc.php');
    $string = rand_string();
    $mystring = sha1($string);
    $myDb->connect();
    $checkhash = mysql_query("SELECT hash FROM yob_recoverpass WHERE hash='$geth'");
    $hash_exist = mysql_num_rows($checkhash);
    $myDb->close();
    if ($hash_exist>0) {
    $myDb->connect();
    $query = mysql_query("SELECT email FROM yob_recoverpass WHERE hash = '$geth'") or die(mysql_error());
    $row = mysql_fetch_array($query); $myDb->close();
    $email=$row['email'];
    $myDb->connect();
    $querybt = "UPDATE yob_users SET password='$mystring' WHERE email='$email'";
    mysql_query($querybt) or die(mysql_error());
    $queryz = "DELETE FROM yob_recoverpass WHERE hash='$geth'";
    mysql_query($queryz) or die(mysql_error());
    $myDb->close();
    $to = $email;
    $subject = SITENAME." Password Recovery";
    $message = "Your New Password is: ".$string."";
    $from = SITENAME."@no-reply.com";
    $headers = "From: $from"; mail($to,$subject,$message,$headers);
    $display_error = "* Email Sent to ".$email."";
    include ('error.php'); exit();
    }
    }
    $display_error = ""; $username = "";
    if ($_POST['email']) { $email = $_POST['email'];
    if( strtolower($_POST['code'])!= strtolower($_SESSION['texto'])){ $display_error = "* Security Code Error";
    include ('error.php'); exit();
    }
    else{ include('includes/config.inc.php');
    $myDb->connect();
    $checkemail = mysql_query("SELECT email FROM yob_users WHERE email='$email'");
    $email_exist = mysql_num_rows($checkemail);
    $myDb->close();
    if ($email_exist>0) { require('includes/passgenerator.inc.php');
    $string = rand_string();
    $mystring = sha1($string);
    $myDb->connect();
    $query = "INSERT INTO yob_recoverpass (hash, email) VALUES('$mystring','$email')";
    mysql_query($query) or die(mysql_error());
    $myDb->close();
    $to = $email;
    $subject = SITENAME." Password Recovery";
    $message = "Please copy and paste the next URL: ".SITE_URL."recoverpass.php?h=".$mystring."";
    $from = SITENAME."@no-reply.com";
    $headers = "From: $from"; mail($to,$subject,$message,$headers);
    $display_error = "* Email Sent to ".$email."";
    include ('error.php'); exit();
    }
    else{ $display_error = "* The Email doesn't exist";
    include ('error.php'); exit();
    }
    }
    }
    else{ include ('header.php');
    ?>

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,849
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Change
    PHP Code:
    $geth $_GET['h']; if($geth){ include('includes/config.inc.php');
    require(
    'includes/passgenerator.inc.php'); 
    to
    PHP Code:
    if(isset($_GET['h'])){
    $geth $_GET['h'];
     include(
    'includes/config.inc.php');
    require(
    'includes/passgenerator.inc.php'); 
    and
    PHP Code:
    if ($_POST['email']) { $email $_POST['email']; 
    to
    PHP Code:
    if (isset($_POST['email'])) { $email $_POST['email']; 
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    May 2009
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    thanks,but facing a little error

    thanks,

    but when I excute the code with html.it gives me error like

    Parse error: syntax error, unexpected $end on line 84

    the whole code is given below

    please help

    <?php
    session_start(); if(isset($_COOKIE["usNick"]) && isset($_COOKIE["usPass"])){ ?>
    <META HTTP-EQUIV="REFRESH" CONTENT="0;URL=myaccount.php">
    <?php exit(); }
    if(isset($_GET['h'])){
    $geth = $_GET['h'];
    if($geth){ include('includes/config.inc.php');
    require('includes/passgenerator.inc.php');
    $string = rand_string();
    $mystring = sha1($string);
    $myDb->connect();
    $checkhash = mysql_query("SELECT hash FROM yob_recoverpass WHERE hash='$geth'"); $hash_exist = mysql_num_rows($checkhash);
    $myDb->close();
    if ($hash_exist>0) {
    $myDb->connect();
    $query = mysql_query("SELECT email FROM yob_recoverpass WHERE hash = '$geth'") or die(mysql_error());
    $row = mysql_fetch_array($query);
    $myDb->close();
    $email=$row['email'];
    $myDb->connect();
    $querybt = "UPDATE yob_users SET password='$mystring' WHERE email='$email'"; mysql_query($querybt) or die(mysql_error());
    $queryz = "DELETE FROM yob_recoverpass WHERE hash='$geth'";
    mysql_query($queryz) or die(mysql_error()); $myDb->close();
    $to = $email;
    $subject = SITENAME." Password Recovery"; $message = "Your New Password is: ".$string."";
    $from = SITENAME."@no-reply.com";
    $headers = "From: $from";
    mail($to,$subject,$message,$headers);
    $display_error = "* Email Sent to ".$email."";
    include ('error.php'); exit();
    }
    }
    $display_error = ""; $username = "";
    if (isset($_POST['email'])) {
    $email = $_POST['email'];
    if( strtolower($_POST['code'])!= strtolower($_SESSION['texto'])){ $display_error = "* Security Code Error";
    include ('error.php');
    exit();
    }
    else{ include('includes/config.inc.php');
    $myDb->connect();
    $checkemail = mysql_query("SELECT email FROM yob_users WHERE email='$email'"); $email_exist = mysql_num_rows($checkemail);
    $myDb->close();
    if ($email_exist>0) { require('includes/passgenerator.inc.php');
    $string = rand_string();
    $mystring = sha1($string);
    $myDb->connect();
    $query = "INSERT INTO yob_recoverpass (hash, email) VALUES('$mystring','$email')"; mysql_query($query) or die(mysql_error());
    $myDb->close();
    $to = $email;
    $subject = SITENAME." Password Recovery";
    $message = "Please copy and paste the next URL: ".SITE_URL."recoverpass.php?h=".$mystring."";
    $from = SITENAME."@no-reply.com";
    $headers = "From: $from";
    mail($to,$subject,$message,$headers);
    $display_error = "* Email Sent to ".$email."";
    include ('error.php');
    exit(); }else{ $display_error = "* The Email doesn't exist"; include ('error.php'); exit(); }
    }
    }
    else{ include ('header.php'); ?>
    <div id="content">
    <p class="error"><?php echo $display_error;?></p>
    <form action="recoverpass.php" method="post" class="f-wrap-1">
    <div class="req"><a href="signup.php">Not Registered?</a><br /><a href="recoverpass.php">Forgot your Password?</a></div>
    <fieldset>
    <h3>Recover your Password</h3>
    <label for="email"><b>Email:</b>
    <input id="email" name="email" type="text" class="f-name" autocomplete="off" tabindex="1" /><br />
    </label>
    <label for="code"><b>Security Code:</b>
    <input id="code" name="code" type="text" class="f-name" autocomplete="off" tabindex="3" /><br/>
    </label>
    <label for="code2"><b>&nbsp;</b>
    <img src="image.php?<?php echo $res; ?>"/><br />
    </label>
    <div class="f-submit-wrap">
    <input type="submit" value="Submit" class="f-submit" tabindex="4" /><br />
    </div>
    </fieldset>
    </form>

    <?php
    include ('footer.php'); } ?>

  • #4
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,292
    Thanks
    4
    Thanked 202 Times in 199 Posts
    You didn't close the last else. Change

    PHP Code:
    <?php
    include ('footer.php'); } ?>
    to
    PHP Code:
    <?php
    }
    include (
    'footer.php'); } ?>
    And please use [ php ] tags around your code when posting. See this sticky for more information.
    Last edited by djm0219; 05-11-2009 at 09:55 AM. Reason: Added link to sticky with how to wrap code in PHP tags
    Dave .... HostMonster for all of your hosting needs

  • #5
    New Coder
    Join Date
    May 2009
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    something went wrong
    your suggestion did not work

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,849
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Format your code with proper indents for your if-else blocks, there must be a missing } somewhere. Also please use [PHP][/PHP] tags to wrap your code while posting here.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Tags for this Thread

    Posting Permissions

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