MLM(Multi Level Marketing) Website Using PHP - Binary Plan

Part 14(B) - Generate and Send Pin

Now we will create a form for send button because we need some data when admin will click on the send button. We will take three hidden fields as user id, amount, and the id of the pin request. 

After sending the all pin, need to change the status of the pin request to close

Great!!! Now admin can send the pin to a user. You can say we have done with a very first major part of the MLM website. In the next few chapters, it will become more interesting when you will be able to join a user to the MLM website and will view the tree. That is amazing.


$product_amount = 300;
//Clicked on send buton
	$userid = mysqli_real_escape_string($con,$_POST['userid']);
	$amount = mysqli_real_escape_string($con,$_POST['amount']);
	$id = mysqli_real_escape_string($con,$_POST['id']);
	$no_of_pin = $amount/$product_amount;
	//Insert pin
		$new_pin = pin_generate();
		mysqli_query($con,"insert into pin_list (`userid`,`pin`) values('$userid','$new_pin')");
	//updae pin request status
	mysqli_query($con,"update pin_request set status='close' where id='$id' limit 1");
	echo '<script>alert("Pin send successfully.");window.location.assign("view-pin-request.php");</script>';	

//Pin generate
function pin_generate(){
	global $con;
	$generated_pin = rand(100000,999999);
	$query = mysqli_query($con,"select * from pin_list where pin = '$generated_pin'");
		return $generated_pin;
<!DOCTYPE html>
<html lang="en">


    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Mlml Website  - View Pin Request</title>

    <!-- Bootstrap Core CSS -->
    <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link href="vendor/metisMenu/metisMenu.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="dist/css/sb-admin-2.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">




    <div id="wrapper">

        <!-- Navigation -->
        <?php include('php-includes/menu.php'); ?>

        <!-- Page Content -->
        <div id="page-wrapper">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <h1 class="page-header">Admin - View pin request</h1>
                    <!-- /.col-lg-12 -->
                <!-- /.row -->
                <div class="row">
                	<div class="col-lg-12">
                    	<div class="table-responsive">
                        	<table class="table table-striped table-bordered">
									$query = mysqli_query($con,"select * from pin_request where status='open'");
											$id = $row['id'];
											$email = $row['email'];
											$amount = $row['amount'];
											$date = $row['date'];
                                            	<td><?php echo $i; ?></td>
                                                <td><?php echo $email; ?></td>
                                                <td><?php echo $amount; ?></td>
                                                <td><?php echo $date; ?></td>
                                                <form method="post">
                                                	<input type="hidden" name="userid" value="<?php echo $email ?>">
                                                    <input type="hidden" name="amount" value="<?php echo $amount ?>">
                                                    <input type="hidden" name="id" value="<?php echo $id ?>">
                                                	<td><input type="submit" name="send" value="Send" class="btn btn-primary"></td>
                                        	<td colspan="6" align="center">You have no pin request.</td>
            <!-- /.container-fluid -->
        <!-- /#page-wrapper -->

    <!-- /#wrapper -->

    <!-- jQuery -->
    <script src="vendor/jquery/jquery.min.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="vendor/bootstrap/js/bootstrap.min.js"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script src="vendor/metisMenu/metisMenu.min.js"></script>

    <!-- Custom Theme JavaScript -->
    <script src="dist/js/sb-admin-2.js"></script>