SELECT command is not working in cpanel php script - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Saturday, November 20, 2021

SELECT command is not working in cpanel php script

I am trying to run the below code. But the sql select command line is not working in cpanel. Though it is working on my local xampp. I have given all privileges to user, all file permissions set to 0644, all directory permission set to 0755(including public_html). The database is connected as I am not facing errors there. Only from the select command line is not working. Can anyone please help. Thanks in advance

<?php
    session_start();

    require 'th_config.php';
    if(isset($_POST['submitSSS'])) {
        $uname = $_POST['uname'];
        $pword = $_POST['pword'];
        echo $uname;
        echo $pword;
        $query = $con->prepare("SELECT count(*) as total FROM credentials WHERE Status = 'Closed'");
        $query -> execute();
        $results = $query->get_result();
        $rows = $results->fetch_assoc();
        echo $rows['total'];
        if ($rows['total']>0){
            echo '<div class="alert alert-info alert-dismissible mt-4 fade show">
                    <strong>Some user is already logged in!</strong>
                </div>';
        }
        else {
            if(empty($uname) || empty($pword)){
                echo '<div class="alert alert-info alert-dismissible mt-4 fade show">
                        <strong>Username or Password not entered!</strong>
                    </div>';
            }else{
                $query1 = $con->prepare("SELECT * FROM credentials WHERE uname=?");
                $query1->bind_param("s",$uname);
                $query1 -> execute();
                $result = $query1->get_result();
                $row = $result->fetch_assoc();
                $_SESSION['Status'] = $row['Status'];
                $_SESSION['uname'] = $uname;
                $_SESSION['Agent'] =  $row['Name'];
                $_SESSION['permission'] =  $row['permission'];
                if (isset($_SESSION['Status'])) {
                    if ($_SESSION['Status']=="Open"){
                        if ($uname == $row['uname'] && $pword==$row['pass']) {
                                            
                            $stmt = $con->prepare("UPDATE credentials SET Status = 'Closed' WHERE uname=?");
                            $stmt->bind_param("s", $uname);
                            $stmt->execute();
                            
                            header('location: th_create_invoice.php');
                            
                        } else {
                            echo '<div class="alert alert-danger alert-dismissible mt-4 fade show">
                            <strong>Wrong Username or Password</strong>
                            </div>';
                        }

                    } else {
                        echo '<div class="alert alert-danger alert-dismissible mt-4 fade show">
                        <strong>Already Logged in. Wait 5 mins</strong>
                        </div>';
                    }
                        
                } else {
                    echo '<div class="alert alert-danger alert-dismissible mt-4 fade show">
                    <strong>Wrong Username or Password</strong>
                    </div>';
                }

            }
        }
    }
?>
<!DOCTYPE html>
<html>
    <head>
        <title>Login Page</title>
        <link rel="stylesheet" href="css/main-style.css"></link>
        <meta name="viewport" content="width=device-width, user-scalable= 0, initial-scale=1">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <!--Font Awesome Link-->
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-2/css/all.min.css" integrity="sha256-46r060N2LrChLLb5zowXQ72/iKKNiw/lAmygmHExk/o=" crossorigin="anonymous" />
        <!-- Bootstrap Link -->
        <link rel="stylesheet" href="css/bootstrap-4.6.0/css/bootstrap.min.css">
        <link rel="shortcut icon" type="image/png" href="image/logo.png">
    </head>
    <body class="userlogin_back">
        <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="POST" id="login" class="form-submit login-form">
        <?php
            if(isset($_GET['value'])){
                if($_GET['value'] == 1){
                    echo '
                        <head>
                            <link rel="shortcut icon" type="image/png" href="image/img.png">
                        </head>
                        <div class="login-form__logo-container">
                            <img class="login-form__logo" src="image/deyhardware.png" alt="Logo" width="100%">
                        </div>
                    ';
                } else{
                    echo '
                        <div class="login-form__logo-container">
                            <img class="login-form__logo" src="image/tiles.png" alt="Logo" width="100%">
                        </div>
                    ';
                }
            }
            
        ?>
        <div class="login-form__content">
            <div class="login-form__header">Login to your account</div>
            <input class="login-form__input" type="text" name="uname" placeholder="Username">
            <input class="login-form__input" type="password" name="pword" placeholder="Password">
            <input type="submit" value="Login" class="login-form__button" name="submitSSS" id="myBtn">
            <div class="login-form__links">
                <a class="login-form__link" href="#">Unlock your Account!</a>
            </div>
        </div>
    </form>
    </body>
</html>


source https://stackoverflow.com/questions/70039283/select-command-is-not-working-in-cpanel-php-script

No comments:

Post a Comment