title: how to generate OTP and send the password to mobile via sms
body: <p>I am doing a project of using OTP for the login of the websites, I have created a button named "Generate" once clicked it will create an OTP and send an SMS via HTTP gateway, then it stores the password in the database.</p>
  
  <p><strong>My code to create an OTP and save in DB:</strong></p>
  
  <pre><code>if(isset($_POST['generate']))
  {
      $string = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
      $string_shuffled = str_shuffle($string);
      $password = substr($string_shuffled, 1, 7);
  
      $password = base64_encode($password);
      $query = mysql_query("UPDATE user_login SET password='".$password."' WHERE username = 'ajai sandy' ");
      $qry_run = mysql_query($query);
  }
  </code></pre>
  
  <p><strong>Now I need to place this code of SMS API:</strong></p>
  
  <pre><code>http://login.smsgatewayhub.com/smsapi/pushsms.aspx?user=abc&amp;pwd=xyz&amp;to=919898123 456&amp;sid=senderid&amp;msg=test%20message&amp;fl=0 
  </code></pre>
  
  <p>The thing is the 5th line of code generates the OTP, then I need to place my SMS API after this so that it could send the password to the mobile, then it should encrypt the password which is on the 6th line and then saves in the database.</p>
  
  <p>Am not sure how to perform this action in sequence and don't know where to place the code </p>