Undefined var in PHP script responsible to send user data to to phpMyAdmin Database

I was working with a signup page to whose code is given below, it was supposed to be a signup page in which a user will input his credential data and the data will be stored in phpMyAdmin database but, it seems to not work as I am getting an error undefined var $random_id. Which I am not able to fix.

Also, Chrome console is empty

Image of the error:

https://i.stack.imgur.com/g9RCB.png

signup.php code:

<?php
    session_start();
    include_once "config.php";
    $fname = mysqli_real_escape_string($conn, $_POST['fname']);
    $lname = mysqli_real_escape_string($conn, $_POST['lname']);
    $email = mysqli_real_escape_string($conn, $_POST['email']);
    $pswrd = mysqli_real_escape_string($conn, $_POST['pswrd']);

    if (!empty($fname) && !empty($lname) && !empty($email) && !empty($pswrd)) {
        // check if user email is valid or not
        if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
            // check is use email is already existing in database or not
            $sql = mysqli_query($conn, "SELECT email FROM user_data WHERE email = '{$email}'");
            if (mysqli_num_rows($sql) > 0) {    // if email already exists
                echo "$email - This email already exists!";
            }else {
                // check if user uploaded file or not 
                if (isset($_FILES['image'])) {   // if file is uploaded
                    $img_name = $_FILES['image']['name'];   // getting user uploaded img_name
                    $img_type = $_FILES['image']['type'];   // getting user uploaded img_type
                    $tmp_name = $_FILES['image']['tmp_name'];   // temp_name to save/mpve file in folder

                    // exploding image file and getting file extension (jpeg, jpg, png)
                    $img_explode = explode('.', $img_name);
                    $img_ext = end($img_explode);    // we get the file extension of user uploaded img_file

                    $extensions = ['png', 'jpeg', 'jpg'];   // common valid img_ext's stored in array
                    if (in_array($img_ext, $extensions) === true) { // if user uploaded img_ext in array
                        $time = time(); // will return current time...
                                        // using this time to rename user uploaded img_file 
                                        // to ensure img_file has a unique name
                        // moving user uploaded img to our folder 
                        $new_img_name = $time.$img_name;
                        
                        // if user uploaded img moves to our folder successfully                         
                        if (move_uploaded_file($tmp_name, "images/".$new_img_name)) {   
                            $status = "Online Now!";    // once user signed up status set to Online Now!
                            $random_id - rand(time(), 10000000);    // creating random_id for user
                            
                            // inserting data inside table (database)
                            $sql2 = mysqli_query($conn, "INSERT INTO user_data (unique_id, fname, lname, email, pswrd, img, status)
                                                 VALUES ({$random_id}, '{$fname}', '{$lname}', '{$email}', '{$pswrd}', '{$new_img_name}', '{$status}')");
                            if ($sql2) {    // if data inserted
                                $sql3 = mysqli_query($conn, "SELECT * FROM user_data WHERE email = '{$email}'");
                                if (mysqli_num_rows($sql3) > 0) {
                                    $row = mysqli_fetch_assoc($sql3);
                                    $_SESSION['unique_id'] = $row['unique_id']; // using this session used unique_id in other php files
                                    echo "success!";
                                }
                            }else {
                                echo "Something went wrong!";
                            }
                        }

                    }else {
                        echo "Please select an image file - jpeg, jpg, png!";
                    }

                }else {
                    echo "Please select your profile picture!";
                }
            }
        }else {
            echo "$email - This is not a valid email!";
        }
    }else {
        echo "All inputs are required!";
    }
?>

And signup.js code

const form = document.querySelector(".signup form"),
continueBtn = form.querySelector(".button input"),
errorText = form.querySelector(".error-txt");

form.onsubmit = (e)=> {
    e.preventDefault(); // preventing form from submitting
}

continueBtn.onclick = ()=> {
    // AJAX HERE
    let xhr = new XMLHttpRequest(); // creating XML object
    xhr.open("POST", "PHP/signup.php", true);
    xhr.onload = ()=> {
        if (xhr.readyState === XMLHttpRequest.DONE) {
            if (xhr.status === 200) {
                let data = xhr.response;
                if (data == "success") {
                    location.href = "users.php"
                }else {
                    errorText.textContent = data;
                    errorText.style.display = "block";
                }
            }
        }
    }
    // to send form data through AJAX to PHP
    let formData = new FormData(form);  // creating new formData object
    xhr.send(formData); // sending form data to PHP
}