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 1035403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:32:14+00:00 2026-05-16T14:32:14+00:00

Hi All Nightowls out there :), I need to authenticate username and password provided

  • 0

Hi All Nightowls out there :),

I need to authenticate username and password provided on a login page against my database table, named regdata. Upon successful authentication, the user is taken to /countdown_clock/countdown.html. When I run the page, I’m not taken to the specified countdown.html, but the same page refreshes with /authlogin.php tacked onto the end of the URL. Can someone suggest how to remedy the following code?

<?php
error_reporting(E_ALL); 
ini_set("display_errors", 1); 

$Database = array(
"Host" => 'myhost',
"User" => 'myuser',
"Password" => 'mypass',
"Name" => 'mydb'
);

$mysqli = new mysqli($Database['Host'], $Database['User'], $Database['Password'], $Database['Name']);


if ($mysqli->connect_error) 
{

?><span class="error">Connect Error (<?php echo $mysqli->connect_errno; ?>) <?php echo $mysqli->connect_error; ?></span><?php
exit();
}

$result = mysqli->prepare("SELECT username, password from regdata where username = $_POST['user_name'] and password = $_POST['password']");

if ($result && 0)
{
$result->execute();

$result->close();
header("Location: http://www.mydomain.com/countdown_clock/countdown.html"); 
}
else
{
$_SESSION['error'] = "Sorry, we cannot process your login at this time.  Please try back later.";

header("Location: http://www.mydomain.com/"); 
} 
?>

My login.php calls authlogin.php as follows:

<form id="form1" name="form1" method="post" action="authlogin.php">
 <input type="submit" class="form_login" alt="Login" value="" /></p></form>

Thanks,
Sid

EDIT: revised statement

$result = mysqli->prepare("SELECT username, password from regdata where username = '" . $_POST['email_address'] . "' and password = '" . $_POST['password']."'
");

Is this the proper way?

  • 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-05-16T14:32:14+00:00Added an answer on May 16, 2026 at 2:32 pm

    Well if the form is on the same page you’ll want to use:

    if (!empty($_POST)) {
      // code
    }
    

    Before executing the rest of your PHP.

    Also you could be getting an error but not have display_errors turned on in your PHP config.

    On top of that your query won’t work you haven’t but quotes around the field values nor have you properly escaped the input.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, If I've go the following database fields/values: user_id field_name field_value 1 EventHour1 1
All my files can be found on GitHub: https://github.com/Integralist/Passage (just in case you need
All, I am trying to create a table to receive user inputs (UGC). This
All I need is to create a file that contains a file names' list
All, I'm using Facebook Connect (JS SDK) to authenticate a user to my site.
All the recent VisualSVN Server posts made me want to check it out. I
All I have found about this is that there are inconsistencies among different web
all I want to calculate the height of the page ,and in my test.less
All my research shows that there's no real usage for the @private directive -
All - Need some insight into this issue. I have created a sample project

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.