Getting error “Call to undefined function catchException()” in php chunk of code

I am making a class in php whose definition is given below.

    // A PHP class to log every exception on bugsnag account.
    // All classes that make 3rd party request must extend this class

    // importing all the dependencies
    require_once realpath('bugsnag.phar');
    require_once realpath('guzzle.phar');
    require_once realpath('vendor/autoload.php');

    class BugSnagLogger {
        private $bugsnag;
        private $bugSnagAPIKey;

        // Initializing the BugSnag Instance in the constructor itself.
        public function __construct($bugSnagAPIKey) {
            $this->bugSnagAPIKey = $bugSnagAPIKey;
            $this->$bugsnag = BugsnagClient::make($this->bugSnagAPIKey);

        // Method to catchExceptions.
        public function catchException(Exception $exception) {

    $logger = new BugSnagLogger('a7ce9f54025c3873c34775e8a7001e6e');
    $logger.catchException(new Exception('Custom Exception by Sparsh.'));

On Executing the above code I am getting the error Call to undefined function catchException(). I don’t know what I am doing wrong in this case, can someone please help me with this ?.

permission denied on laravel.log file laravel 9 using Docker

I installed laravel using composer inside of my docker container, however, i get this error when i try to access the index page

The stream or file "/var/www/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log:

I am using laravel 9, i have tried all possible solution i could find and it doesn’t work.
I run on windows 10.

Here is my Dockerfile

FROM php:8.0.2-fpm

# Install dependencies for the operating system software
RUN apt-get update && apt-get install -y 

# Install extensions for php
RUN docker-php-ext-install pdo_mysql

# Install composer (php package manager)
RUN curl -sS | php -- --install-dir=/usr/local/bin --filename=composer

# Set working directory
WORKDIR /var/www

I have adding the below code to my Dockerfile

# Assign permissions of the working directory to the www-data user
RUN chown -R www-data:www-data 

but when try to build the image again with the code in it, i get an error message saying

directory doesn’t exist

Here is my docker-compose.yml file

version: '3.8'

      context: ./
      dockerfile: Dockerfile
    container_name: jaynesis-php
    restart: always
    working_dir: /var/www
      - ../src:/var/www
    image: nginx:latest
    container_name: jaynesis-nginx
    restart: always
      - "8000:80"
      - ../src:/var/www
      - ./nginx:/etc/nginx/conf.d
    container_name: jaynesis-db
    image: mysql:8.0
      - ./storage/mysql:/var/lib/mysql
    restart: always
      - 3306:3306

XAMPP VM is not opening on MacOS 13 beta (Ventura)

I have updated to MacOS 13 Ventura and after that XAMPP VM app is not opening at all. I have tried several solutions for problems associated with XAMPP crash on previous MacOS versions (e.g. Updating bitnami hyperkit) but XAMPP VM still doesn’t work. Also I tried to reinstall XAMPP, but even XAMPP VM installer in not opening as the XAMPP VM app itself.

Console app report:

Translated Report (Full Report Below)

Process:               stackman [9276]
Path:                  /Applications/
Identifier:            stackman
Version:               ???
Code Type:             X86-64 (Native)
Parent Process:        Exited process [9271]
User ID:               501

Date/Time:             2022-06-25 14:24:40.2887 +0500
OS Version:            macOS 13.0 (22A5286j)
Report Version:        12
Bridge OS Version:     7.0 (20P50320f)
Anonymous UUID:        E41A4C2D-3B98-3F27-492A-3E5FECB194E1

Time Awake Since Boot: 9900 seconds

System Integrity Protection: enabled

Crashed Thread:        4

Exception Type:        EXC_GUARD (SIGKILL)
Exception Codes:       GUARD_TYPE_MACH_PORT
Exception Codes:       0x0000000000000d5a, 0x0000000000000000

Termination Reason:    Namespace GUARD, Code 2305843022098599258 

Thread 0::  Dispatch queue:
0   libsystem_pthread.dylib             0x7ff806b391ce _pthread_create + 586
1   stackman                                 0x44b9a82 _cgo_try_pthread_create + 66 (gcc_libinit.c:100)
2   stackman                                 0x44b98d6 _cgo_sys_thread_start + 118 (gcc_darwin_amd64.c:98)
3   stackman                                 0x4058d1d runtime.asmcgocall + 173 (asm_amd64.s:718)
4   stackman                                 0x4033589 runtime.newm + 153 (proc.go:1853)
5   stackman                                 0x4033c28 runtime.startm + 312 (proc.go:1997)
6   stackman                                 0x4033d75 runtime.handoffp + 85 (proc.go:2024)
7   stackman                                 0x4034191 runtime.stoplockedm + 257 (proc.go:2092)
8   stackman                                 0x403588a runtime.schedule + 730 (proc.go:2488)
9   stackman                                 0x4035a16 runtime.park_m + 182 (proc.go:2599)
10  stackman                                 0x405746b runtime.mcall + 91 (asm_amd64.s:351)

Thread 1:
0   libsystem_pthread.dylib             0x7ff806b33ecc start_wqthread + 0

Thread 2:
0   libsystem_pthread.dylib             0x7ff806b33ecc start_wqthread + 0

Thread 3:
0   stackman                                 0x405b455 runtime.usleep + 69 (sys_darwin_amd64.s:418)
1   stackman                                 0x40399f3 runtime.sysmon + 211 (proc.go:4216)
2   ???                               0x7469622d343620 ???

Thread 4 Crashed:
0   stackman                                 0x405b56a runtime.mach_msg_trap + 42 (sys_darwin_amd64.s:510)
1   stackman                                 0x402bdc9 runtime.machcall + 137 (os_darwin.go:279)
2   stackman                                 0x402bf22 runtime.mach_semcreate + 162 (os_darwin.go:374)
3   stackman                                 0x405593b runtime.semacreate.func1 + 43 (os_darwin.go:45)
4   stackman                                 0x402b556 runtime.semacreate + 70 (os_darwin.go:44)
5   stackman                                 0x40134e2 runtime.lock + 114 (lock_sema.go:46)
6   stackman                                 0x4033b21 runtime.startm + 49 (proc.go:1974)
7   stackman                                 0x4034068 runtime.wakep + 72 (proc.go:2078)
8   stackman                                 0x40353d1 runtime.resetspinning + 113 (proc.go:2449)
9   stackman                                 0x40356d5 runtime.schedule + 293 (proc.go:2543)
10  stackman                                 0x403252e runtime.mstart1 + 158 (proc.go:1232)
11  stackman                                 0x4032476 runtime.mstart + 118 (proc.go:1188)
12  stackman                                 0x44b9c9d crosscall_amd64 + 12 (gcc_amd64.S:35)
13  libsystem_pthread.dylib             0x7ff806b384d1 _pthread_start + 125
14  libsystem_pthread.dylib             0x7ff806b33eef thread_start + 15

Thread 4 crashed with X86 Thread State (64-bit):
  rax: 0x000000000000002e  rbx: 0x0000000000000100  rcx: 0x000070000f33dc20  rdx: 0x0000000000000028
  rdi: 0x000070000f33dcc8  rsi: 0x0000000000000003  rbp: 0x000070000f33dc58  rsp: 0x000070000f33dc20
   r8: 0x0000000000001d03   r9: 0x0000000000000000  r10: 0x0000000000000100  r11: 0x0000000000000206
  r12: 0x0000000000000000  r13: 0x0000000000000000  r14: 0x0000000004032400  r15: 0x0000000000000000
  rip: 0x000000000405b56a  rfl: 0x0000000000000206  cr2: 0x00000000049a1948
Logical CPU:     0
Error Code:      0x0100001f 
Trap Number:     133

Binary Images:
    0x7ff806b32000 -     0x7ff806b3dff7 libsystem_pthread.dylib (*) <840e0b9f-85dc-392d-b3b1-3d1dbbd68c5d> /usr/lib/system/libsystem_pthread.dylib
         0x4000000 -          0x49a2fff stackman (*) <06c5a0bd-e3f8-3c99-8b48-01bd427e156a> /Applications/
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=398.2M resident=0K(0%) swapped_out_or_unallocated=398.2M(100%)
Writable regions: Total=561.8M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=561.8M(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Activity Tracing                   256K        1 
Kernel Alloc Once                    8K        1 
MALLOC                           165.2M       18 
MALLOC guard page                   24K        5 
MALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)
STACK GUARD                       56.0M        5 
Stack                             10.5M        6 
Stack Guard                          4K        1 
VM_ALLOCATE                      528.5G        9 
__DATA                            15.2M      276 
__DATA_CONST                      13.1M      172 
__DATA_DIRTY                       625K       97 
__FONT_DATA                        2352        1 
__LINKEDIT                       167.4M        5 
__OBJC_RO                         64.1M        1 
__OBJC_RW                         1965K        2 
__TEXT                           230.8M      297 
dyld private memory                512K        2 
mapped file                       29.1M        3 
shared memory                       72K        7 
===========                     =======  ======= 
TOTAL                            529.6G      910 
TOTAL, minus reserved VM space   529.2G      910 

Full Report

{"app_name":"stackman","timestamp":"2022-06-25 14:24:40.00 +0500","app_version":"","slice_uuid":"06c5a0bd-e3f8-3c99-8b48-01bd427e156a","build_version":"","platform":1,"share_with_app_devs":1,"is_first_party":1,"bug_type":"309","os_version":"macOS 13.0 (22A5286j)","roots_installed":0,"incident_id":"60060CF6-9765-4AF9-9013-F7A265545B8B","name":"stackman"}
  "uptime" : 9900,
  "procRole" : "Unspecified",
  "version" : 2,
  "userID" : 501,
  "deployVersion" : 210,
  "modelCode" : "Macmini8,1",
  "coalitionID" : 1516,
  "osVersion" : {
    "train" : "macOS 13.0",
    "build" : "22A5286j",
    "releaseType" : "User"
  "captureTime" : "2022-06-25 14:24:40.2887 +0500",
  "incident" : "60060CF6-9765-4AF9-9013-F7A265545B8B",
  "pid" : 9276,
  "cpuType" : "X86-64",
  "roots_installed" : 0,
  "bug_type" : "309",
  "procLaunch" : "2022-06-25 14:24:40.2662 +0500",
  "procStartAbsTime" : 9978992971986,
  "procExitAbsTime" : 9979015264514,
  "procName" : "stackman",
  "procPath" : "/Applications/",
  "parentProc" : "Exited process",
  "parentPid" : 9271,
  "coalitionName" : "com.bitnami.stackman",
  "crashReporterKey" : "E41A4C2D-3B98-3F27-492A-3E5FECB194E1",
  "responsiblePid" : 9271,
  "bridgeVersion" : {"build":"20P50320f","train":"7.0"},
  "sip" : "enabled",
  "exception" : {"port":3418,"signal":"SIGKILL","guardId":0,"codes":"0x0000000000000d5a, 0x0000000000000000","violations":["INVALID_OPTIONS"],"message":"mach_msg_trap() called with msgh_id 3418. The trap is not allowed on this platform.","subtype":"GUARD_TYPE_MACH_PORT","type":"EXC_GUARD","rawCodes":[3418,0]},
  "termination" : {"namespace":"GUARD","flags":2,"code":2305843022098599258},
  "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
  "faultingThread" : 4,
  "threads" : [{"id":138818,"queue":"","frames":[{"imageOffset":29134,"symbol":"_pthread_create","symbolLocation":586,"imageIndex":0},{"imageOffset":4954754,"sourceLine":100,"sourceFile":"gcc_libinit.c","symbol":"_cgo_try_pthread_create","imageIndex":1,"symbolLocation":66},{"imageOffset":4954326,"sourceLine":98,"sourceFile":"gcc_darwin_amd64.c","symbol":"_cgo_sys_thread_start","imageIndex":1,"symbolLocation":118},{"imageOffset":363805,"sourceLine":718,"sourceFile":"asm_amd64.s","symbol":"runtime.asmcgocall","imageIndex":1,"symbolLocation":173},{"imageOffset":210313,"sourceLine":1853,"sourceFile":"proc.go","symbol":"runtime.newm","imageIndex":1,"symbolLocation":153},{"imageOffset":212008,"sourceLine":1997,"sourceFile":"proc.go","symbol":"runtime.startm","imageIndex":1,"symbolLocation":312},{"imageOffset":212341,"sourceLine":2024,"sourceFile":"proc.go","symbol":"runtime.handoffp","imageIndex":1,"symbolLocation":85},{"imageOffset":213393,"sourceLine":2092,"sourceFile":"proc.go","symbol":"runtime.stoplockedm","imageIndex":1,"symbolLocation":257},{"imageOffset":219274,"sourceLine":2488,"sourceFile":"proc.go","symbol":"runtime.schedule","imageIndex":1,"symbolLocation":730},{"imageOffset":219670,"sourceLine":2599,"sourceFile":"proc.go","symbol":"runtime.park_m","imageIndex":1,"symbolLocation":182},{"imageOffset":357483,"sourceLine":351,"sourceFile":"asm_amd64.s","symbol":"runtime.mcall","imageIndex":1,"symbolLocation":91}]},{"id":138819,"frames":[{"imageOffset":7884,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":0}]},{"id":138820,"frames":[{"imageOffset":7884,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":0}]},{"id":138821,"frames":[{"imageOffset":373845,"sourceLine":418,"sourceFile":"sys_darwin_amd64.s","symbol":"runtime.usleep","imageIndex":1,"symbolLocation":69},{"imageOffset":236019,"sourceLine":4216,"sourceFile":"proc.go","symbol":"runtime.sysmon","imageIndex":1,"symbolLocation":211},{"imageOffset":32766967684544032,"imageIndex":2}]},{"triggered":true,"id":138822,"threadState":{"r13":{"value":0},"rax":{"value":46},"rflags":{"value":518},"cpu":{"value":0},"r14":{"sourceLine":1170,"value":67314688,"sourceFile":"proc.go","symbol":"runtime.mstart","symbolLocation":0},"rsi":{"value":3},"r8":{"value":7427},"cr2":{"value":77207880},"rdx":{"value":40},"r10":{"value":256},"r9":{"value":0},"r15":{"value":0},"rbx":{"value":256},"trap":{"value":133},"err":{"value":16777247},"r11":{"value":518},"rip":{"value":67482986,"matchesCrashFrame":1},"rbp":{"value":123145557367896},"rsp":{"value":123145557367840},"r12":{"value":0},"rcx":{"value":123145557367840},"flavor":"x86_THREAD_STATE","rdi":{"value":123145557368008}},"frames":[{"imageOffset":374122,"sourceLine":510,"sourceFile":"sys_darwin_amd64.s","symbol":"runtime.mach_msg_trap","imageIndex":1,"symbolLocation":42},{"imageOffset":179657,"sourceLine":279,"sourceFile":"os_darwin.go","symbol":"runtime.machcall","imageIndex":1,"symbolLocation":137},{"imageOffset":180002,"sourceLine":374,"sourceFile":"os_darwin.go","symbol":"runtime.mach_semcreate","imageIndex":1,"symbolLocation":162},{"imageOffset":350523,"sourceLine":45,"sourceFile":"os_darwin.go","symbol":"runtime.semacreate.func1","imageIndex":1,"symbolLocation":43},{"imageOffset":177494,"sourceLine":44,"sourceFile":"os_darwin.go","symbol":"runtime.semacreate","imageIndex":1,"symbolLocation":70},{"imageOffset":79074,"sourceLine":46,"sourceFile":"lock_sema.go","symbol":"runtime.lock","imageIndex":1,"symbolLocation":114},{"imageOffset":211745,"sourceLine":1974,"sourceFile":"proc.go","symbol":"runtime.startm","imageIndex":1,"symbolLocation":49},{"imageOffset":213096,"sourceLine":2078,"sourceFile":"proc.go","symbol":"runtime.wakep","imageIndex":1,"symbolLocation":72},{"imageOffset":218065,"sourceLine":2449,"sourceFile":"proc.go","symbol":"runtime.resetspinning","imageIndex":1,"symbolLocation":113},{"imageOffset":218837,"sourceLine":2543,"sourceFile":"proc.go","symbol":"runtime.schedule","imageIndex":1,"symbolLocation":293},{"imageOffset":206126,"sourceLine":1232,"sourceFile":"proc.go","symbol":"runtime.mstart1","imageIndex":1,"symbolLocation":158},{"imageOffset":205942,"sourceLine":1188,"sourceFile":"proc.go","symbol":"runtime.mstart","imageIndex":1,"symbolLocation":118},{"imageOffset":4955293,"sourceLine":35,"sourceFile":"gcc_amd64.S","symbol":"crosscall_amd64","imageIndex":1,"symbolLocation":12},{"imageOffset":25809,"symbol":"_pthread_start","symbolLocation":125,"imageIndex":0},{"imageOffset":7919,"symbol":"thread_start","symbolLocation":15,"imageIndex":0}]}],
  "usedImages" : [
    "source" : "P",
    "arch" : "x86_64",
    "base" : 140703241019392,
    "size" : 49144,
    "uuid" : "840e0b9f-85dc-392d-b3b1-3d1dbbd68c5d",
    "path" : "/usr/lib/system/libsystem_pthread.dylib",
    "name" : "libsystem_pthread.dylib"
    "source" : "P",
    "arch" : "x86_64",
    "base" : 67108864,
    "size" : 10104832,
    "uuid" : "06c5a0bd-e3f8-3c99-8b48-01bd427e156a",
    "path" : "/Applications/",
    "name" : "stackman"
    "size" : 0,
    "source" : "A",
    "base" : 0,
    "uuid" : "00000000-0000-0000-0000-000000000000"
  "sharedCache" : {
  "base" : 140703237689344,
  "size" : 19473252352,
  "uuid" : "91e491f1-9bed-38cf-a767-49e103932dd5"
  "vmSummary" : "ReadOnly portion of Libraries: Total=398.2M resident=0K(0%) swapped_out_or_unallocated=398.2M(100%)nWritable regions: Total=561.8M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=561.8M(100%)nn                                VIRTUAL   REGION nREGION TYPE                        SIZE    COUNT (non-coalesced) n===========                     =======  ======= nActivity Tracing                   256K        1 nKernel Alloc Once                    8K        1 nMALLOC                           165.2M       18 nMALLOC guard page                   24K        5 nMALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)nSTACK GUARD                       56.0M        5 nStack                             10.5M        6 nStack Guard                          4K        1 nVM_ALLOCATE                      528.5G        9 n__DATA                            15.2M      276 n__DATA_CONST                      13.1M      172 n__DATA_DIRTY                       625K       97 n__FONT_DATA                        2352        1 n__LINKEDIT                       167.4M        5 n__OBJC_RO                         64.1M        1 n__OBJC_RW                         1965K        2 n__TEXT                           230.8M      297 ndyld private memory                512K        2 nmapped file                       29.1M        3 nshared memory                       72K        7 n===========                     =======  ======= nTOTAL                            529.6G      910 nTOTAL, minus reserved VM space   529.2G      910 n",
  "legacyInfo" : {
  "threadTriggered" : {

  "trialInfo" : {
  "rollouts" : [
      "rolloutId" : "61fd92db295c182621ececc3",
      "factorPackIds" : {
        "SIRI_DIALOG_ASSETS" : "62a62539b6983a616949a0f1"
      "deploymentId" : 250000076
      "rolloutId" : "5ffde50ce2aacd000d47a95f",
      "factorPackIds" : {

      "deploymentId" : 250000156
  "experiments" : [


Now I using regular XAMPP and I recovered data from VM files using qcow2 mount tools, BUT there some damaged projects and this is the reason I want to actually fix the XAMPP VM on MacOS 13 Ventura.

best way to save money transaction table in mysql [closed]

hey guys I’m going to create a tourism agency management system. the customers can ask for changes to the programs that they get from the agency so the total amount can be changed and all the tour, rent car, hotel prices ( all this has different tables and has its own price all of These prices are summed up and the sum saved in financial_transaction table ) so what the data that have to be saved in financial_transaction and what the best way to handle and display all of these changes

I need advice on structuring the table (the best way to do it)

Laravel 8.x Is there any way to bind CustomLogger using monolog with DateTimeZone set via Service Providers

I’d like to override all of Laravel logger’s dateTimeZone to ‘Asia/Tokyo’, but not changing config/app.php => timezone.

Laravel comes with monolog library by default, and basically IlluminateLogLogManager is doing all the work to instantiate MonologLogger objects.

We can pass DateTimeZone object to MonologLogger constructor’s 4th argument, but there is no way we can pass that to LogManager via config/logging.php or anything.

I know that there’s a way to create custom logger object with full control and register to custom channel.

One way is that I’ll create & use AppLoggingCreateCustomLoggerWithTokyoTimeZone::class and modify all of the default existing channels.

The other way is that I’ll somehow override LogManager and bind it to service container ‘s log service. (override log service, but it’s a singleton)

Any good ideas? Anything is appreciated.

WordPress PHP Contact form – problem with displaying message about sent mail

I’m trying to develop a contact form for a language school website that runs on WordPress.
Disclaimer: I’m about 6 months into coding, so please forgive me for being new to this. I’m developing my own theme and I wanted to limit usage of plugins to bare minimum for safety reasons – I prefer to learn how to write stuff myself instead on relying on updates of a third-party plus the courses I follow on WordPress dev listed it as a good practice to avoid unnecessary plugins.
Update: I tried implementing plugins, but they either broke my page or didn’t work anyway.

The problem is listed below in bold.

What I want to achieve:

  1. Simple contact form that takes following info: name, email, course, phone (optional) and a message.
  2. Validate the form if user provided correct info – I can’t make the
    user provide valid info, but at least I want to lock number into
    numbers only range and check if email is correct.
  3. Check if user is human (Captcha).
  4. Send the email to my address and provide a copy to the sender.
  5. Inform the user whether the action was a success or a failure.

What I succeeded with:

  • Mail gets sent.
  • Captacha seems to be working and filtering out attempts that do not click on it.

What ‘kinda works’:

  • The PHP doesn’t seem to validate the form. I used HTML type and require instead, but I’ve read that solution is not ideal. I tried to use JS to write some functions that would prevent unwanted input, but I couldn’t get it to work properly. I decided to ask the question first in case it might be a dead end. JS seems to be working on my WordPress as I’m using Bootstrap and some custom JS for certain features so I’m pretty sure the code gets executed, but I wanted to ask first if that’s the correct way of approach it before I invest my time in it.

What I have a problem with:

It is imperative to me that the user gets feedback from the page whether the email has been sent or not for obvious business-client communication reasons. I tried two solutions found on SO:

  • Injecting JS alert into PHP’s echo inside conditional (JS doesn’t get executed)
  • Using header method to redirect into that informs about success or that
    informs about a failure and recommends another avenue of contact

What went wrong: the second solution got executed properly, the user gets redirected to or, however the browser crashes due to ‘too many redirects’.

I tried googling, I tried different solutions from tutorials. What would be your recommendation?

My code:

$nameErr = $emailErr = $courseErr = $phoneErr = "";
$name = $email = $course = $comment = $phone = "";
$thank_you = wp_redirect( '"'.home_url().'/thank-you"', 301 );
$error = wp_redirect( '"'.home_url().'/error', 301 );

    if (empty($_POST["name"])) {
      $nameErr = "Give name";
    } else {
      $name = test_input($_POST["name"]);
      // check if name only contains letters and whitespace
      if (!preg_match("/^[a-zA-Z-' ]*$/",$name)) {
        $nameErr = "Only letters allowed";
    if (empty($_POST["email"])) {
      $emailErr = "Need email";
    } else {
      $email = test_input($_POST["email"]);
      // check if e-mail address is well-formed
      if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
        $emailErr = "Email incorrect";
if (empty($_POST["phone"])) {
  $phone = "";
} else {
  $phone = test_input($_POST["phone"]);
  // check if URL address syntax is valid (this regular expression also allows dashes in the URL)
  if (!is_numeric($number)) {
    $phoneErr = "Bad number";

if (empty($_POST["comment"])) {
  $comment = "";
} else {
  $comment = test_input($_POST["comment"]);

if (empty($_POST["course"])) {
  $courseErr = "Pick course";
} else {
  $course = test_input($_POST["course"]);
 function test_input($data) {
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    return $data;
          $secret = 'mySecretKey';
          $verifyResponse = file_get_contents(''.$secret.'&response='.$_POST['g-recaptcha-response']);
          $responseData = json_decode($verifyResponse);
              $message = "g-recaptcha verified successfully";
                $to = "[email protected]"; // this is your Email address
                $from = $_POST['email']; // this is the sender's Email address
                $name = $_POST['name'];
                $course = $_POST['course'];
                $phone = $_POST['phone'];
                $comment = "Form submission";
                $comment2 = "Copy of your form submission";
                $message =  "Name:" . $name . "Interested in " . $course. " Number" . $phone . " " . " Wrote" . "nn" . $_POST['comment'];
                $message2 = "Copy " . $name ."nn" . "Interested in:" . $course . "nn" . $_POST['comment'];
                $headers = "From:" . $from;
                $headers2 = "From:" . $to;
                 // sends a copy of the message to the sender
                // This redirects to page thanking for contact.
// This redirects to page informing about failure.
              $message = "couldn't verify Captcha. Email not sent.";
         echo '<script type="text/javascript">mailNotSent();</script>';
<section id="contact" class="contact">
    <div class="container pseudonest">
        <div class="pseudonest contact__head--nest">
            <h1 class="display-5 lh-1 mb-2 contact__head--pseudocircle contact__head--header mx-auto">Enroll now</h1>
        <div class="container m-auto">
             <div class="d-flex justify-content-center contact__form">
                <div class="col-md-7 col-lg-8">
                    <form action="" method="post">
                        <form class="needs-validation" novalidate>
                            <div class="row g-3">
                                <div class="col">
                                    <label for="name" id="nameHeader" class="form-label">Name</label>
                                    <input type="text" class="form-control radio__margin" id="name" name="name"
                                        placeholder="" value="<?php echo $name;?>" required>
                                    <div class="invalid-feedback">
                                        <?php echo $nameErr;?>
                                    <label for="email" class="form-label">Email</label></label>
                                    <input type="email" class="form-control radio__margin" id="email" name="email"
                                        placeholder="[email protected]" value="<?php echo $email;?>" required>
                                    <div class="invalid-feedback">
                                        <?php echo $emailErr;?>
                                    <label for="phone" class="form-label">Phone</label></label>
                                    <input type="number" class="form-control radio__margin" id="phone" name="phone"
                                        pattern="[0-9]+" placeholder="+48 111 222 333" value="<?php echo $phone;?>">
                                    <div class="invalid-feedback">
                                        <?php echo $phoneErr;?>
                                <div class="col radio__col">
                                    <label for="firstName" class="form-label">Course?</label>
                                    <div class="row radio__section">
                                        <label class="radio__container">English
                                            <input type="radio" name="course"
                                                <?php if (isset($course) && $course=="English") echo "checked";?>
                                            <span class="radio__checkmark"></span>
                                        <label class="radio__container">
                                            <input type="radio" name="course"
                                                <?php if (isset($course) && $course=="Polish") echo "checked";?>
                                            <span class="radio__checkmark"></span>Polish
                                        <label class="radio__container">
                                            <input type="radio" name="course"
                                                <?php if (isset($course) && $course=="Italian") echo "checked";?>
                                            <span class="radio__checkmark"></span>Italian
                                        <span class="error"> <?php echo $courseErr;?></span>
                            <div class="col-12 mb-5">
                                <label for="email-content" class="form-label">Content</label>
                                <div class="input-group has-validation">
                                    <textarea class="form-control" rows="5" name="comment"
                                        cols="30"><?php echo $comment;?></textarea>
                                    <div class="invalid-feedback">
                            <form id="frmContact" action="varify_captcha.php" method="POST" novalidate="novalidate">
                                <div class="g-recaptcha my-3" data-sitekey="mySiteKey">
                                <input type="submit" name="submit" value="Send" id="submit"
                                    class="btn btn-primary contact__form--btn">
                                <div id="fakeSubmit" class="btn btn-primary contact__form--btn hidden">Fill the form

Laravel Action Route not Define

I have unique problem. I already create Route on web.php, on Controller, and Blade. and working on my localhost. but after publish to real server, I jus got error Action [email protected] not define. this is my code.

Route::get('/timetableschedule', '[email protected]');

this is my web.php

public function EmployeeTimeTable(Request $request){
    $session = $request->session()->get('');
    $companysession = $request->session()->get('user.location');
    $locationdata = DB::table('company')

    $userlist = db::table('users')

    $timesetting = db::table('time_leaving')

    $leaveschedule = db::table('employee_leaving')

    return view('Management.employeetimetable',['location'=>$locationdata,'UserList'=>$userlist,'ListTimeSet'=>$timesetting,'LeavingSchedule'=>$leaveschedule]);

this is my controller

          <a href="{{action('[email protected]')}}" class="dropdown-item">
            <p>Employee Timetable</p>

and this is code on blade to call [email protected]

this step same as another controller, web, and blade.php. but, just for this rout get me a trouble. thank you

I want to save an client-created string on an apache2 website

I recently set up an apache2-server for a schoolproject I’m working on. I would like the user to be able, to save a variable directly onto the website, therefore altering this part of the website forever or until the user changes it again. I know Python3, html, php and a bit of js. I realize, the information I gave you is not necessarily enough to really understand what I mean, but I am open to further questions. Help would be greatly appreciated, due to the project being due in a week from now, with extra extra-work still unfinished.
Thanks in advance,

PHP – Compare array and output found values

i have a problem trying to get some functionality to work in PHP which i am sadly not very fond of. I tried reading and wrapping my head around it but i guess i am just to unexperienced to find the correct solution myself. I was hoping that you could point me into the right direction.

The issue:

We have an image folder full of product pictures. Their naming conventions are like this :

  • EK016_9BL_P_1
  • EK016_9BL_P_2
  • EK016_9BL_P_3
  • EK016_I1T_P_1
  • EK016_I1T_P_3
  • EK022_GKC_P_1
  • EK022_GKC_P_2

and so on….

So first what i did to get a list of all the images in the folder is the following :


$dir = "C:/img";
$files = scandir($dir);
$shortcodes = [];

echo "<table>";

foreach ($files as $file){

// Trim the filename of "_-." so only the main product code remains for comparison
$trimmed= strtok($file, '_-.');

// Push cleaned filenames to a new array
array_push($shortcodes, $trimmed);

// Make each value unique so it doesn't repeat like 5x "EK016" etc
$filtered = array_unique($shortcodes);

foreach ($filtered as $shortArtCode) {
echo "</table>";


This works so far – probably not the most elegant solution but it outputs the above example list but only the main product code (everything before the _) so for example, it lists unique values like

  • EK016
  • EK018
  • EK019
  • EK022

Now that i have separated the “Main Article Code” from the file list, i want to assign the images in the folder to its respective product code, so the output would look like :

  • EK016 => EK016_9BL_P_1.jpg

  •   => EK016_9BL_P_2.jpg
  •   => EK016_9BL_P_3.jpg
  •   => EK016_9BL_P_4.jpg
  • EK018 => EK018_2BY_P_1.jpg

  •   => EK018_2BY_P_2.jpg
  •   => EK018_2BY_P_3.jpg

of course, based on the existing files in the folder that match the “Product Code”.

I have tried “in_array” comparisons, and string comparisons but with no luck since I probably need to do everything in the same loop to get proper results. Does anyone have an idea what could be done to make this quick and dirty or maybe a completely different approach I haven’t thought of?

appreciate your help 🙂

HTML: getting selected datalist option value, and innerHTML, without using Jquerys

I have a situation where I want to let a user decide titles of books that I have on my db, using an input with a datalist (generated by php), after the user picked a title, he would click a submit button and the form would send the title in another file.

Everything worked fine but I didn’t realized that I needed to send the ID of the book that the user selected, because there can be more than one book with the same title.

What I would like to have is the option of the datalist, that no longer has the title of the book inside its “value” attribute, but I want that title inside its innerHTML, so that the title gets displayed, while having the ID inside the “value” attribute. My problem is that if I do that, when the user clicks on the datalist option, the ID gets inside the text input, so the user may not know what book he choose.

summing up: I would like to have the datalist that displays the title, when an option is chosen, that title gets displayed in the text input, when I submit, the Id of the book gets sent in “FindBook.php” inside $_POST.

isIn() checks if the title is inside the array of titles, I would need to change that so that it can check if the ID is inside the array of IDs.


   <form onsubmit="return isIn(document.getElementById('book').value);" action="FindBook.php" target="_blank" method="POST">
      <input id="libro" name="bookTitle" list="books" autocomplete="off" style="width: 200px;">
      <input type="submit" value="Find Book">
   <datalist id="books">
    <? foreach ($books as $row) { ?>
      <option value="<? echo $row["title"]; ?>"></option>
    <? }; ?>


   <form onsubmit="return isIn(*id of the book*);" action="FindBook.php" target="_blank" method="POST">
      <input id="libro" name="bookTitle" list="books" autocomplete="off" style="width: 200px;">
      <input type="submit" value="Find Book">
  <datalist id="books">
    <? foreach ($books as $row) { ?>
      <option value="<? echo $row["id"]; ?>"><? echo $row["title"]; ?></option>
    <? }; ?>

Since I don’t understand JQuerys i would really prefer a solution that doesn’t imply that.
Sorry for my bad english, let me know if I need to clarify something.

Html auto writes =”” after an attribute with php

Well, I’ve been trying to put a “required” attribute in an html text input with php but I can`t.
I’ve a php function that creates automatically a form with all the data you give to it, but that is not the problem.
The problem is that I’ve a boolean parameter in which you choose if some of the inputs are required or not, and when one of them is true, the input must have the “required” attribute on it.
Something like…

function make_form(..., $required,...) {
   echo "<input type='...' name='...' value='...' ".($required?"required":"").">";

What I want is that when the $required variable is true, the input has “required” on it, but instead, this is what the server sends to the client:

<input type='...' name='...' value='...' required="">

And I don’t want those =”” after the “required” cause then it doesn’t validate that the input is not empty.
I want this:

<input type'...' name='...' value='...' required>

Without the =””

I’ve tried using htmlentities(“required”), htmlspecialchars(“required”), adding an &nbsp after the “required”, using print instead of echo, using a variable instead of plain text, changing the position of the “required” inside the tag, etc. and the =”” still appears.
I hope you can help me; I’m using php 8.
Thank you very much.