<?php

        include'session.php';
        include'connection.php';
        ob_start();
        $length = 32;
        $random_string="";
        while(strlen($random_string)<$length && $length > 0)
		{
                $randnum = mt_rand(0,61);
                $random_string .= ($randnum < 10) ?
                chr($randnum+48) : ($randnum < 97 ? 
                chr($randnum+55) : $randnum+122);
        }
		
         $random_string;
         
         $quUpdateToken = "UPDATE retailer SET ApiToken='$random_string' WHERE Userid='$userid'";
         if(mysqli_query($con,$quUpdateToken))
         {
             header('location:Generate_API_Token.php?STATUS=SUCCESS');
         }
         else
         {
             header('location:Generate_API_Token.php?STATUS=FAILED');
         }
    ob_end_flush();
?>