Trying to add a custom button in woocomerce in checkout via plugin

I´m trying to create a plugin to add a custom button in the woocomerce checkout just before clicking on place order, but no matter what I do it never shows up on the page.

function add_custom_button_before_place_order() {
    ?>
    <div style="margin-bottom: 20px;">
        <button type="button" class="button alt" id="customButton">My Custom Button</button>
    </div>
    <script type="text/javascript">
        document.getElementById("customButton").onclick = function() {
            alert("Button clicked!");
        }
    </script>
    <?php
}

add_action('woocommerce_review_order_before_submit', 'add_custom_button_before_place_order');

Thank you so much.

Why can’t I use migration in my symfony project?

I have a problem with my migration command.
I checked my credentials and they’re actually valid so I tried various methods.
I tried putting localhost and 127.0.0.1 with and without ports in this line in .env:
"mysql://'usr':'pwd'@host/db_name?serverVersion=8.0.35&charset=utf8"
I tried with and without password.
He are my problems.
When I use localhost I get these errors

In ExceptionConverter.php line 101:
                                                                                                                                    
  An exception occurred in the driver: SQLSTATE[HY000] [1045] Access denied for user 'Robertson'@'localhost' (using password: YES)  
                                                                                                                                    

In Exception.php line 28:
                                                                                               
  SQLSTATE[HY000] [1045] Access denied for user 'Robertson'@'localhost' (using password: YES)  
                                                                                               

In Driver.php line 33:
                                                                                               
  SQLSTATE[HY000] [1045] Access denied for user 'Robertson'@'localhost' (using password: YES)

and when I use the 127 as host, it just loads infinitely. I get no message or anything. The command just goes to a new line and nothing happens.

I even tried to use them without starting the server. I’m new to symfony and maybe someone had a similar problem but I can’t find it.
If any information is needed please tell me and I’ll deliver it

I’m using Fedora 38 btw

php 7.4 it is working fine but in php 8.0+ it is not working

The main error i am getting here
variable = createVoucherCurl

it will return 403 forbidden

Please help i am stuck here last 1 week.

Thanks advance for provide solutions.

{
 error: {
  code: 403,
  message: "Forbidden"
 }
}

Below is my code

<?php
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: 0"); // Proxies.
ob_start();
const AUTH_TOKEN = "TESTWRINGTOKEN"; // Replace with a long, complex static token and put in general settings variable


if (isset($_GET['token']) && $_GET['token'] === AUTH_TOKEN) {


    function getWifiCode($n, $quota, $minutes, $note, $up, $down) {
        $urlBase = "https://184.67.111.138";
        $loginEndpoint = "/api/auth/login";
        $createVoucherEndpoint = "/proxy/network/api/s/default/cmd/hotspot";
        $queryVoucherEndpoint = "/proxy/network/api/s/default/stat/voucher";
 // Dynamically generate a cookie file name based on session ID
        $cookieFile = 'cookie_' . session_id() . '.txt';
        // Login and retrieve the CSRF token
        $loginCurl = curl_init($urlBase . $loginEndpoint);
        curl_setopt($loginCurl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($loginCurl, CURLOPT_POST, true);
        curl_setopt($loginCurl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
        curl_setopt($loginCurl, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($loginCurl, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($loginCurl, CURLOPT_POSTFIELDS, json_encode([
            'username' => 'pangeapod',
            'password' => 'BAjD:)ai4rM83bE'
        ]));
        curl_setopt($loginCurl, CURLOPT_HEADER, true);
        curl_setopt($loginCurl, CURLOPT_COOKIEJAR, $cookieFile); // Use the session-based cookie file
        $loginResponse = curl_exec($loginCurl);
$loginError = curl_error($loginCurl);


if ($loginError) {
    echo "cURL Error for Login: " . $loginError;
} else {
   // echo "Login Response: " . htmlspecialchars($loginResponse);  // Use htmlspecialchars for safe rendering of the response in the browser
}
        preg_match('/x-csrf-token: (.*?)(rn)/', $loginResponse, $matches);
        $csrfToken = isset($matches[1]) ? $matches[1] : null;
        
        curl_close($loginCurl);
// Prepare headers
$headers = [
    'Content-Type: application/json',
    'X-CSRF-Token: ' . $csrfToken
];


// Prepare post data
$data = [
    "cmd" => "create-voucher",
    "n" => (int) $_POST['n'],  // casting to integer
    "expire" => (int) $_POST['minutes'],  // casting to integer
    "note" => $_POST['note'],
    "up" => (int) $_POST['up'],  // casting to integer
    "down" => (int) $_POST['down'],  // casting to integer
    "quota" => (int) $_POST['quota']  // casting to integer
];


$postData = json_encode($data);
$url = $urlBase . $createVoucherEndpoint;
// Log details
//echo "Sending request to: " . $url . "<br>";
//echo "Headers: <pre>" . print_r($headers, true) . "</pre><br>";
//echo "Body: " . htmlspecialchars($postData) . "<br>";


        // Create Voucher
        $createVoucherCurl = curl_init($urlBase . $createVoucherEndpoint);
        curl_setopt($createVoucherCurl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($createVoucherCurl, CURLOPT_POST, true);
        curl_setopt($createVoucherCurl, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($createVoucherCurl, CURLOPT_COOKIEFILE, $cookieFile); // Use the session-based cookie file
        curl_setopt($createVoucherCurl, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($createVoucherCurl, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($createVoucherCurl, CURLOPT_POSTFIELDS, $postData);
        
        
        $createResponse = curl_exec($createVoucherCurl);
$createError = curl_error($createVoucherCurl);
if ($createError) {
  //  echo "cURL Error for Voucher Creation: " . $createError;
} else {
  //  echo "Voucher Creation Response: " . htmlspecialchars($createResponse);
}
$createdData = json_decode($createResponse, true);
$creationTime = $createdData['data'][0]['create_time'] ?? null;
        // Query the code
        $queryVoucherCurl = curl_init($urlBase . $queryVoucherEndpoint);
        curl_setopt($queryVoucherCurl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($queryVoucherCurl, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($queryVoucherCurl, CURLOPT_COOKIEFILE, $cookieFile); // Use the session-based cookie file
        curl_setopt($queryVoucherCurl, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($queryVoucherCurl, CURLOPT_SSL_VERIFYPEER, 0);
        $queryResponse = curl_exec($queryVoucherCurl);
        $queryError = curl_error($queryVoucherCurl);


if ($queryError) {
 //   echo "cURL Error for Query Voucher: " . $queryError;
} else {
  //  echo "Query Response: " . htmlspecialchars($queryResponse);
}
        curl_close($queryVoucherCurl);
// Clean up the cookie file after use
        unlink($cookieFile);
        $data = json_decode($queryResponse, true);
if (is_array($data) && isset($data['data'])) {
    foreach ($data['data'] as $voucher) {
        if ($voucher['create_time'] == $creationTime) {
            return $voucher['code'];
        }
    }
}




    }


if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    session_start();
    $code = getWifiCode(
        $_POST['n'],
        $_POST['quota'],
        $_POST['minutes'],
        $_POST['note'],
        $_POST['up'],
        $_POST['down']
    );
     session_write_close(); // Close the session after the function call
      if (isset($_POST['json']) && $_POST['json'] == 'true') {
        header('Content-Type: application/json');
        echo json_encode(['voucher_code' => $code]);
    } else {
    ?>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>WiFi Voucher</title>
        <style>
            body { font-family: Arial, sans-serif; background-color: #f5f5f5; padding: 20px; text-align: center; }
            .voucher-code {
                font-size: 36px;
                padding: 20px;
                border: 3px dashed #007BFF;
                display: inline-block;
                margin-top: 20px;
                color: #007BFF;
            }
        </style>
    </head>
    <body>
        <div class="voucher-code"><?php echo $code; ?></div>
    </body>
    </html>
    <?php
    } // end for checking if it should return json. 
} else {
    ?>
      <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>WiFi Access</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f5f5f5;
            padding: 20px;
            text-align: center;
        }


        select, input[type="text"] {
            padding: 10px;
            width: 100%;
            max-width: 300px;
            border-radius: 8px;
            border: 1px solid #ccc;
            margin-bottom: 15px;
        }


        .section {
            border: dashed 2px #ccc;
            margin-bottom: 20px;
            padding: 10px;
        }


        .section-header {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center; 
    position: relative;
}


.section-header span {
    position: absolute;
    right: 10px;
}


        .section-content {
            display: none; /* default state is collapsed */
        }


        .btn {
            margin: 20px;
            padding: 15px;
            border: none;
            border-radius: 8px;
            font-size: 16px;
            cursor: pointer;
            width: 80%;
            max-width: 300px;
        }


        .guest { background-color: #4CAF50; color: white; }
        .paid { background-color: #007BFF; color: white; }


        h2 {
            color: #333;
            margin-bottom: 25px;
        }
    </style>
</head>
<body>


<div class="section">
    <div class="section-header" onclick="toggleSection(this)">
        <h2>Guest WiFi</h2>
        <span>&#9660;</span>
    </div>
    <div class="section-content">
        <form action="?token=<?= AUTH_TOKEN ?>" method="POST">
            <select name="minutes">
                <?php
                for($i=1; $i<=7; $i++){
                    echo '<option value="'. $i * 1440 .'">'. $i .' day'. ($i > 1 ? 's' : '') .'</option>';
                }
                ?>
            </select>
            <br>
            <select name="down">
                <option value="10000">Default Download Speed - 10 MPS</option>
                <option value="30000">Fast Download Speed - 30 MPS</option>
            </select>
            <br>
            <input type="text" name="note" minlength="5" placeholder="Note (Min 5 chars)" required>
            <br>
            <input type="hidden" name="n" value="1">
            <input type="hidden" name="quota" value="0">
            <input type="hidden" name="up" value="10000">
            <button type="submit" class="btn guest">Get Code</button>
        </form>
   </div>
</div>


<div class="section">
    <div class="section-header" onclick="toggleSection(this)">
        <h2>Paid WiFi</h2>
        <span>&#9660;</span>
    </div>
    <div class="section-content">
        <form action="?token=<?= AUTH_TOKEN ?>" method="POST">
            <select name="minutes">
                <?php
                for($i=1; $i<=7; $i++){
                    echo '<option value="'. $i * 1440 .'">'. $i .' day'. ($i > 1 ? 's' : '') .'</option>';
                }
                ?>
            </select>
            <br>
            <select name="down">
                <option value="50000">Default Fast - 50 MPS</option>
                <option value="80000">Super Fast - 80 MPS</option>
            </select>
            <br>
            <input type="text" name="note" minlength="5" placeholder="Note (Min 5 chars)" required>
            <br>
            <input type="hidden" name="n" value="1">
            <input type="hidden" name="quota" value="0">
            <input type="hidden" name="up" value="50000">
            <button type="submit" class="btn paid">Get Code</button>
        </form>
   </div>
</div>


<div class="section">
    <div class="section-header" onclick="toggleSection(this)">
        <h2>Staff WiFi</h2>
        <span>&#9660;</span>
    </div>
    <div class="section-content">
        <form action="?token=<?= AUTH_TOKEN ?>" method="POST">
            <input type="text" name="note" minlength="8" placeholder="Name (Min 8 chars)" required>
            <input type="hidden" name="n" value="1">
            <input type="hidden" name="quota" value="0">
            <input type="hidden" name="up" value="50000">
            <input type="hidden" name="down" value="70000">
            <input type="hidden" name="minutes" value="<?= 525600 ?>"> <!-- 1 year in minutes -->
            <button type="submit" class="btn guest">Get Code</button>
        </form>
    </div>
</div>


<div class="section">
    <div class="section-header" onclick="toggleSection(this)">
        <h2>Device WiFi</h2>
        <span>&#9660;</span>
    </div>
    <div class="section-content">
        <form action="?token=<?= AUTH_TOKEN ?>" method="POST">
            <input type="text" name="note" minlength="1" placeholder="Device Name" required>
            <input type="hidden" name="n" value="1">
            <input type="hidden" name="quota" value="0">
            <input type="hidden" name="up" value="50000">
            <input type="hidden" name="down" value="80000">
            <input type="hidden" name="minutes" value="<?= 5256000 ?>"> <!-- 10 years in minutes -->
            <button type="submit" class="btn paid">Get Code</button>
        </form>
    </div>
</div>


<script>
    function toggleSection(element) {
        const content = element.nextElementSibling;
        if(content.style.display === "none" || content.style.display === "") {
            content.style.display = "block";
            element.querySelector("span").innerHTML = "&#9650;";
        } else {
            content.style.display = "none";
            element.querySelector("span").innerHTML = "&#9660;";
        }
    }
</script>


</body>
</html>


        <?php
    }


} else {
    echo "Unauthorized.";
}
ob_end_flush();
?>

Debug on old laravel version [closed]

I am currently working on a project with these features :
-PHP 7.3.31
-laravel 5.8.

I’m on vscode and wanted to know what your debugging methods are? Do you have any good tips? Is the only way to debug with this version to put logs everywhere?

For the moment, apart from putting logs everywhere, I don’t see any other solution.

Why does whatsapp business php api deliver my template messages twice?

All the template messages that I post once will be received twice by the opposite user. I send messages through php API. I have two apps under one business account, and both are having the same problems.
My PHP curl code is:

$messageBody = 'Welcome and congratulations!! This message demonstrates your ability to send a WhatsApp message notification from the Cloud API, hosted by Meta. Thank you for taking the time to test with us.' ;

$template_array = array(
    "name" => $templateName, //
    "language" => '{ "code": "en_US" }', 
    //"components" => '' //for parameters
) ;

$text_arr = array(
    'preview_url' => 'false', 
    'body' => $messageBody
);

$fields = array(
    'messaging_product' => 'whatsapp',
    'recipient_type' => 'individual',
    'to' => 91 . $toMobile,
    'type' => 'template',
    'template' => $template_array,
    'type' => 'text',
    'text' => $text_arr

);


$headers = array( "Authorization: Bearer " . $accessToken, "Content-Type: application/json", );

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $postUrl);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($fields) );
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$response = json_decode(curl_exec($curl), true);
//print_r($response);
$jsonResult = curl_exec($curl) ;
$resultCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);

echo $resultCode . ' - ' . $jsonResult ;

curl_close($curl);

navigation bar misplaced or just wrong codes. i don’t now what to do anymore

the navigation bar and side bar is not supposed to be in the admin log in page.

the navigation bar and side bar should only pop ups after i logged in as admin.

this is the admin log in page with navigation bar that not supposed to be there.
///picture///

yet this is what happened after i logged in, the design are not existing.

///picture///

i don’t understand why its wrong.

this is the code for that navigation bar and nav side bar.

` <?php

 if(is_admin_login())
{

?>
 <body class="sb-nav-fixed">
    <nav class="sb-topnav navbar navbar-expand navbar-dark bg-dark">
        <!-- Navbar Brand-->
         <a class="navbar-brand ps-3" href="index.php">Library System</a>
        <!-- Sidebar Toggle-->
        <button class="btn btn-link btn-sm order-1 order-lg-0 me-4 me-lg-0" id="sidebarToggle" href="#!"><i class="fas fa-bars"></i></button>
        <form class="d-none d-md-inline-block form-inline ms-auto me-0 me-md-3 my-2 my-md-0">
        </form>
        <!-- Navbar-->
        <ul class="navbar-nav ms-auto ms-md-0 me-3 me-lg-4">
            <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" id="navbarDropdown" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"><i class="fas fa-user fa-fw"></i></a>
                <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
                   <li><a class="dropdown-item" href="logout.php">Logout</a></li>
                </ul>
            </li>
        </ul>
    </nav>

    <div id="layoutSidenav">
        <div id="layoutSidenav_nav">
            <nav class="sb-sidenav accordion sb-sidenav-dark" id="sidenavAccordion">
                <div class="sb-sidenav-menu">
                    <div class="nav">

                    <a class="nav-link" href="logout.php">Logout</a>

                    </div>
                </div>
                <div class="sb-sidenav-footer">
                   
                </div>
            </nav>
        </div>
        <div id="layoutSidenav_content">
            <main>

<?php 
}`

and this is the code for the admin login page where that code from above should not be here in admin log in page.

`<?php

//admin_login.php

include ‘database_connection.php’;

include ‘function.php’;

$message = ”;

if(isset($_POST[“login_button”]))
{

$formdata = array();

if(empty($_POST["admin_email"]))
{
    $message .= '<li>Email Address is required</li>';
}
else
{
    if(!filter_var($_POST["admin_email"], FILTER_VALIDATE_EMAIL))
    {
        $message .= '<li>Invalid Email Address</li>';
    }
    else
    {
        $formdata['admin_email'] = $_POST['admin_email'];
    }
}

if(empty($_POST['admin_password']))
{
    $message .= '<li>Password is required</li>';
}
else
{
    $formdata['admin_password'] = $_POST['admin_password'];
}

if($message == '')
{
    $data = array(
        ':admin_email'      =>  $formdata['admin_email']
    );

    $query = "
    SELECT * FROM lms_admin 
    WHERE admin_email = :admin_email
    ";

    $statement = $connect->prepare($query);

    $statement->execute($data);

    if($statement->rowCount() > 0)
    {
        foreach($statement->fetchAll() as $row)
        {
            if($row['admin_password'] == $formdata['admin_password'])
            {
                $_SESSION['admin_id'] = $row['admin_id'];

                header('location:admin/index.php');
            }
            else
            {
                $message = '<li>Wrong Password</li>';
            }
        }
    }   
    else
    {
        $message = '<li>Wrong Email Address</li>';
    }
}

}

include ‘header.php’;

?>

<div class="col-md-6">

    <?php 
    if($message != '')
    {
        echo '<div class="alert alert-danger"><ul>'.$message.'</ul></div>';
    }
    ?>

    <div class="card">

        <div class="card-header">Admin Login</div>

        <div class="card-body">

            <form method="POST">

                <div class="mb-3">
                    <label class="form-label">Email address</label>

                    <input type="text" name="admin_email" id="admin_email" class="form-control" />

                </div>

                <div class="mb-3">
                    <label class="form-label">Password</label>

                    <input type="password" name="admin_password" id="admin_password" class="form-control" />

                </div>

                <div class="d-flex align-items-center justify-content-between mt-4 mb-0">

                    <input type="submit" name="login_button" class="btn btn-primary" value="Login" />

                </div>

            </form>

        </div>

    </div>

</div>

`

i’m watching this from the youtube and carefully write codes line per line and yet the output i get is not the same as i watch from the youtube. this is the video link:

since this is my first time doing php. i used to do java coding.

How to count the number of students from each course from the mysql database?

So, I want to make a calculator that will calculate this formula:

Result = No. of Attendance / (No. of Students * No. of School Days) 

but I want the No. of students to be counted automatically by course and strand (different column) from the database.

This is the initial code:

<?php include 'includes/session.php'; ?>
<?php include 'includes/header.php'; ?>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

  <?php include 'includes/navbar.php'; ?>
  <?php include 'includes/menubar.php'; ?>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        Calculator
      </h1>
    </section>
    <!-- Main content -->
    <section class="content">
      <div class="row">
        <div class="col-md-12">
          <div class="box box-info">
            <div class="box-body">
              <form method="post">
                <label for="D">No. of Attendance:</label>
                <input type="text" id="D" name="D" placeholder="No. of Attendance" value="<?php echo isset($_POST['D']) ? $_POST['D'] : '' ?>"><br>
                <label for="B">No. of Students:</label>
                <input type="text" id="B" name="B" placeholder="No. of Students" value="<?php echo isset($_POST['B']) ? $_POST['B'] : '' ?>"><br>
                <label for="C">No. of School Days:</label>
                <input type="text" id="C" name="C" placeholder="No. of School Days" value="<?php echo isset($_POST['C']) ? $_POST['C'] : '' ?>"><br>
                <button type="submit" name="submit" value="submit">Calculate</button>
              </form>
              <h4>
                <?php
                if (isset($_POST['submit'])) {
                    // Retrieve user input values for D, B, and C
                    $D = isset($_POST['D']) ? $_POST['D'] : 0;
                    $B = isset($_POST['B']) ? $_POST['B'] : 0;
                    $C = isset($_POST['C']) ? $_POST['C'] : 0;

                    // Ensure the inputs are numeric
                    if (is_numeric($D) && is_numeric($B) && is_numeric($C)) {
                        // Check if B and C are not zero to avoid division by zero error
                        if ($B != 0 && $C != 0) {
                            // Calculate A = D / (B * C)
                            $A = $D / ($B * $C);
                            // Convert to percentage
                            $percentage = $A * 100;
                            echo "Result: A = " . $A . " or  " . $percentage . "%";
                        } else {
                            echo "Error: Division by zero";
                        }
                    } else {
                        echo "Please enter numeric values for D, B, and C";
                    }
                }
                ?>
              </h4>
            </div>
          </div>
        </div>
      </div>
    </section>
  </div>
  <!-- /.content-wrapper -->
</div>
<!-- ./wrapper -->

<?php include 'includes/scripts.php'; ?>
</body>
</html>

This is the code I edited:

<?php include 'includes/session.php'; ?>
<?php include 'includes/header.php'; ?>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

  <?php include 'includes/navbar.php'; ?>
  <?php include 'includes/menubar.php'; ?>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        Calculator
      </h1>
    </section>
    <!-- Main content -->
    <section class="content">
      <div class="row">
        <div class="col-md-12">
          <div class="box box-info">
            <div class="box-body">
              <form method="post">
                <label for="course">Select Course:</label>
                <select id="course" name="course">
                  <option value="">Select Course</option>
                  <?php
                  // Fetch courses from your database and populate the dropdown menu
                  // Assuming you have a database connection already established
                  $query = "SELECT * FROM position_college"; // Modify this query according to your database schema
                  $result = mysqli_query($connection, $query);
                  if ($result) {
                      while ($row = mysqli_fetch_assoc($result)) {
                          echo "<option value='" . $row['description_college'] . "</option>";
                      }
                  }
                  ?>
                </select><br>
                <label for="D">No. of Attendance:</label>
                <input type="text" id="D" name="D" placeholder="No. of Attendance" value="<?php echo isset($_POST['D']) ? $_POST['D'] : '' ?>"><br>
                <label for="B">No. of Students:</label>
                <input type="text" id="B" name="B" placeholder="No. of Students" value="<?php echo isset($_POST['B']) ? $_POST['B'] : '' ?>"><br>
                <label for="C">No. of School Days:</label>
                <input type="text" id="C" name="C" placeholder="No. of School Days" value="<?php echo isset($_POST['C']) ? $_POST['C'] : '' ?>"><br>
                <button type="submit" name="submit" value="submit">Calculate</button>
              </form>
              <h4>
                <?php
                if (isset($_POST['submit'])) {
                    // Retrieve user input values for D, B, C, and the selected course
                    $D = isset($_POST['D']) ? $_POST['D'] : 0;
                    $B = isset($_POST['B']) ? $_POST['B'] : 0;
                    $C = isset($_POST['C']) ? $_POST['C'] : 0;
                    $selected_course = isset($_POST['course']) ? $_POST['course'] : 0;

                    // Ensure the inputs are numeric
                    if (is_numeric($D) && is_numeric($B) && is_numeric($C) && $selected_course) {
                        // Check if B and C are not zero to avoid division by zero error
                        if ($B != 0 && $C != 0) {
                            // Calculate A = D / (B * C)
                            $A = $D / ($B * $C);
                            // Convert to percentage
                            $percentage = $A * 100;
                            echo "Result: A = " . $A . " or  " . $percentage . "%";
                        } else {
                            echo "Error: Division by zero";
                        }
                    } else {
                        echo "Please enter numeric values for D, B, C, and select a course";
                    }
                }
                ?>
              </h4>
            </div>
          </div>
        </div>
      </div>
    </section>
  </div>
  <!-- /.content-wrapper -->
</div>
<!-- ./wrapper -->

<?php include 'includes/scripts.php'; ?>
</body>
</html>

But this code doesn’t work and it doesn’t seem to provide result the I wanted it to give. These are the tables in the database

enter image description here
enter image description here

Undefined array key “text” warning [closed]

I’m trying to solve the issue of Undefined array key “text”, but implemented fix doesn’t seem to work. Any ideas? 🙁 The whole file is fairly big, thousands of line, wondering if that’s part of the issue but error is same line always

ORIGINAL

  static function _helper_to_panel_values() {
        // add the rest
        foreach (self::get_all() as $id => $config) {
            $buffy_array[] = array(
                'text' => $config['text'],
                'title' => '',
                'val' => $id,
                'img' => $config['img']
            );
        }

        // the first template is the default one, ex: it has no value in the database
        $buffy_array[0]['val'] = '';

        return $buffy_array;
    }

TRYING TO FIX

static function _helper_to_panel_values() {
    $buffy_array = array(); // Initialize the array to avoid undefined variable warning

    // add the rest
    foreach (self::get_all() as $id => $config) {
        // Check if 'text' key exists in $config array before accessing it
        $text = isset($config['text']) ? $config['text'] : '';
        $img = isset($config['img']) ? $config['img'] : '';
        
        $buffy_array[] = array(
            'text' => $text,
            'title' => '',
            'val' => $id,
            'img' => $img
        );
    }

    // the first template is the default one, ex: it has no value in the database
    $buffy_array[0]['val'] = '';

    return $buffy_array;
}

want to assign the orders manually to the vendor show them in dokan deshboard but the client can’t register himself can’t add products

[enter image description here](https://i.sstatic.net/nSm0fMlP.png)

Hello experts I need to ask about one of my client website that my client wants to add the vendor and to create the him a username and password by him self so that he can assign them a order in woocommerace but woocommerce don’t provide such feature so I added acf field to get the vendor list now we can select the vendor but when we update and goes to vendor Dokan deshboard the order which we assign to him is not showing if anyone have a solution olz help me

// Function to show WooCommerce orders assigned to the current Dokan vendor based on a custom ACF field
function show_orders_assigned_to_vendor_by_username() {
    // Check if the current user is a Dokan vendor
    if (!dokan_is_user_seller(get_current_user_id())) {
        return; // If not a vendor, exit
    }

    // Get the current vendor's username or email
    $current_vendor_username = wp_get_current_user()->user_login; // Get current user's username

    // Query for WooCommerce orders where the ACF field matches the current vendor's username
    $args = [
        'post_type' => 'shop_order',
        'post_status' => [
            'wc-processing',
            'wc-completed',
            'wc-pending',
            'wc-on-hold',
            'wc-cancelled',
            'wc-refunded',
            'wc-failed',
        ],
        'meta_query' => [
            [
                'key' => 'assigned_vendor', // ACF field key
                'value' => $current_vendor_username, // Vendor's username to compare
                'compare' => '=',
            ],
        ],
        'orderby' => 'date',
        'order' => 'DESC',
    ];

    $orders = new WP_Query($args);

    // Display the list of orders in the Dokan vendor dashboard
    if ($orders->have_posts()) {
        ?>
        <h2>Orders Assigned to You</h2>
        <ul>
            <?php
            while ($orders->have_posts()) {
                $orders->the_post(); // Set up the post data
                $order_id = get_the_ID(); // Get the order ID
                $order = wc_get_order($order_id); // Get WooCommerce order object

                // Display basic order information
                ?>
                <li>
                    Order ID: <?= $order_id ?> - 
                    Date: <?= $order->get_date_created()->format('Y-m-d') ?> - 
                    Status: <?= wc_get_order_status_name($order->get_status()) ?> 
                </li>
                <?php
            }
            ?>
        </ul>
        <?php
    } else {
        ?>
        <p>No orders assigned to you.</p> 
        <?php
    }

    wp_reset_postdata(); // Reset the global post data
}

// Hook into the Dokan vendor dashboard to display the custom section
add_action('dokan_dashboard_content_inside_before', 'show_orders_assigned_to_vendor_by_username'); // Adjust the hook if needed

I need to solve the problem for my website

Long wait for “nothing” method on livewire component

I am using Livewire 2.x and I have a query, it turns out that in my livewire component, I have several methods that are called chained according to the events that happen (a file is uploaded and processed in stages which are reported to the UI)
There are about 7 stages, but in stage 6, the component method does nothing on purpose for the test, and it turns out that it takes several seconds. I have cleaned with $this->refresh(‘varname’) thinking that they are the public properties that are transmitted, but it still takes a while to do anything.
More than a problem, I would actually like to know what happens since apparently it is the way Livewire works. I would like to better understand how it works.
thank you

Show/Hide/Disable/Enable Required HTML Form Field Based on Another form Value with Complication of WordPress and Elementor (Conditional Form Field)

Case Example: Where a user selects 3 drinks, they get asked if they would like a courtesy hot chocolate in a second form field that conditionally appears. The first form field is always required, the second is required when the condition of field 1 is met. Where the user changes the value of the first form field back to less than 3 drinks, the second (conditional) form field, that asks if they’d like a courtesy hot chocolate, is disabled from being required and disappears.

I have got as far as setting div display to hidden for the conditional field.

What I am looking to achieve

  1. Showing/Hiding/Disabling and Enabling “Required” for a conditional form field based on another value (such as a HTML slider or a radio button being the first field).

My form is created using HTML and PHP, my intention is to insert it as a code snippet into WordPress using a third party module. I also use Elementor. I’d ideally like the form to inherit Elementor’s styling. One of the problems that I envisage is adding two classes to the same widget in Elementor.

Questions:

Would it cause any harm to declare classes inline (I can’t see any other option)? If there is a recommended alternative, please suggest it – Elementor is needed on my website though, as is WordPress.

Is it possible from a code snippet to have it inherit Elementor’s styling and how can I encourage this please?

Does the method of showing/hiding/disabling/enabling the requirement of completion on a form field differ in any way depending on the “triggering” or the “conditionally appearing” field depending on if the “triggering” field is a radio button, checkbox, dropdown value or a Range slider please?

I’m not a javascript coder – if I spent my life learning every coding language just to be able to achieve a basic aim, i’d never get on with my overall goal so there has to be a sanity cut-off point but please could someone point me in the right direction in terms of what I need from a Javascript point of view.

With many thanks and hopefully the question is useful to others too.

I have got as far as setting div display to hidden for the conditional field.

Migrate Auth PHP native to laravel with API

I have example PHP native for auth with API and its working:

This fungsi.php:

This fungsi.php

This login.php

This login.php

and this home.php

and this home.php

this my example controller auth laravel:

this my example controller auth laravel

I already try it with guzzle or sanctum but didn’t work.

I use laravel 10 but if the project need laravel 11 I ready to upgrade it.

Can someone please help me?

Unity Text on Each other

this is my AdminUI.cs

using UnityEngine;
using TMPro;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine.Networking;

public class AdminUI : MonoBehaviour
{
    public TextMeshProUGUI userPrefab; // TextMeshProUGUI prefab for user email and username
    public Transform contentPanel; // Panel to which the TextMeshPro components will be attached

    async void Start()
    {
        // Fetch user data from the database
        string usersText = await Getusers.GetUsersText();

        // Split the received text by newline character
        string[] lines = usersText.Split('n');

        // Display user data using TextMeshPro
        foreach (string line in lines)
        {
            // Instantiate TextMeshPro component for user email and username
            TextMeshProUGUI userText = Instantiate(userPrefab, contentPanel);

            // Set the user email and username text
            userText.text = line;
        }
    }
}

public static class Getusers
{
    readonly static string SERVER_URL = "http://localhost:80/Cryppy";

    public static async Task<string> GetUsersText()
    {
        string GET_USERS_URL = $"{SERVER_URL}/GetUsers.php";
        UnityWebRequest req = UnityWebRequest.Get(GET_USERS_URL);

        // Send the request asynchronously
        var operation = req.SendWebRequest();

        // Wait until the request is completed
        while (!operation.isDone)
        {
            await Task.Delay(100); // You can adjust the delay time as needed
        }

        // Check for errors
        if (req.result != UnityWebRequest.Result.Success)
        {
            Debug.LogError($"Error fetching users: {req.error}");
            return null;
        }
        else
        {
            // Return the response text
            return req.downloadHandler.text;
        }
    }


}

and this is the GetUser.php

<?php
// Connect to your database
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "cryppy_nightfall";

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Fetch user data
$sql = "SELECT email, username FROM user";
$result = $conn->query($sql);

// Check if any rows were returned
if ($result->num_rows > 0) {
    $users = "";
    // Output data of each row
    while($row = $result->fetch_assoc()) {
        // Concatenate email and username with a colon and line break
        $user = $row["email"] . ":" . $row["username"] . "n";
        $users .= $user;
    }
    
    // Return the string
    echo $users;
} else {
    echo "0 results";
}
$conn->close();
?>
     

in the website , the data displayed good
but in unity when lunch , the data display on each other so you can’t even read

tried to add
to the php
and tried n to the script
but not worked
btw am using scroll view , so this info should be dispalyed in UI screen