Results 1 to 7 of 7

Thread: Day 17 - Include: Easy cut and paste for Programmers - Become PHP Expert in 30 days

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2003
    Posts
    3,040

    Default

    Nice. We can keep frequently used code in another file and include them as needed.
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

  2. #2
    Join Date
    Nov 2009
    Location
    kerala
    Posts
    19,076

    Default

    http://php.flashwebhost.com/sibichan..._password.html

    Yes, I got the mail with password

    I used 'require' in lost_password.php

    PHP Code:

    <?php
    require "includes/database.php";  
    if (isset(
    $_POST['email'])) {

        
    $email $_POST['email'];

    } else {

        die(
    'Please enter your email address');}
    // now we have $email variable.

    // $email can contain space if user enter white space..

    // So lets remove any white space char using trim() function.
    $email trim($email);
    // lets write an SQL statement to search our users table

    // to find the user having email address == $email
    $sql "select * from users where email='$email'";
    // In above line, we used single quotes between email, because it is a string.
    // Now time to execute the SQL statement.

    $result $mysqli->query($sql);
    // lets see how many records found in database

    // If num_rows is 0, no user found
    if ($result->num_rows == 0) {

        die(
    "User with email address <b>$email</b> not found");

    }
    // lets get the user record from MySQLi result
    $userInfo mysqli_fetch_assoc($result);
    // $userInfo is an associate array.

    // Lets print it.

    // Now you can see all information about the user, including password.
    $name $userInfo['name'];

    $password $userInfo['password'];

    mail($email,"Your password""Hello $name, your password is $password");

    echo 
    'The password has been sent to the e-mail address specified';

  3. #3
    Join Date
    Sep 2003
    Posts
    3,040

    Default

    Good, require is better, but used include as everyone understand the meaning of the word and is easy to relate to what it do - include code from other file.
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

Bookmarks

Posting Permissions

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