How to fix “Undefined Array Key ‘id’ Error” of the Dashboard Page (After Login)? [duplicate]

Can anyone help me how to fix the Undefined Array Key ‘id’ Error in Dashboard Page (Welcome Page) After Redirect from Login Page?
Thank You…

In Login Page:

<?php 
    session_start(); 
    if(isset($_POST['submit'])) { 
    extract($_POST); 
    include 'database.php'; 
    $sql = mysqli_query($conn,"SELECT * FROM registration where regno='$regno' and pass='$pass'"); 
    $row = mysqli_fetch_array($sql); 

    if(is_array($row)) { 
    if($_SESSION["captcha"] == $_POST["captcha"]) {

    $_SESSION["id"] = $row['id'];  
    header("Location: dashboard.php"); 

    } else {
    echo "Invalid CAPTCHA Code!";
    }} else {
    echo "Invalid Reg ID or Password!";
    }
    }
?>

Where $regno = Registration Number, $pass = Password & “captcha” = CAPTCHA Code

I’ve tried in Dashboard Page:

<?php
    session_start();
    include 'database.php';
    $id = $_SESSION["id"];
    $sql = mysqli_query($conn,"SELECT * FROM registration where id='$id'");
    $row = mysqli_fetch_array($sql);

    if(!isset($_SESSION['id'])){
    header("Location: login.php");
    exit();
    }
?>

It shows “Undefined Array Key ‘id’ Error” in dashboard.php
Any help?

How to Replace DOCX Placeholder with Formatted HTML in PHPWord

I’m using the PHPWord package in Laravel to replace placeholders in a DOCX template.

I have a placeholder ${html} in my DOCX file, and I’m trying to replace it with HTML content like:
<p>Hello,<br><br><strong>Welcome</strong></p>

Currently, PHPWord is inserting the raw HTML tags as text, but I want the content to be rendered with proper formatting (bold text, line breaks, etc.).

I’ve checked the PHPWord documentation but couldn’t find a clear solution for HTML parsing. Any suggestions or examples would be appreciated.

I am trying to understand how to upload a file to this code

I’m trying to make a little script for my home network but I don’t entirely understand how to use curl with the mytestupload.php script could someone maybe help explain how I can post my file to it and what I’m doing wrong here?

mytestupload.php below

<?php 

    function jss($data)
    {
        echo json_encode( $data );
    }

    $comm = $_POST['cmd'];

    if( !empty( $comm ) ){

        if( $comm == "test" ){

            jss(array(
                "code" => 200,
            ));

        }

        if( $comm == "mkdir" ){

            $tmp_dir = $_POST['dir'];

            mkdir( $tmp_dir );
            chmod( $tmp_dir , 0755 );

            jss(array(
                "code" => 200,
            ));

        }

        if( $comm == "upload" ){

            $post_file = $_POST['file'];
            $post_data = $_POST['data'];

            $post_data_enc = base64_decode( $post_data );

            file_put_contents( $post_file , $post_data_enc );
            chmod( $post_file , 0644 );

            jss(array(
                "code" => 200,
            ));

        }

    }

I thought this command would work but it seems I am missing something:

$ curl -F 'file=@/tmp/test.txt' -F 'cmd=upload' http://127.0.0.1/mytestupload.php
{"code":200}

It returned 200 but I don’t know why the file doesn’t upload

Can someone explain how to fix my curl command to work ? I was expecting a file to show up in my folder but I’m not getting something right.

Any help really appreciated!

Laravel Modular Monolith custom Exception Handler

Not sure if this can be done but worth a punt.

Brief explanation, we are adopting a modular monolith approach to our application development and everything is fine thus far. However, when implementing a custom exception handler for each of module this becomes quite tricky when attempting to register/inject this handler into Laravel similar to the way you would with the service providers.

File structure:

- Laravel
  - app
    - Exceptions
      - Handler.php
  - src
    - module 1
      - Http
        - Client.php
      - Exceptions
        - Handler.php
        - ExceptionOne.php
      - Tests
        - TestOne.php
    - module 2

My understanding is because Laravel’s error handler is a singleton this is going to be quite tricky…not possible.

I have tried extending Laravels handler and then call the register method in my modules service provider but this didn’t work.

There were some other methods not worth mentioning that didn’t work either.

Ideal solution would be:

class Handler 
{
    protected $registeredHandlers = [
        AppExceptions::class,
        ModularMonolithExceptionsHandler::class
    ];

    public function register(): void
    {
        foreach(this->registeredHandlers as $handler) {
            $handler->register();
        }
    }
}

Something along these lines where we can have multiple handlers where we can register the exceptions, this would still allow the singleton to be there but also, allows for separation of the exceptions from the main apps handler.

Installing PHP >8.0 on MacOS 11 (Homebrew)

I’m trying to install PHP version 8.4 (or any version above 8.0) on my MacBook, but each time I run into an error with curl or with MacOS 11.

I know MacOS 11 is outdated but it is the last version I am able to get on this Macbook (mid 2014, intel).

My process:

I started by just trying to install PHP v8.4 like this: brew install [email protected] which gave me the following error:

% brew install [email protected]

Warning: You are using macOS 11.
We (and Apple) do not provide support for this old version.

This is a Tier 3 configuration:
  https://docs.brew.sh/Support-Tiers#tier-3
Do not report any issues to Homebrew/* repositories!
Read the above document instead before opening any issues or PRs.

...............................
.. lots of package downloads ..
...............................

curl: (35) error:1400442E:SSL routines:CONNECT_CR_SRVR_HELLO:tlsv1 alert protocol version
Error: [email protected]: Failed to download resource "libsodium"
Download failed: https://download.libsodium.org/libsodium/releases/libsodium-1.0.20.tar.gz

Which (after looking on internet and asking AI) indicates outdated SSL certificates (don’t know if that is really the problem).

I tried multiple things like:

# Update Homebrew itself
brew update

# Update curl
brew install curl

# Update certificates
brew install ca-certificates

export PATH="/usr/local/bin:$PATH"

But that did not change anything.

Then I tried to use the shivammathur/homebrew-php tap which gave me the same error.

After looking on the internet for a while I found a GitHub discussion that gave me this solution:

export HOMEBREW_FORCE_BREWED_CURL=1
brew config   # check that the Curl: entry now points to Homebrew curl
brew install pure-ftpd

This seemed to work when I tried to install PHP again because running: brew install shivammathur/php/[email protected] again it installed packages it could not before.

But after almost an hour of downloading it gave me this error:

==> python3.13 -m venv --system-site-packages --without-pip /usr/local/Cellar/asciidoc/10.2.1/libexec
==> python3.13 -m pip --python=/usr/local/Cellar/asciidoc/10.2.1/libexec/bin/python install /private/tmp/asciidoc-20250616-5971-avx3y
Last 15 lines from /Users/stagair/Library/Logs/Homebrew/asciidoc/02.python3.13:
2025-06-16 09:05:44 +0000

python3.13
-m
pip
--python=/usr/local/Cellar/asciidoc/10.2.1/libexec/bin/python
install
--verbose
--no-deps
--no-binary=:all:
--ignore-installed
--no-compile
/private/tmp/asciidoc-20250616-5971-avx3y6/asciidoc-10.2.1

/usr/local/opt/[email protected]/bin/python3.13: No module named pip.__main__; 'pip' is a package and cannot be directly executed



Error: You are using macOS 11.
We (and Apple) do not provide support for this old version.

This is a Tier 3 configuration:
  https://docs.brew.sh/Support-Tiers#tier-3
Do not report any issues to Homebrew/* repositories!
Read the above document instead before opening any issues or PRs.

This build failure was expected, as this is not a Tier 1 configuration:
  https://docs.brew.sh/Support-Tiers
Do not report any issues to Homebrew/* repositories!
Read the above document instead before opening any issues or PRs.

Is it at all possible to install PHP 8 on my MacBook?

PHP using JSON string and inserting Data to URL [closed]

I have a php script that runs a API URL as below. Some of the information in the URL should be populated by echo information. Here is my current code.

$imei = $_POST['imei'];
$email = $_POST['email'];

$ch = curl_init("etrackfleet.com/api/api.php?api=server&key=256431&cmd=ADD_USER_OBJECT,<?php echo $email; ?>,<?php echo $imei; ?>");

curl_exec($ch);

Once I run the php file I get error Your browser sent a request that this server could not understand.

I presume the echo statement is not being read by the php request?

If I echo the $imei on the same page it shows the value from the POST but not in URL

getting unauthenticated error in phonepe refund api

i am getting problem of getting unauthenticated in the phonepe refund api. also i am using that token in the payment time it’s working fine.

$data = $this->getAuthKey();

    $payment = Payment::where('id', $paymentId)->first();
    $token = $data['access_token'];
    // $token = $payment->auth_key;
    $url = 'https://api.phonepe.com/apis/pg/payments/v2/refund';
    $amount = $payment->amount * 100;
    $refund_id = 'REF' . $paymentId . uniqid();
    $order_id = $payment->transaction_id;

    $payload = [
        "merchantRefundId" => $refund_id,
        "originalMerchantOrderId" => $order_id,
        "amount" => $amount, 
    ];

    $response = Http::withHeaders([
        'Content-Type' => 'application/json',
        'Authorization' => 'O-Bearer ' . $token,
    ])->post($url, $payload);

    $response = $response->json();

    return $response;

Upload multiple images related to hasMany() entity in same create form using BackPack and Laravel 11

I’m building an admin panel using Laravel 11 and Backpack PRO 6.x (Tabler theme).

I have two models with a one-to-many relationship:

ProdutoVariacao (main entity)

ProdutoVariacaoImagem (child entity)

The relationship is as follows:

One ProdutoVariacao has many ProdutoVariacaoImagem (hasMany)

Each ProdutoVariacaoImagem belongs to one ProdutoVariacao (belongsTo)

My goal is to allow users to create a new ProdutoVariacao entry and upload multiple images within the same create form. Each uploaded image should:

Be physically stored on disk (e.g. storage/app/…).

Automatically create a record in the produto_variacao_imagens table, properly linked to the ProdutoVariacao via foreign key.

The database and models are fully set up with the correct relationships.

What I’m looking for:

What is the recommended way to implement this kind of nested form behavior in Backpack PRO 6.x?

Should I use Backpack’s repeatable fields? Or relationship fields? Or handle everything manually inside store() and update() methods?

How can I properly store both the main entity and the related images together in the same request?

Any concrete example, best practice, or recommended Backpack approach would be greatly appreciated.

I’ve already tried several approaches, but none fully solved the problem. The closest I got was being able to store the correct file path in the database, but I couldn’t manage to actually store the image physically inside /storage.

Thank you in advance!

Site domain tranformed as additional URL parameter

I have the same web infrastructure for different sites. In my reality different sites are representation of different content from different databases on the same web infrastructure but I want to keep it hidden from users.

I want that domain name is transferred as additional parameter site in my URL but this has to be hidden from users. For example one domain URL http://www.domain1.com should be transferred into http://www.maindomain.com/?site=domain1, other domain http://www.domain2.com into http://www.maindomain.com/?site=domain2.

Other URL parameters should be preserved as well. For example: http://www.domain3.com/index.php?param1=100&param2=200 should be transferred into http://www.maindomain.com/index.php?site=domain3&param1=100&param2=200

All this should be hidden from user – user should only see:

http://www.domain3.com/index.php?param1=100&param2=200

but in background the following should be processed:

http://www.maindomain.com/index.php?site=domain3&param1=100&param2=200

How to achieve this?

Laravel returns 404 when deployed to public_html subdirectory (`~username` path)

As the final task of my university practice, we need to deploy our Laravel project to the university server.

When I SSH into the machine, I land in my home directory, which only contains a public_html directory (and this root directory is not writable). I’ve placed all the Laravel files inside that directory, so the structure looks like this:

public_html
|- .env
|- .htaccess
|- app
|- bootstrap
|- composer.json
|- public
|- resources
|- routes
|- storage
|- vendor

Since there’s no index.php directly inside public_html, I added a .htaccess file to redirect everything to public/index.php:

RewriteEngine On
RewriteRule ^$ public/index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ public/index.php [L]

With this setup, I’m able to access Laravel by visiting:
https://<university domain>/~dramosac

However, Laravel treats ~dramosac as part of the requested route, which doesn’t exist, so it returns a 404 error.

To debug this, I updated the 404 page to show some request details:

<pre>
Requested URL: {{ request()->fullUrl() }}
Internal path (request()->path()): {{ request()->path() }}
APP_URL: {{ config('app.url') }}
Current route name: {{ Route::currentRouteName() ?? 'None' }}
Current controller: {{ optional(Route::getCurrentRoute())->getActionName() }}
Authenticated?: {{ Auth::check() ? 'Yes' : 'No' }}
HTTP Method: {{ request()->method() }}
</pre>

The output is:

Requested URL: https://<university domain>/~dramosac
Internal path (request()->path()): ~dramosac
APP_URL: https://<university domain>/~dramosac
Current route name: None
Current controller: 
Authenticated?: No
HTTP Method: GET

As you can see, Laravel thinks ~dramosac is the internal path, even though I set the correct APP_URL in the .env file.

Question:
Why does Laravel still treat ~dramosac as part of the route, even though APP_URL is set correctly? How can I configure Laravel to serve the correct routes from this subdirectory?

Thanks in advance!

Most efficient way to handle large-scale array processing in PHP 8.3 without memory exhaustion? [closed]

I’m working with large datasets (100K+ rows from MySQL) in PHP 8.3 and need to optimize memory usage. I’ve experimented with generators using yield, SplFixedArray, and processing data in chunks with array_chunk, but I’m wondering if PHP 8.3’s JIT compiler or other new features offer better solutions.

Specifically, I’d like to know if there are any measurable improvements in memory efficiency when using foreach versus array_reduce for large datasets in PHP 8.3. Does the JIT compiler help reduce memory overhead for data processing tasks? Are there any new PHP 8.3 features specifically designed for handling large datasets more efficiently?

I’m particularly interested in answers supported by benchmarks, official PHP documentation, or detailed profiling results that demonstrate memory usage differences between approaches in PHP 8.3.

How do I implement pagination support in laravel-seo-sitemap?

I’m using the laravel-seo-sitemap package to generate sitemap XML files in a Laravel 10 application.

I have a paginated blog route like this:

Route::prefix('/blog')->group(function () {
    Route::get('/', [BlogController::class, 'index'])
        ->name('support.blog.index')
        ->priority('0.6')
        ->sitemap();
});

This correctly adds /blog to the sitemap, but I also want to include paginated versions like /blog?page=2, /blog?page=3, etc., since those contain unique and crawlable content (e.g. paginated archive listings).

How can I configure the package to generate sitemap entries for each page of the pagination?

Ideally, I’d like to specify:

  • The total number of pages dynamically (from a model or query)
  • The route pattern to apply pagination (/blog?page=2, /blog?page=3, …)

Is there a way to extend the sitemap generator with a custom SitemapItemTemplate or hook into the route’s sitemap registration?

Any example or guidance would be appreciated.

https://github.com/VeiligLanceren-nl/laravel-seo-sitemap

I already did try to use the template but it didn’t work out as wished.
I was expecting that this will solve the issue but it not worked out

Combine multiple rows in from and to columns into one

I have two tables

table1

id    from     to
02    900      990
01    1005     1030
02    2190     3050
03    4150     4200

table2

id    from     to
01    1005     1030
02    2190     3000
02    3001     3050
03    4150     4175

What I am trying to do is for each row in table1, I want to check if it exists in table2 even if its in multiple rows in table2 but continuous.

In the above example for id 01 in table1 its easy to get id 01 in table2 as from and to are same. I got that.

But I also want for id 02 (the third row, not the first one). All from and to for id 02 in table1 are there in table2 but as they are in multiple rows I can’t get them.

Id 03 will not come as its not complete in table2

table1 can have multiple rows with same id but from and to range will be different and there will never be an overlap.

table2 can have the same id of table1 distributed in more than 2 rows also.

I am fetching rows from table1 and trying to find the from and to range in table2 so I have all the fields of the particular row from tabe1 in an array.

What I am expecting is just exists yes/no.

I am using PHP/ORACLE.

Any leads would be appreciated.

Thanks.

Below is the small working snippet if from and to are single row in table1 and table2.

$or1 = oci_parse($o_con, "select * from table1");
oci_execute($or1);
$count_1 = oci_fetch_all ($or1, $ow1 , 0, -1, OCI_FETCHSTATEMENT_BY_ROW);

for ($i = 0; $i < $count_1; $i++)
{
    $id = $or1[$i]['ID'];
    $begin = $or1[$i]['FROM'];
    $end = $or1[$i]['TO'];
    $or2= oci_parse($o_con, "select * from table2 where from = $begin and to = $end and id= '$id'");
    oci_execute($or2);
    $count_2 = oci_fetch_all ($or2, $ow2 , 0, -1, OCI_FETCHSTATEMENT_BY_ROW);
    if ($count_2 == 0 ) { $color="red";} else { $color="green"; }
}

cURL error 23 when downloading nativephp/mobile in Laravel

I’m trying to install the nativephp/mobile package in my Laravel project using Composer, but I keep getting a cURL error 23. Here’s the command I’m running

composer require nativephp/mobile --ignore-platform-req=ext-zip

I’m using the –ignore-platform-req=ext-zip flag because I don’t have the ZIP extension installed (could this be related?)
I also tried Clearing Composer cache but still not working.