<?php
	session_start();
	if($_SESSION['rid'])
	{
		$userid=$_SESSION['rid'];
	}
	else
	{
		header('location:../login.php');
	}
?>
<?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:api_documents.php');
         }
    ob_end_flush();
?>