Why can't I retrieve this data from the database?

Discussion in 'PHP' started by Airwalk Enterprise, Inc, Mar 28, 2011.

  1. #1
    So I'm creating a 'forgot username' feature, and I can't retrieve the name from the database. I can get the email, and the email sends successfully, it just won't display the users login name in the email? Just a blank space.

    login form:

    <form id="muform" method="post" action="http://www.airwalk-design.com/community/login/missing-username/confirm/">
    <input type="text" autocomplete="on" class="required email" minlength="6" maxlength="64" id="email" name="email"/>
    Email<br/>
    <input class="submit" type="submit" value="Email My Password"/>
    </form>

    confirmpage:

    <?php

    include($_SERVER["DOCUMENT_ROOT"]."/community/database.php");

    // input data into database

    $name = mysql_real_escape_string($_POST['name']);
    $email = mysql_real_escape_string($_POST['email']);

    $check = mysql_query("SELECT name FROM community WHERE email='$email'");

    $name_exist = mysql_num_rows($check);

    if($name_exist > 0) {

    $subject = "Login Info For Airwalk Design";
    $message = "Dear $name, here is your login name to log in to airwalk-design.com. Don't forgot it again!

    Name: $name

    Regards,


    Danny @ Airwalk

    Airwalk: http://www.airwalk-design.com/
    Facebook: http://www.facebook.com/airwalkdesign/
    Twitter: http://www.twitter.com/airwalk_design
    Myspace: http://www.myspace.com/airwalk-design/
    DeviantArt: http://airwalkdesign.deviantart.com/";

    mail($email, $subject, $message, "From: Airwalk Design <no-reply@airwalk-design.com>\nX-Mailer:pHP/" . phpversion());

    header('Location: http://www.airwalk-design.com/community/login/');

    }

    else {

    include($_SERVER["DOCUMENT_ROOT"]."/community/dontmove-head.php");
    echo "<div class=\"blink\">Sorry man, I didn't recognise that email address - I don't think it's in our database. Please double-check it and try again.</div>";
    include($_SERVER["DOCUMENT_ROOT"]."/community/missing-username.php");
    include($_SERVER["DOCUMENT_ROOT"]."/community/dontmove-foot.php");


    }

    ?>

    Thanks in advance :)
     
    Airwalk Enterprise, Inc, Mar 28, 2011 IP
  2. WoRLDLiFE

    WoRLDLiFE Peon

    Messages:
    116
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    login form:

    <form id="muform" method="post" action="http://www.airwalk-design.com/community/login/missing-username/confirm/">
    <input type="text" autocomplete="on" class="required email" minlength="6" maxlength="64" id="email" name="email"/>
    Email<br/>
    <input class="submit" type="submit" value="Email My Password"/>
    </form>

    confirmpage:
    
    <?php
    
    include($_SERVER["DOCUMENT_ROOT"]."/community/database.php");
    
    // input data into database
    
    
    $email = mysql_real_escape_string($_POST['email']);
    
    $check = mysql_query("SELECT name FROM community WHERE email='$email'"); 
    
    $name_exist = mysql_num_rows($check);
    
    if($name_exist > 0) {
    $get= mysql_fetch_assoc($check);
    $name = $get['name'];
    $subject = "Login Info For Airwalk Design";
    $message = "Dear $name, here is your login name to log in to airwalk-design.com. Don't forgot it again!
    
    Name: $name
        
    Regards,
    
    	
    Danny @ Airwalk
    
    Airwalk: [url]http://www.airwalk-design.com/[/url]
    Facebook: [url]http://www.facebook.com/airwalkdesign/[/url]
    Twitter: [url]http://www.twitter.com/airwalk_design[/url]
    Myspace: [url]http://www.myspace.com/airwalk-design/[/url]
    DeviantArt: http://airwalkdesign.deviantart.com/";
        
    mail($email, $subject, $message, "From: Airwalk Design <no-reply@airwalk-design.com>\nX-Mailer:PHP/" . phpversion()); 
    
    header('Location: [url]http://www.airwalk-design.com/community/login/');[/url]
    
    }
    
    else {
    
    	include($_SERVER["DOCUMENT_ROOT"]."/community/dontmove-head.php");
    	echo "<div class=\"blink\">Sorry man, I didn't recognise that email address - I don't think it's in our database. Please double-check it and try again.</div>";
    	include($_SERVER["DOCUMENT_ROOT"]."/community/missing-username.php");
    	include($_SERVER["DOCUMENT_ROOT"]."/community/dontmove-foot.php");
    
    	
    }
    
    ?>
    
    Code (markup):
    Try this :) hope it will work
     
    WoRLDLiFE, Mar 28, 2011 IP
  3. Airwalk Enterprise, Inc

    Airwalk Enterprise, Inc Peon

    Messages:
    126
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Already got it working, but thanks anyway. That's pretty much what I did. I feel proud for figuring that out for myself =D
     
    Airwalk Enterprise, Inc, Mar 28, 2011 IP
  4. theofficialSJ

    theofficialSJ Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    What was the issue. Let us know so that it will be of great help for us
     
    theofficialSJ, Mar 28, 2011 IP
  5. srisen2

    srisen2 Peon

    Messages:
    359
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    try this

    mysql_connect("$host", "$username", "$password")or die("cannot connect");
    mysql_select_db("$db_name")or die("cannot select DB");

    $query = "SELECT * FROM account WHERE userid = '$userid'";


    $result = mysql_query($query);
    if ($result) {
    while($row=mysql_fetch_array($result))
    {
    $profileusername = $row["username"];

    }
    }
     
    srisen2, Mar 28, 2011 IP