Steemtools Tutorial part-6 (Check current Recovery Account tool by PHP and STEEMJS)

in #utopian-io6 years ago

IMG_20190216_230142_624.JPG

Repository

https://github.com/nawab69/steemtools

What Will I Learn?

  • You will learn About steem account recovery
  • You will learn How to make php web tool
  • You will learn How to make a php site which show current recovery account
  • You will learn How to use API

Requirements

  • Knowledge on php, html, bootstrap, API
  • Php server
  • Bootstrap CDN
  • Steemjs API

Difficulty

  • Intermediate

Tutorial Content

Hello Steemians,

I am Nawab. Last week an accident happened to me. So I didn't write any tutorial one week. Now I want to continue my steemtools php tutorial series. In this ongoing series, I have taught you to make some useful tools based on steemit in php language.

Here is the previous series -

Now I will teach you creating steemit account recovery tools. This tool has five part.

  1. Check current recovery Account
  2. Change recovery Account
  3. Check recovery Request
  4. Request account Recovery
  5. Recover Account

Today, I will teach you the first part today.

I am sorry to say that I am not good in the English language. My native language is Bengali. I am trying to improve the English language. Though I am a programmer and software engineer, I am not good in the English language. And it is my weak point. Please forgive me if my tutorial has some grammatical errors

What is steem account recovery?

Every steem account has a recovery account. If any user forgets his password/ owner key, he/she can recover his account by recovery account.
For example, Every google account has an alternative email/phone number. If a user forget his password, he can recover his password by his alternative email/ phone number.
Steem account recovery is the same as google account recovery. By default, every steem account's recovery account is steem. You can change your recovery account so that you can recover your steem account anytime by using an alternative account.

Check current recovery account

Now I will teach you how to create a tool which will show recovery account of any steem account.
Its function is the same as " Check current withdraw Route " tool's function. I have already described it in part -2 of this series. So I will not explain all the codes. Because You already know about these functions.

First, create a file named checkrecovery.php in the main directory of your PHP website. Then open the file and follow the steps one by one.

Include Header : First include header and sidebar files. Write down this code;

<?php
include ('include/header.php');
include ('include/nav.php');
?>

Username Input Form : Create a simple form like bootstrap form. You can use any kind of bootstrap form.

<form action="" method="post" >

</form>

Add an input box and a submit box into the form. Write this code inside the <form>...</form> tag.

<div class="form-group">
  <div class="input-group mb-2 mr-sm-2"> 
      <div class="input-group-prepend">
          <div class="input-group-text">@</div>
      </div> 
      <input type="text" class="form-control" name="user" placeholder="Username">
   </div>
</div>

<div class="form-group">
   <button align="center" name="submit" class="btn btn-primary mb-2">Submit</button> </div>

Php Function : Finally write some php functions for run this tools.

  • Store username from Html Form.
<?php 
if($_POST)
{
$username = $_POST["user"];
  • Generate API address of SteemJS.
$url = "https://api.steemjs.com/get_accounts?names[]=$username";
  • Use CURL function to get account information in JSON from SteemJS.
//  Initiate curl
$ch = curl_init();
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL,$url);
// Execute
$result=curl_exec($ch);
// Closing
curl_close($ch);
  • Decode JSON to PHP strings
$info = json_decode($result,true);
  • Store php strings to variables.
$name = $info[0][name];
$to = $info[0][recovery_account];
?>
  • Display the Result
<div class="alert alert-success" role="alert"> <h4 class="alert-heading">Hi <?php echo $name; ?> </h4> <p>Your current recovery account is <b>@<?php
echo $to; ?> </b>
</p> <hr> <p class="mb-0">You can change your Recovery account from <a href="changerecovery">here</a> </p> </div>
<?php
}
?>

Then save the file.

Here is the full code .

<?php
/* Include header file */
include ('include/header.php');
/* Include navigation bar file */
include ('include/nav.php');
?>
<div class="container">
<br>
<br>
<center>
<div class="card"> <h5 class="card-header">Check Current Recovery Account</h5> <div class="card-body"> 
      <form action="" method="post" >
      <div class="form-group">
      <div class="input-group mb-2 mr-sm-2"> 
      <div class="input-group-prepend"> <div class="input-group-text">@</div> </div> 
      <input type="text" class="form-control" name="user" id="inlineFormInputGroupUsername2" placeholder="Username"> </div> </div>
<br>
<div class="form-group">
<button align="center" name="submit" class="btn btn-primary mb-2">Submit</button> 
</div>
</form>
</div> </div>
</center>
      
<?php 
if($_POST)
{
$username = $_POST["user"];
$url = "https://api.steemjs.com/get_accounts?names[]=$username";  //steemjs API
//  Initiate curl
$ch = curl_init();
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL,$url);
// Execute
$result=curl_exec($ch);
// Closing
curl_close($ch);
$info = json_decode($result,true);  //decode json
$name = $info[0][name];  //store username value
$to = $info[0][recovery_account];  //store recovery account value
?>
<div class="alert alert-success" role="alert"> <h4 class="alert-heading">Hi <?php echo $name; ?> </h4> <p>Your current recovery account is <b>@<?php
echo $to; ?> </b>
</p> <hr> <p class="mb-0">You can change your Recovery account from <a href="changerecovery">here</a> </p> </div>
<?php

}
?>
<br>
<br>
<p>
<hr>
</div>
<?php
include ('include/footer.php');
?>

You can also find it in steemtools GitHub repository.

Test the tool

Open the file in a browser. You will a form. Write your steemit username into the inputbox and click on submit button. You will get result.

Screenshot_20190216-230003.png

Screenshot_20190216-230025.png


Curriculum

Proof Of work done https://github.com/nawab69/steemtools

https://steemtools.cf/checkrecovery

Sort:  

Thank you for your contribution @nawab69.
After analyzing your tutorial we suggest the following points listed below:

  • In the next tutorial we suggest you just put the github link in the full code. You don't need to put the whole code at the end of your tutorial.

  • Please detail the explanation of your code.

  • Thanks for following some suggestions we gave in your previous tutorial. The structure of your tutorial has improved.

Looking forward to your upcoming tutorials.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

Thank you for your review, @portugalcoin! Keep up the good work!

Congratulations @nawab69! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You received more than 500 upvotes. Your next target is to reach 1000 upvotes.

Click here to view your Board
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

Valentine challenge - Love is in the air!

Support SteemitBoard's project! Vote for its witness and get one more award!

Hi @nawab69!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hey, @nawab69!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!