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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:49:24+00:00 2026-06-13T22:49:24+00:00

Hey can annyone view my code and explain? $error = array() doesnt store my

  • 0

Hey can annyone view my code and explain? $error = array() doesnt store my errors and
$error[] = ‘Wrong username or password!’; dont working. I need display my error at same page as i have login script.

  <?php


$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="2"; // Database name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
if (isset($_POST['formsubmitted'])) {
    $error = array();//Declare An Array to store any error message 
};  
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];

// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

$sql="SELECT * FROM `members` WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);

// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){

// Register $myusername, $mypassword and redirect to file "login_success.php"
//store data:
$_SESSION['$myusername'];
$_SESSION['$mypassword']; 
//next page:

header("location:login_success.php");
}
else {
 $error[] = 'Wrong username or password!';
};
?>

ty!
  • 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-13T22:49:24+00:00Added an answer on June 13, 2026 at 10:49 pm

    try this :

    <?php
    if(isset($error) && is_array($error))
    {
       echo "<div class='error'>" . implode("<br />", $error) . "</div>";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey, can anyone notice any errors in this code: <?php include(config.php); if(isSet($_POST['lastmsg'])) { $lastmsg
Hey i can't seem to understand this error. I'm trying to select an image
Hey, can anyone post a sample code demonstrating how can images (jpeg, png) be
Hey guys, can anyone explain me what (id)sender exactly means? I have seen it
Hey all, can anyone please explain how I can subclass UIButton and override some
Hey guys, I'm wondering if anyone can help me extend this bit of code-
Hey can anyone see what wrong with my menu in the while loop it
Hey i have an error in this: while((Status.health !0) && (Wolves.health !0) ) Can
Hey can anyone help me understand how to do an edit method for my
Hey can any one tell me should i need open a port for outgoing

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.