Data not inserting to table

Asked by At

im trying to insert data to a table from another table. but its just one that is inserting (employeeid). its missing the (firstname and lastname) im making a attendance table here. i can give my codes to anyone can help. what should I do? im new to codings in general. and im trying to get this thing right.

<?php
session_start();
error_reporting(0);
include 'config.php';
if(isset($_POST['employeeid'])) {
    $employeeid=$_POST['employeeid']; 
    $ret=mysqli_query($con,"SELECT * FROM tbluser WHERE employeeid='$employeeid'");
    $num=mysqli_fetch_array($ret);
    if($num>0){
        $_SESSION['employeeid']=$employeeid; 
        $uip=$_SERVER['REMOTE_ADDR'];
        $action="Login";
        $sql=mysqli_query($con,"INSERT INTO attendance (employeeid, firstname, lastname, userIp, action) VALUES ('$employeeid', '$firstname', '$lastname', '$uip', '$action')");
        $extra="dash.php";
        $host=$_SERVER['HTTP_HOST'];
        $uri=rtrim(dirname($_SERVER['PHP_SELF']),'/\\');
        header("location:http://$host$uri/$extra");
        exit();
    }
    else
    {
        echo "<script>alert('Username or password is incorrect!')</script>";
        echo "<script>window.open('index.php','_self')</script>";     
    }
}
?>

here is my html form

<html>
<head>
  <meta charset="UTF-8">
  <title></title>
    <link rel="stylesheet" href="style.css" media="screen" type="text/css" />
<br><br><br><br><br><br><br><br><br><br><br><br><center><h1><b>WELCOME BRUH!‍</b></h1></center>
</head>
<body>
    <script>
    function clock() {
var time = new Date(),

    hours = time.getHours(),

    minutes = time.getMinutes(),

    seconds = time.getSeconds();

document.querySelectorAll('.clock')[0].innerHTML = harold(hours) + ":" + harold(minutes) + ":" + harold(seconds);

  function harold(standIn) {
    if (standIn < 10) {
      standIn = '0' + standIn
    }
    return standIn;
  }
}
setInterval(clock, 1000);
    </script>
    <div class="clock" style="font-family: 'Digital-7 Italic','Share Tech Mono', monospace; 
    font-size: 50px; color: #000000; 
    text-shadow: 0 0 20px rgba(255, 255, 255);  0 0 20px rgba(10, 175, 230, 0); 
    position: absolute;
    top: 200px;
    left: 685px;">
    </div>
        <div class="container">
        <div id="login">
            <fieldset class="clearfix">
            <form action="loginprocess.php" name="login" method="POST">

            <p><span class="fontawesome-barcode"></span><input type="text"  placeholder="EmployeeID" name="employeeid" required></p>
            <p><input name="submit" type="submit" value="Sign In"></p>

            </form>
            </fieldset>
                    <form>
                    <a href="admin.php">
                    <input type="submit2" value="ADMIN"/>
                    </a>
                    </form>                  
        </div>
        </div>
        </body>
        </html>

0 Answers