Tag Archives: password

How to change your WordPress website’s password using phpMyAdmin

Here is the way that I use to change my WordPress site’s password if I am unable to log in or reset the password to the dashboard.

Log into phpMyAdmin.

Open your WordPress database.

Select the wp_users table and click Browse.

 

 

Now click Edit on the user whose password you want to change.

You will change the password in the row user_pass.

You will notice that WordPress stores the passwords as MD5 Hash rather than plain text.

This means that you will need to use an MD5 generators online to generate your password. I use JavaScript MD5. Simply type your password in the tool and generate MD5 results.

Copy and paste the code you get from the converter into the user_pass field and click Go to save the new password.

Let me know if you run into any issues or have any questions.

Password protect one section of a web page

Here is the code that you can use to password protect just one section of your web page.

First, open the web page in a text editor.

Next, copy and paste this code into the section that you want to password protect:

<?php  // Define your username and password  
$username = "someuser"; 
$password = "somepassword";  
if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) {  ?>
<h1>Login</h1>  
<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">     
<p><label for="txtUsername">Username:</label>     
<br /><input type="text" title="Enter your Username" name="txtUsername" /></p>    
<p><label for="txtpassword">Password:</label>    
<br /><input type="password" title="Enter your password" name="txtPassword" /></p>     
<p><input type="submit" name="Submit" value="Login" /></p>  
</form>  
<?php  }  else {  ?>  
<p>This is the protected page. Your private content goes here.</p> 
<?php  }  ?> 

Make sure to define the username and password you want to use.

Finally, save the page as a PHP page (this is important!) and upload it to your website.

Note: If you are trying to make the entire webpage password protected, please refer to my previous post which covers how to password protect a web page

Password protect a web page

Here is the code you can use to password protect a web page quickly and easily.

If the web page you wish to password protect is an HTML page, open it in a text editor and save it as a PHP page.

Copy and paste this code at the very top of the page you have open in a text editor:

<?php  // Define your username and password  
$username = "someuser"; 
$password = "somepassword";  
if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) {  ?>
<h1>Login</h1>  
<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">     
<p><label for="txtUsername">Username:</label>     
<br /><input type="text" title="Enter your Username" name="txtUsername" /></p>    
<p><label for="txtpassword">Password:</label>    
<br /><input type="password" title="Enter your password" name="txtPassword" /></p>     
<p><input type="submit" name="Submit" value="Login" /></p>  
</form>  
<?php  }  else {  ?>  
<p>This is the protected page. Your private content goes here.</p> 
<?php  }  ?> 

 

First, you will obviously need to define the username and password that you want to use to protect the page.

Next, replace the text that says “This is the protected page…” in the code you just added to your page with the content of the web page that you want to be password protected.

You can password protect just one particular part of your web page if you want to by copying and pasting the code above into wherever on your web page you want to password protect, as long as the web page is a php page. See this post for an example of a web page with only part of it’s content password protected.

Note: if you are trying to password protect just one section of your web page, please refer to my next post on how to password protect part of a web page.