Laravel 10 custom login/registration not going to dashboard page

I am trying to make my own custom laravel 10 login/registration because i didn’t want to use the breez package because i wanted to learn how do you make a login/registrasion by yourself.

But I cant seem to get past the authentication of the dashboard page.

I am using an if statment if(Auth::check()) on my dashboard function to authenticate the user in the database.

but for me this isn’t working because i keep getting the error message from the redirect back to the login page (This only happens when I register a new user into the database) but whenever I try loging in I get the success message from my login function (See code futher down) while still being in the login page.

AuthController (Dashboard):

public function dashboard(): View
    {
        if(Auth::check()) {
            return view('auth.dashboard');
        }

        return view('auth.login')->with('error', 'You are not allowed to access');
    }

AuthController (Login):

public function loginPost(Request $request): RedirectResponse
    {
        $request->validate([
           'email' => 'required',
           'password' => 'required'
        ]);

        $credentials = $request->only('email', 'password');

        if(Auth::attempt($credentials)) {

            $request->session()->regenerate();

            return redirect()->intended(route('dashboard'))->with('success', 'You have successfully logged in');
        }

        return redirect(route('login'))->with('error', 'Oppes! You have entered invalid credentials');
    }

web.php

Route::get('/register', [AuthController::class, 'register'])->name('register');
Route::post('/register', [AuthController::class, 'registerPost'])->name('register.post');
Route::get('/login', [AuthController::class, 'login'])->name('login');
Route::post('/login', [AuthController::class, 'loginPost'])->name('login.post');
Route::get('/dashboard', [AuthController::class, 'dashboard'])->name('dashboard');
Route::post('/logout', [AuthController::class, 'logout'])->middleware('auth')->name('logout');

I havn’t found any solution yet so if someone can help me it will be very appreciated.

PHP: Homepage just reloads after logging in, dropdowns for user not showing

I wanna ask what is wrong with my code. When the user is not logged in, the user icon on index.php nav bar will redirect to customer.php(login). And after they login, it will go back to index.php and the user icon will contain the dropdown.

The problem is that after I try to login, when I click the user icon, my homepage just reloads. Here is my code:

header.php

    <li <?php if($current_page == "login") echo "class='login'" ?> class="nav-item dropdown">
       <?php
       if(isset($_SESSION['user_id'])) { ?>
         <a href="#" class="nav-link dropdown-toggle" id="userDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
            <i class="bi bi-person-circle text-white"></i>
         </a>
         <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="userDropdown">
            <li><a class="dropdown-item" href="customer_profile.php"><i class="bi bi-person-badge-fill me-2"></i>My Profile</a></li>
            <li><a class="dropdown-item" href="customer_orders.php"><i class="bi bi-box-fill me-2"></i>My Orders</a></li>
            <li><a class="dropdown-item" href="customer_settings.php"><i class="bi bi-gear-fill me-2"></i>Settings</a></li>
            <li><a class="dropdown-item" href="notifications.php"><i class="bi bi-bell-fill me-2"></i>Notifications</a></li>
            <li><hr class="dropdown-divider"></li>
            <li><a class="dropdown-item" href="customer_logout.php"><i class="bi bi-box-arrow-left me-2"></i>Logout</a></li>
         </ul>
         <?php } else { ?>
         <a href="customer.php" class="nav-link">
                <i class="bi bi-person-circle text-white"></i>
         </a>
         <?php } ?>
    </li>

customer.php

   
        <?php
                $current_page = "login";
                require 'user-config.php';
                if(isset($_SESSION["user_id"])) {
                    header("location: index.php");
                    exit();
                }
                if(isset($_POST["submit"])) {
                    $usernameemail = mysqli_real_escape_string($conn, $_POST["usernameemail"]);
                    $password = mysqli_real_escape_string($conn, $_POST["password"]);
                    $result = mysqli_query($conn, "SELECT * FROM users WHERE username = '$usernameemail' OR email = '$usernameemail'");
                    if(mysqli_num_rows($result) > 0) {
                        $row = mysqli_fetch_assoc($result);
                        if(password_verify($password, $row["password"])) {
                            $_SESSION["user_id"] = $row["user_id"];
                            header("location: index.php");
                            exit();
                        } else {
                            echo "<script> alert('Wrong password.'); </script>";
                        }
                    } else {
                        echo "<script> alert('User is not registered.'); </script>";
                    }
                }
            ?>
    
           <!--Other content-->
    
           <!--Navigation Bar-->
              <?php require_once 'customer/includes/header.php'; ?>
           <!--End of Navigation Bar-->
    
    <!-- end snippet -->

Laravel 9 PHP 8 – Issue with batch cancelling

I’m using Laravel 9 with PHP 8.0.

I would like to launch several hundred jobs one after the other.

I initialized my jobs by storing them in “recognitionsBus”. Then ran the batch.

I tried to reduce the job to the minimum to just log informations, but each time a job is launched, it passes in the condition which says that the batch is cancelled

Also, not all jobs are executed. After a certain number, the batch stops. It may be an issue on my side but the batch doesn’t pass through the then/catch or finally. Do you know why ?

Thank you in advance.

Controller

    foreach ($recognitions as $recognition) {
    $test = Test::create([...]);

    $recognitionsBus->push(new TestJob($test);
    }

    Bus::batch($recognitionsBus->toArray())
    ->then(function (Batch $batch) use ($test) {
        Log::info("success");
    })->catch(function (Batch $batch, Throwable $e) use($test) {
        Log::error("error");

        throw $e;
    })->finally(function (Batch $batch) use ($test) {
        Log::info("finish");
    })
    ->dispatch();

Job

    <?php

    namespace AppJobs;

    use IlluminateBusBatchable;
    use IlluminateBusQueueable;
    use IlluminateContractsQueueShouldQueue;
    use IlluminateFoundationBusDispatchable;
    use IlluminateQueueInteractsWithQueue;
    use IlluminateQueueSerializesModels;
    use IlluminateSupportFacadesLog;
    use Throwable;

    class TestJob implements ShouldQueue
    {
    use Batchable, Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $test;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($test)
    {
        $this->test = $test;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        if ($this->batch()->cancelled()) {
            Log::info('canceled');

            return;
        }

        Log::info($this->test->id);
    }

    /**
     * Handle a job failure.
     */
    public function failed(Throwable $exception)
    {
        Log::info($exception->getMessage());
    }
    }

Command

php artisan queue:work

How to place a marker in javascript at the right point according to the data in the database on the maps view?

I want to update the data, but when I open one of the data based on ID, the marker doesn’t appear in the maps view, so I can’t drag it to change position.

This is view code :

@extends('layouts.main')

@section('container')
<style type="text/css">
    #map {
      height: 400px;
    }
</style>
<main class="form-login">
            @csrf
            <div class="card">
              <div class="card-body mt-2">
                  <form id="UserForm" action="{{ url('update-data/'. $data->id)  }}" method="POST">
                    @csrf
                      <div class="row">
                          <div class="col-md-6">
                              <fieldset>
                                  <legend class="font-weight-semibold"><i class="icon-reading mr-2"></i>Data Pelabuhan</legend>
                                  <div class="form-group row">
                                      <label class="col-lg-3 col-form-label">Nama Pelabuhan</label>
                                      <div class="col-lg-9">
                                          <input type="email" name="email" class="form-control" placeholder="Email" value="{{ $data->nama_pelabuhan }}">
                                      </div>
                                  </div>
                                  <div class="form-group row">
                                      <label class="col-lg-3 col-form-label">Tipe Pelabuhan</label>
                                      <div class="col-lg-9">
                                          <input type="text" name="tipe_pelabuhan"  class="form-control" placeholder="Tipe Pelabuhan" value="{{ $data->tipe_pelabuhan }}">
                                      </div>
                                  </div>
                                  <div class="form-group row">
                                    <label class="col-lg-3 col-form-label">Provinsi</label>
                                    <div class="col-lg-9">
                                      <select name="provinsi" id="provinsi" class="custom-select">
                                          <option value="" selected>Pilih Provinsi</option>
                                          <option value="Nusa Tenggara Barat">Nusa Tenggara Barat</option>
                                      </select>
                                    </div>
                                  </div>
                                  <div class="form-group row">
                                    <label class="col-lg-3 col-form-label">Kabupaten</label>
                                    <div class="col-lg-9">
                                      <select name="kabupaten" id="kabupaten" class="custom-select">
                                        <option value="" selected>Pilih Kabupaten</option>
                                        <option value="Kab. Bima">Kab. Bima</option>
                                        <option value="Kab. Dompu">Kab. Dompu</option>
                                        <option value="Kab. Lombok Barat">Kab. Lombok Barat</option>
                                        <option value="Kab. Lombok Tengah">Kab. Lombok Tengah</option>
                                        <option value="Kab. Lombok Timur">Kab. Lombok Timur</option>
                                        <option value="Kab. Lombok Utara">Kab. Lombok Utara</option>
                                        <option value="Kab. Sumbawa">Kab. Sumbawa</option>
                                        <option value="Kab. Sumbawa Barat">Kab. Sumbawa Barat</option>
                                        <option value="Kota Bima">Kota Bima</option>
                                        <option value="Kota Mataram">Kota Mataram</option></select>
                                    </div>
                                </div>
                              </fieldset>
                          </div>
          
                          <div class="col-md-6">
                              <fieldset>
                                     <legend class="font-weight-semibold"><i class="icon-envelope mr-2"></i></legend>
                                  <div class="form-group row">
                                      <label class="col-lg-3 col-form-label">Konstruksi</label>
                                      <div class="col-lg-9">
                                          <input type="text" name="konstruksi" placeholder="Konstruksi" class="form-control" value="{{ $data->konstruksi }}">
                                      </div>
                                  </div>
                                  <div class="form-group row">
                                      <label class="col-lg-3 col-form-label">Tanggal Berlaku SK</label>
                                      <div class="col-lg-9">
                                          <input type="text" name="tgl_berlaku_sk" placeholder="Tanggal Berlaku SK" class="form-control" value="{{ $data->tgl_berlaku_sk }}">   
                                      </div>
                                  </div>
                                  <div class="form-group row">
                                      <label class="col-lg-3 col-form-label">Nomor Izin</label>
                                      <div class="col-lg-9">
                                          <input type="text" name="no_izin" placeholder="Nomor Izin" class="form-control" value="{{ $data->no_izin }}"> 
                                      </div>
                                  </div>
                                  <div class="form-group row">
                                    <label class="col-lg-3 col-form-label">Kedalaman Pelabuhan</label>
                                    <div class="col-lg-9">
                                        <input type="text" name="kedalaman" placeholder="Kedalaman Pelabuhan" class="form-control" value="{{ $data->kedalaman }}">  
                                    </div>
                                  </div>
                                  <div class="form-group row">
                                    <label class="col-lg-3 col-form-label">Hirarki Pelabuhan</label>
                                    <div class="col-lg-9">
                                        <input type="text" name="hierarki" placeholder="Hirarki Pelabuhan" class="form-control" value="{{ $data->hierarki }}">  
                                    </div>
                                  </div>
                                  <div class="form-group row">
                                    <label class="col-lg-3 col-form-label">Peruntukan Pelabuhan</label>
                                    <div class="col-lg-9">
                                        <input type="text" name="peruntukan" placeholder="Peruntukan Pelabuhan" class="form-control" value="{{ $data->peruntukan }}">   
                                    </div>
                                  </div>
                                  <div class="form-group row">
                                    <label class="col-lg-3 col-form-label">Tahap Pelabuhan</label>
                                    <div class="col-lg-9">
                                        <input type="text" name="tahap" placeholder="Tahap Pelabuhan" class="form-control" value="{{ $data->tahap_pelabuhan }}">    
                                    </div>
                                  </div>
                                  
                              </fieldset>
                          </div>
                        <div class="col-md">
                            <div class="mb-3">
                                <input type="hidden" name="latitude" value="{{ $data->latitude }}" class="form-control rounded-top @error('latitude') is-invalid @enderror" id="latitude" disabled>
                                @error('latitude')
                                <div class="invalid-feedback">
                                  {{ $message }}
                                </div>
                              @enderror
                              </div>
                              <div class="mb-3">
                                <input type="hidden" name="longitude" value="{{ $data->longitude }}" class="form-control rounded-top @error('longitude') is-invalid @enderror" id="longitude" disabled>
                                @error('longitude')
                                <div class="invalid-feedback">
                                  {{ $message }}
                                </div>
                              @enderror
                              </div>
                              <label for="koordinat" class="form-label">Titik Lokasi Pelabuhan</label>
                              <div id="map"></div>   
                                <script type="text/javascript">
                                    function initMap() {
                                        const myLatLng = { lat: -8.636176573413225, lng: 117.23647409339307 };
                                        const map = new google.maps.Map(document.getElementById("map"), {
                                            zoom: 8,
                                            center: myLatLng,
                                            scrollwheel: true,
                                        });

                                        var location = {{ IlluminateSupportJs::from($location) }};
                            
                                        const pos = { location };
                                        let marker = new google.maps.Marker({
                                            position: pos,
                                            map: map,
                                            draggable:true
                                        });
                                    
                                        google.maps.event.addListener(marker,'position_changed',
                                        function (){
                                            let lat = marker.position.lat()
                                            let lng = marker.position.lng()
                                            $('#latitude').val(lat)
                                            $('#longitude').val(lng)
                                        });
                                        }
                                    </script>
                                
                                    <script type="text/javascript"
                                        src="https://maps.google.com/maps/api/js?key={{ env('GOOGLE_MAP_KEY') }}&callback=initMap" >
                                    </script>

                        </div>
                      </div>
          
                  </form>

                      <div class="text-right">
                          <!-- <button type="button" id="UserBtnSinkron" class="btn btn-sm btn-warning rounded-round mr-3">
                              Sinkronisasi DRH
                          </button> -->
                          <button type="submit" id="UserBtnSave" class="btn btn-sm btn-primary rounded-round">
                              Simpan Data
                          </button>
                      </div>
              </div>
          </div>
          <!-- /2 columns form -->
    @endsection

This is Controller :

public function edit($id)
    {
        $data = Pelabuhan::find($id);
        $location = [];
        $location[] = [
            $data->latitude,
            $data->longitude
        ];
        return view('pelabuhan.edit', compact('data'),[
            'title' => 'Daftar Pelabuhan',
            'data' => $data,
            'location' => $location
        ]);
    }

I try to defined this variable to get the latitude and longitude in database, here it is the controller :

public function edit($id)
    {
        $data = Pelabuhan::find($id);
        $latitude = [];
        $latitude[] = [
            $data->latitude
        ];
        $longitude = [];
        $longitude[] = [
            $data->longitude
        ];
        return view('pelabuhan.edit', compact('data'),[
            'title' => 'Daftar Pelabuhan',
            'data' => $data,
            'latitude' => $latitude,
            'longitude' => $longitude
        ]);

And this is the javascript view :

<script type="text/javascript">
                                    function initMap() {
                                        const myLatLng = { lat: -8.636176573413225, lng: 117.23647409339307 };
                                        const map = new google.maps.Map(document.getElementById("map"), {
                                            zoom: 8,
                                            center: myLatLng,
                                            scrollwheel: true,
                                        });

                                        var latitude = {{ IlluminateSupportJs::from($latitude) }};
                                        var longitude = {{ IlluminateSupportJs::from($longitude) }};
                            
                                        const pos = { lat: latitude, lng: longitude };
                                        let marker = new google.maps.Marker({
                                            position: pos,
                                            map: map,
                                            draggable:true
                                        });
                                    
                                        google.maps.event.addListener(marker,'position_changed',
                                        function (){
                                            let lat = marker.position.lat()
                                            let lng = marker.position.lng()
                                            $('#latitude').val(lat)
                                            $('#longitude').val(lng)
                                        });
                                        }
                                    </script>

Get the DateTime of all Videos from a YouTuber

I want to do a fun project and calculate when a YouTuber is most likely to upload their next YouTube video based on previous releases and their release dates.

So I calculate how long the YouTuber needs on average between each upload, and then calculated when he will upload their next YouTube video.

But first I need all Date / Times from for example the last 50 videos of that specific YouTuber.
Currently I’m trying to do that with Python and the Google Cloud “YouTube Data API v3”.

I found a few lines of code online:

import os
import googleapiclient.discovery
from googleapiclient.errors import HttpError
from google.oauth2.credentials import Credentials

# Replace 'YOUR_API_KEY' with your API key or provide the path to your credentials file
api_key = 'YOUR_API_KEY'

# Create the API client
youtube = googleapiclient.discovery.build('youtube', 'v3', developerKey=api_key)

def get_channel_subscriber_count(channel_id):
    try:
        response = youtube.channels().list(part='statistics', id=channel_id).execute()
        channel = response['items'][0]
        subscriber_count = channel['statistics']['subscriberCount']
        print(f"Subscriber Count: {subscriber_count}")
    except HttpError as e:
        print(f"An error occurred: {e}")

# Replace 'CHANNEL_ID' with the ID of the specific YouTube channel
channel_id = 'CHANNEL_ID'
get_channel_subscriber_count(channel_id)

I replaced the API Key with mine, and changed the channel_id to the name of the YouTuber (youtube.com/@RemusNeo) so I replace it with “RemusNeo”.
However I always get the following error message:

Traceback (most recent call last): File
“C:UsersBaseultPycharmProjectspythonProjectmain.py”, line 23, in

get_channel_subscriber_count(channel_id) File “C:UsersBaseultPycharmProjectspythonProjectmain.py”, line 15, in
get_channel_subscriber_count
channel = response[‘items’][0] KeyError: ‘items’

If I use the same code and do it manually with each video using the following code, then it works fine:

def get_video_details(video_id):
    try:
        response = youtube.videos().list(part='snippet', id=video_id).execute()
        video = response['items'][0]
        title = video['snippet']['title']
        release_date = video['snippet']['publishedAt']
        print(f"Title: {title}")
        print(f"Release Date: {release_date}")
    except HttpError as e:
        print(f"An error occurred: {e}")

# Replace 'VIDEO_ID' with the ID of the specific YouTube video
video_id = 'VIDEO_ID'
get_video_details(video_id)

I tried a few other methods, for example get the Subscriber Count of that YouTuber but that also didn’t work. So I guess the code is outdated to access a YouTubers channel?

Would be awesome if someone could help me, thanks a lot 🙂

Pivot table pagination doesn’t work in laravel 8

I am doing an assignment for my study, here the code

Category Models

It have books method that pivot table Books and Categories

<?php

namespace AppModels;

use IlluminateDatabaseEloquentFactoriesHasFactory;
use IlluminateDatabaseEloquentModel;

class Category extends Model
{
    protected $fillable = [ 'name', 'slug', 'image', 'status' ];

    public function books()
    {
        return $this->belongsToMany(Book::class, 'book_category', 'category_id', 'book_id');
    }
}

Category Resource

<?php

namespace AppHttpResources;

use IlluminateHttpResourcesJsonJsonResource;

class Category extends JsonResource
{
    public function toArray($request)
    {
        $parent = parent::toArray($request);
        $data['books'] = $this->books()->paginate(6);
        $data = array_merge($parent, $data);
        return [
            'status' => 'succes',
            'message' => 'category data',
            'data' => $data
        ];
    }
}

Category Controller

<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;
use AppModelsCategory;
use AppHttpResourcesCategory as CategoryResource;

class CategoryController extends Controller
{
    public function slug($slug)
    {
        $criteria = Category::where('slug', $slug)->first();
        return new CategoryResource($criteria);
    }
}

Book Resource

<?php

namespace AppModels;

use IlluminateDatabaseEloquentFactoriesHasFactory;
use IlluminateDatabaseEloquentModel;

class Book extends Model
{
    protected $fillable = [
        'title', 'slug', 'description', 'author', 'publisher', 'cover',
        'price', 'weight', 'stock', 'status'
    ];
}

And here the result from postman

{
    "status": "succes",
    "message": "category data",
    "data": {
        "id": 7,
        "name": "debitis",
        "slug": "debitis",
        "image": "/xampp/htdocs/bookstore-api/public/images/categories\518c73c94a9f2ca6524c5c2ab8dc02ae.png",
        "status": "PUBLISH",
        "created_at": "2023-07-16T08:39:41.000000Z",
        "updated_at": null,
        "books": {
            "current_page": 1,
            "data": [],
            "first_page_url": "http://bookstore-api.test/v1/categories/slug/debitis?page=1",
            "from": null,
            "last_page": 1,
            "last_page_url": "http://bookstore-api.test/v1/categories/slug/debitis?page=1",
            "links": [
                {
                    "url": null,
                    "label": "&laquo; Previous",
                    "active": false
                },
                {
                    "url": "http://bookstore-api.test/v1/categories/slug/debitis?page=1",
                    "label": "1",
                    "active": true
                },
                {
                    "url": null,
                    "label": "Next &raquo;",
                    "active": false
                }
            ],
            "next_page_url": null,
            "path": "http://bookstore-api.test/v1/categories/slug/debitis",
            "per_page": 6,
            "prev_page_url": null,
            "to": null,
            "total": 0
        }
    }
}

The first time I run the script I got an SQL error because book_category table was not yet created, then after the table created, the result like the above
I expect books pagination based on category will be working

PHP : false OR false OR true == false?

I don’t understand what’s going on here in PHP.
I’ve spent hours on this until I understood that it doen’t work normally, or that I dont understand something.

Here the few lines :

$test = false OR false OR true;
echo $test;

Here $test is false, nothing is printed.
Also, if I try:

if($test){
    echo "IT'S TRUE";
}

Nothing is printed.

BUT HERE :

if(false OR false OR true){
    echo "IT'S TRUE";
}

“IT’S TRUE” is printed.

So the statement “false OR false OR true” is false when assigned to a variable, but true when is a condition.
Does anyone know and can explain to me why ?

Echo doesn’t work, cant figure out the reason… maybe missing smth [duplicate]

Hello I have 2 pages in PHP, in the first one is my HTML-code on second page PHP for that html, just tried to write a checking for $_FILES(whether it is empty or not) to add a text(missing files or to process next action in backend), but the echo in my HTML doesn’t work, maybe smth is not right so pls just check the code and mention the issues if possible, thanks in advance.

Here is the HTML.php code

                     <div class = "col-lg-6" id = "error">
                        <span>
                          <?php echo $error; ?>// (this echo doesnt work)
                        </span>
                     </div>

and here is my PHP.php code

 public function dashboard(){
        $this->view('admin/dashboard'); 
        $error = "";     //(to declare variable)
        if($_FILES['file']['name'] == ''){
            $error = "Please Upload The Picture";
        }
        //var_dump($_FILES);(no issues with connecting as var_dump works)
}

Value changing when assigned to variable

I am writting a programm to decode a binary file. I am currently in test phase and I use phpunit. I tried to assign a two byte value into a variable but the value changed without any apparent reason. I get 132 instead of 1.

The original bytes of the file are : 00 0F 00 01

Here is the code who decodes this part :

$infos = unpack('n2', fread($file, 4));
print_r($infos);
print($infos[2]);
$nb = $infos[2];
print(' nb '.$nb);

here is the result in the console :
Array
(
[1] => 15
[2] => 1
)
1 nb 132

The contents of $infos are completely fine, but I don’t understand why $nb takes the value 132.

Laravel StoreAs Returns FALSE and does not upload the image

I’m working with Laravel v10, and I wanted to upload a picture into the directory public/frontend/images/home, so at the Controller, I tried this:

public function submitHomeBoxes(Request $request)
{
    try {
        $pageImage = Page::where('pag_type', 'home');
        if ($request->hasFile('box_image_1')) {
            $boxImage = $request->file('box_image_1');
            $imageName = $boxImage->getClientOriginalName();
            $imagePath = $boxImage->storeAs('public/frontend/images/home');
            $pageImage->where('pag_name', 'box_image_1')->update(['pag_value' => $imageName]);
            dd($imagePath); // returns false
        }

        return redirect()->back()->withSuccess('Image Uploaded');
    } catch (Exception $e) {
        dd($e);
    }
}

But it does not upload the picture somehow, and dd($imagePath) returns false!

So what’s going wrong here? How can I solve this issue?


UPDATE:

I made some changes on the method to get the error, but still do not know what the error is:

try{
            $pageImage = Page::where('pag_type', 'home');
            if ($request->hasFile('box_image_1')) {
                $boxImage = $request->file('box_image_1');
                $imageName = $boxImage->getClientOriginalName();
                $imagePath = $boxImage->storeAs('public/frontend/images/home');
                if ($imagePath === false) {
                    $error = $boxImage->getError();
                    dd($error); //returns 0
        
                }
                $pageImage->where('pag_name', 'box_image_1')->update(['pag_value' => $imageName]);
                // dd($imagePath); return false
            }

        }catch (Exception $e) {
            dd($boxImage->getErrorMessage());
        }

Creating a server to count visitors

I need some help about servers.
I have a small site running now and I want to add some interaction with it.
The main idea is to create a counter of visiting the site, just for test.
I tried to create a simple php file:
<html> <body> <?php echo 'Hi!'; ?> </body> </html>
but when I try to visit the page on site, the file just downloads.
Then I tried to write to txt file from js(pure) and realized that there is no function for it.
I don’t want to use Node.js or something like this, because I just don’t understand how it works and I have no free hosting for it.

To be honest, I don’t understand how servers work.
I will be grateful for any explanations.

Get stored data from Timmy Fingerprint machine using php library

I’m currently using Timmy fingerprint machine for attendance system. When I trying to connect to Timmy fingerprint machine using zkteco php library, it’s getting an error saying

“socket_sendto(): Host lookup failed [11001]: No such host is known”.

Device Name: Timmy TM20 Fingerprint Machine.
I’ve used rats/zkteco laravel library (https://github.com/raihanafroz/zkteco) and used Ethernet to connect fingerprint machine with my laptop.

Is there any other ways that I can get all the data from fingerprint through PHP?

Selenium Grid can’t find Test Data

I got following Problem. The Selenium grid is running in a Docker Container and is connecting on a webserver which is also running in a Container. When running the tests, it seems like the webserver isn’t doing the same thing like when opening on my local computer. Do you know any reason this could have? i am getting following error “FacebookWebDriverExceptionTimeoutException : Must have more than one option in select”. The reason for this is, that the page is loading the content from the dropdown, which i want to select from, dynamicly. It seems like that there is the problem.

I tried mapping the data from the webserver to the selenium grid. I used curl out of the selenium container to check if there is any data in the dropdown, but there isn’t.