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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:08:59+00:00 2026-06-17T04:08:59+00:00

On my 000webhost website I had created this SQL file, named test.sql Here is

  • 0

On my 000webhost website I had created this SQL file, named test.sql

Here is it’s coding:

CREATE TABLE `members` (
`id` int(4) NOT NULL auto_increment,
`username` varchar(65) NOT NULL default '',
`password` varchar(65) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=2 ;
-- 
-- Dumping data for table `members`
--
INSERT INTO `members` VALUES (1, 'john', '1234');

And after that I created another php file named main_login.php

Here is coding:

<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="checklogin.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>Member Login </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="mypassword" type="text" id="mypassword"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>

After that I prepared another php file named checklogin.php

Here is coding:

$host="I INSERTED MY LOCAL HOST HERE"; // Host name 
$username="I INSERTED MY USERNAME HERE"; // Mysql username 
$password="I TYPED MY PASSWORD HERE"; // Mysql password 
$db_name="[B]I AM CONFUSED THAT WHICH DATABASE SHOULD I NAME HERE[/B]  :eek: "; // Database name 
$tbl_name="members"; // Table 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");

// 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 $tbl_name 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"
session_register("myusername");
session_register("mypassword"); 
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
?>

In checklogin.php, 4th line, I am confused that which database name should I provide. I tried to write test.sql as I had created a table with SQL file, but while logging in it’s showing error and login form is not able to fetch the SQL table data.I had already created a mySQL file in service provided by 000webhost.com and get MySQL username, MySQL database and host site (let username be SQL_user and site), but currently don’t know how to use MySQL. So which file should I name in $db_name above? And also want to know that how can I add data in MySQL in 000webhost.com so that login form can fetch the login info?

Thank You in advance…

  • 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-17T04:09:00+00:00Added an answer on June 17, 2026 at 4:09 am

    Above I had asked 2 Questions:

    Que 1. So which file should I name in $db_name above?

    Que 2. How can I add data in MySQL in 000webhost.com so that login form can fetch the login info?

    Here are answers:

    Ans 1. Here in the checklogin.php I had to write this:

    $host="INSERTED LOCAL HOST HERE"; // Host name 
    $username="INSERTED USERNAME HERE"; // Mysql username 
    $password="TYPED PASSWORD HERE"; // Mysql password 
    $db_name="HERE WE HAVE TO INSERT MYSQL DATABASE NAME"; // Database name 
    $tbl_name="members"; // Table name 
    

    Now in above at $db_name we will be your MySQL database name, and I will have to create another table at that database.

    Ans 2. After opening my site Control Panel at 000webhost I will have to go on phpMyAdmin and create a database first and after putting the username, password, local host etc., I will click on “Enter phpMyAdmin” at the right side of the table it will take us to another window and there we have to create the database and this database will be the place from where the login form will fetch data.

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

Sidebar

Related Questions

I have a website on free hosting - 000webhost.com and it allows you to
This is my first time building a website and using CodeIgniter for a school
This is my php code saved as db2.php <?php mysql_connect(mysql15.000webhost.com,a3189966_root,); mysql_select_db(a3189966_pd); $firstName = $_GET[firstName];
I have a PHP/MySQL website on 000webhost (http://www.boisvert.me.uk; but it's down for review at
I recently made a portfolio website and put it online on 000webhost.com . Today
I created a website using Code Ignitor and MySQL and want to upload everything
I have a INSERT operation in my website which works like this. On index.html
I was wondering if anyone had input as to why this statement isn't inserting
PLEASE CLOSE THIS I HAVE FIGURED OUT THE ------------MY PROBLEM---------------------------------------- mysql_select_db("members") or die(mysql_error()); echo
I have created 2 pages update.php edit.php We start on edit.php so here is

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.