Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8218487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:48:38+00:00 2026-06-07T12:48:38+00:00

I have written a PHP script that I use for authentication with e-mail and

  • 0

I have written a PHP script that I use for authentication with e-mail and password since e-mail is identified as unique.

I want to echo “true” as well as echo :: fname (First Name). how can I write it? Following is my PHP code.

include "db_config.php";

$email = $_POST['email'];
$password = $_POST['password'];

$sql = "select fname,e_mail,password from user where e_mail = '$email' and pwd = '$password'  ";

$result = mysql_query($sql);

if (mysql_num_rows($result) > 0){
    echo "true";
}
else{
    echo "Login Failed";
}

If you can suggest me some better way to write this code, please let me know.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:48:40+00:00Added an answer on June 7, 2026 at 12:48 pm

    Consider the comments about mysql_* and mysql_real_escape_string, but after you get your result, you echo it like this, adapted from the manual:

    $result = mysql_query($sql);
    if (!$result) {
        echo "Could not successfully run query ($sql) from DB: " . mysql_error();
        exit;
    }
    
    if (mysql_num_rows($result) == 0) {
        echo "No rows found, nothing to print so am exiting";
        exit;
    }
    
    $row = mysql_fetch_assoc($result); 
    echo "true" . $row['fname'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a PHP script that I would like to use on several
I have a written a script in PHP that reads from data from a
I have written a php e-mail processing client that uses the IMAP protocol. I
I have written a php script that generates a list of links that match
I have a script that I've written that I sell to others who want
I have written a script using my local PHP 5.3 installation making use of
I have written a php script that returns an arbitrary number of specific ids
I am trying to download some files. I have written a php script that
I have written a script image.php that is quite long, but I've just copied
I have written a very very very simple!! script in php. header redirection not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.