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-MailerHP/" . 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
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
Already got it working, but thanks anyway. That's pretty much what I did. I feel proud for figuring that out for myself =D
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"]; } }