Solution for admin authentication received from the user

I am trying to build a website for my college in which I have to take in the achievements obtained by the user and display on the front end…. but in order to be remove any bogus data received from the students I want to have an admin which will look at the data and once approved it must be visible to all users on the front end main page.
For more clarity on what I am trying to do:

  1. A registered user has access to post information of his/her achievements.
  2. The info must be present on the admin page and has to review it.
  3. Once reviewed, the admin must have the access to post it on to the front end for every user to see.

Can you help me on the preferred tech stack I must be knowing or the functionalities i must be knowing to do so?

I want to click answer button to answer the qustion

[enter image description here][1]


<?php require_once('connection.php');  
session_start();


if (isset($_POST['Submit']))
{  
   $answ = $_POST['answ'];      
   $email = $_SESSION['email']; 


   $insert = "INSERT INTO `id18159895_adproject`.`que` (answ,queID,email) SELECT que.queID FROM que   " ;
   $result = mysqli_query($con, $insert);

   if (!$result) {
       echo "<script>alert('ERROR !!!!! '); location='qna.php';</script>";
   }
   else {
       echo "<script>alert('Successful Post'); location='qna.php'; </script>";
   }

}
?>

how can add the answer to the current question with my logged email?

Add [title] to fillable property to allow mass assignment on [AppModelsResume]

estoy empezando con Laravel (PHP) y me he encontrado con este error El error es este: Add [title] to fillable property to allow mass assignment on [AppModelsResume].

El código del ResumeController que me da error es este:


public function store(Request $request)
    {
        $user = auth()->user();
        $resume = $user->resumes()->create([
            'title' => $request['title'],
            'name' => $user->name,
            'email' => $user->email,
        ]);

        return response("Created resume $resume->id");
    }

El cual resumes() me lo marca vscode como que no es encontrada la función, cuando la tengo hecha en el archivo Resume.php y en el User.php

Este es el código de las funciones:
(Resume.php)

    public function user(){
       return $this->belongsTo(User::class);
    }

(User.php)

    public function resumes() {
        return $this->hasMany(Resume::class);
    }

¡Muchas gracias de ante mano!

Laravel Eloquent Relationship Join

carts:-

id product_name price

ratings:-

id product_id user_id

I have these two table. And i have defined a relationship in product model for geting rating of particular product. and output of the code is this:-
“data”: [
{
“id”: 4200,
“name”: “Anti gravity Beer Cake”,
“modal”: “”,
“price”: 1800,
“discount”: 0,
“quantity”: 20,
“discription”: “Good Quality Product!”,
“p_status”: “active”,
“m_id”: 664,
“product_link”: “anti-gravity-beer-cake–6040c2b317894”,
“product_picture”: ” “,
“weight”: 0,
“weight_type”: “Kilogram”,
“rating”: {
“id”: 4,
“u_id”: 1,
“product_id”: 4200,
“subject”: null,
“ratings”: 4,
“review”: null,
“type”: “rating”
}
},
{
“id”: 4200,
“name”: “Anti gravity Beer Cake”,
“modal”: “”,
“price”: 1800,
“discount”: 0,
“quantity”: 20,
“discription”: “Good Quality Product!”,
“p_status”: “active”,
“m_id”: 664,
“product_link”: “anti-gravity-beer-cake–6040c2b317894”,
“product_picture”: ” “,
“weight”: 0,
“weight_type”: “Kilogram”,
“rating”: {
“id”: 5,
“u_id”: 1,
“product_id”: 4200,
“subject”: null,
“ratings”: 5,
“review”: null,
“type”: “rating”
}
}

But i want product having high rating first. How i an do it?
product model:-

namespace AppModels;

use IlluminateDatabaseEloquentFactoriesHasFactory;
use IlluminateDatabaseEloquentModel;

class product extends Model
{
use HasFactory;

public function rating(){
    return $this->hasOne(ratings_and_review::class)->orderBy('ratings','DESC');
}

}

How can i get the value of a checkbox in checkout page to woocommerce orders meta?

This is an accordion made on the woocommerce checkout page and I want to pass the value of these checkboxes to woocommerce orders. Is it possible to do it this way or any simple way. ?

add_action('woocommerce_before_checkout_form' ,'screening_checkout_clinic');
            function screening_checkout_clinic(){
            ?>
    

<div class="checkout-clinic-select"><?php echo "<h2>Select a preffered clinic</h2>"; ?>

    

<button class="custom-accordion-screening-clinic">Kuala Lumpur</button>
    

<div class="panel">
            <div class="custom-accordion-inner">
              <input name="accordion1" id="accordion1" type="checkbox" value="Polyclinic & Surgery Khor"></input>
              <label for="accordion1">Polyclinic & Surgery Khor</label>
            </div>
            <div class="custom-accordion-inner">
              <input name="accordion2" id="accordion2" type="checkbox" value="Poliklinik & Surgeri Siva"></input>
              <label for="accordion2">Poliklinik & Surgeri Siva</label>  
            </div>
            <div class="custom-accordion-inner">
              <input name="accordion3" id="accordion3" type="checkbox" value="Clinic Q City & Surgery"></input>
              <label for="accordion3">Clinic Q City & Surgery</label>    
            </div>
            <div class="custom-accordion-inner">
              <input name="accordion4" id="accordion4" type="checkbox" value="HS Mediclinic & Surgery"></input>
              <label for="accordion4">HS Mediclinic & Surgery</label>  
            </div>
        </div>
 <?php              
 }
 ?>    

Modal doesn’t open on all buttons

As my title already says, I have an issue with a modal not opening on all buttons.

Here is the situation:

I have a page that displays all applications a user has sent for different jobs. So it may be just one, or up to whatever.
It looks like this:

https://i.stack.imgur.com/VtfkK.jpg

Now if the user wants to cancel the application he can press the button “Bewerbung zurückziehen”, then the modal opens to give a heads up that all data will be lost and if he is sure, in the modal he can confirm it or go back. Everything works fine for the first post on the site, but all other posts just nothing happens, so the modal doesn’t open.

Here is my code:

  1. The blade file that displays all posts:
@foreach($bewerbungen as $bewerbung)
                    @foreach($stellenanzeigen_names as $stellenanzeigen_name)
                        @if($bewerbung->Stellenanzeigen_ID === $stellenanzeigen_name->Stellenanzeigen_ID)
                            <div
                                class="p-10 grid-cols-3 grid-rows-3 gap-4 shadow-2xl mb-10 bg-gradient-to-r from-green-400 to-blue-500 border-solid border-2 border-black rounded-lg">
                                <!--Card 1-->
                                    <div
                                        class="overflow-hidden row-span-3 bg-gray-100 shadow-2xl border-solid border-2 border-gray-500 rounded-lg">
                                        <div class="pt-4 pl-4">
                                            {{ $stellenanzeigen_name->Titel }}
                                            <hr class="border-black">
                                        </div>
                                        <div class="pt-4 pl-8 font-medium text-xl font-bold font-serif">
                                            ID der Bewerbung: {{ $bewerbung->Bewerbung_ID }}</div>
                                        <div class="pt-4 pl-8 pb-3 font-medium text-xl font-bold font-serif">
                                            ID der Stellenanzeige: {{ $bewerbung->Stellenanzeigen_ID }}</div>

                                        <div class="w-1/4 mb-4 pl-4">
                                            <div class="font-medium text-base font-bold font-serif mb-4 pb-3">
                                                <button type="submit" id="delete_appl_btn" name="delete_appl_btn"
                                                        class="mb-4 pb-3 w-full text-white px-4 py-3 rounded text-base font-medium
                                                                bg-gradient-to-r from-green-400 to-blue-500 float-right shadow transition
                                                                duration-500 ease-in-out transform hover:-translate-y-1 hover:scale-100
                                                                shadow-2xl border-2 w-full p-4 rounded-lg">
                                                    Bewerbung zurückziehen
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                            </div>
                        @endif
                    @endforeach
                @endforeach

Here is the code for the modal:

<div id="delete_application_modal" class="modal fixed ml-96 top-20 mx-auto p-5 border w-96 shadow-lg rounded-md bg-white hidden">
                        <div class="mt-3 text-center text-xl">
                            Bewerbung zurückziehen
                            <div class="text-center text-sm mt-4">
                               
                            </div>
                        </div>

                        <div class="items-center px-4 py-3">
                            <label for="delete_application" class="sr-only">Bewerbung zurückziehen</label>

                            <form action="{{ route('delete', $bewerbung->Bewerbung_ID) }}" method="post">
                                @csrf
                                <button type="submit" id="ok_btn" class="mb-4 pb-3 w-full text-white px-4 py-3 rounded text-base font-medium
                                                bg-gradient-to-r from-green-400 to-blue-500 float-right shadow transition
                                                duration-500 ease-in-out transform hover:-translate-y-1 hover:scale-100
                                                shadow-2xl border-2 w-full p-4 rounded-lg">
                                    Bewerbung zurückziehen
                                </button>
                            </form>
                        </div>

                        <div class="items-center px-4 py-3">
                            <button id="back_btn_tel" class="mb-4 pb-3 w-full text-white px-4 py-3 rounded text-base font-medium
                                                bg-gradient-to-r from-green-400 to-blue-500 float-right shadow transition
                                                duration-500 ease-in-out transform hover:-translate-y-1 hover:scale-100
                                                shadow-2xl border-2 w-full p-4 rounded-lg">
                                zurück
                            </button>
                        </div>
                    </div>
                    @if(session()->has('message'))
                        <div class="alert alert-success">
                            {{ session()->get('message') }}
                        </div>
                    @endif
                    <script>
                        var delete_appl_modal = document.getElementById("delete_application_modal");

                        var open_modal = document.getElementById("delete_appl_btn");

                        var back_btn = document.getElementById("back_btn_tel");

                        open_modal.onclick = function () {
                            delete_appl_modal.style.display = "block";
                        }

                        back_btn.onclick = function () {
                            delete_appl_modal.style.display = "none";
                        }

                        window.onclick = function (event) {
                            if (event.target == modal) {
                                delete_appl_modal.style.display = "none";
                            }
                        }
                    </script>

Honestly I have zero clue why it works for the first but not for the others, they have the same buttons, with same name, id & everything.
Maybe someone of you had a similar issue. I wish you all happy holidays!

Used fgetcsv() for uploading CSV file but it show empty array

I’m working on a codeIgniter3 project where I need to upload CSV file into the database and I used custom made library for perform this task but it is not working and showing empty array!

here are the library that I used “Csvimport.php“:

  <?php defined('BASEPATH') or exit('No direct script access allowed');

  class Csvimport {

    var $fields;/** columns names retrieved after parsing */
    var $separator = ';';/** separator used to explode each line */
    var $enclosure = '"';/** enclosure used to decorate each field */
    var $max_row_size = 120400;/** maximum row size to be used for decoding */

    function parse_file($p_Filepath) {

      $file = fopen($p_Filepath, 'r');

      $this->fields = fgetcsv($file, $this->max_row_size, $this->separator, $this->enclosure);



      $keys_values = explode(',', $this->fields[0]);

      $content = array();
      $keys = $this->escape_string($keys_values);

      $i = 1;
      while (($row = fgetcsv($file, 0, $this->separator, $this->enclosure)) != false) {
        
        if ($row != null) { // skip empty lines
          $values = explode(',', $row[0]);
          if (count($keys) == count($values)) {
            $arr = array();
            $new_values = array();
            $new_values = $this->escape_string($values);
            for ($j = 0; $j < count($keys); $j++) {
              if ($keys[$j] != "") {
                $arr[$keys[$j]] = $new_values[$j];
              }
            }

            $content[$i] = $arr;
            $i++;
          }
        }
      }
      fclose($file);
      return $content;
    }

    function escape_string($data) {
      $result = array();
      foreach ($data as $row) {
        $result[] = str_replace('"', '', $row);
      }
      return $result;
    }

  }
  ?>

Here is the “Controller” code that I used to upload the CSV file:

$this->load->library('csvimport');
$file_path = base_url()."upload/test.csv";
$csv_data = $this->csvimport->parse_file($file_path);
echo '<pre>';
print_r($csv_data);
echo '</pre>';

When I executed code it show empty array() as result!

Please help me i’m stuck with this!! 🙁

In CSV file I’ve following fields:

grade
name
address
city
phone
email
type
created

Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens

I am new to php .I have checked values so many time, they are same in database too .
I am getting this error:
Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in C:xampphtdocssmscreateAboutTest.php:26 Stack trace: #0 C:xampphtdocssmscreateAboutTest.php(26): PDOStatement->execute() #1 {main} thrown in C:xampphtdocssmscreateAboutTest.php on line 26
I don’t know what’s wrong with my code 🙁 . thankyou for your help in advance:

$pdo = new PDO('mysql:host=localhost;port=3306;dbname=testconductingportal', 'root', '');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$t_id = $_POST['t_id'];
$t_name= $_POST['t_name'];
$ins_name = $_POST['ins_name'];
$t_date = $_POST['t_date'];
$t_time = $_POST['t_time'];
$t_duration= $_POST['t_duration'];
$t_fee = $_POST['t_fee'];
$t_savedate = $_POST['t_savedate'];
$t_closing_date  = $_POST['t_closing_date'];
$t_description = $_POST['t_description'];
$statement= $pdo->prepare("INSERT INTO about_test (t_id, t_name, ins_name, t_date, t_time, t_duration, t_fee, t_savedate, t_closing_date, t_description)
VALUES(:t_id, :t_name, :ins_name, :t_date, :t_time, :t_duration, :t_fee, :t_savedate, :t_closing_date', :t_description')");
$statement->bindvalue(':t_id', $t_id);
$statement->bindvalue(':t_name', $t_name);
$statement->bindvalue(':ins_name', $ins_name);
$statement->bindvalue(':t_date', $t_date);
$statement->bindvalue(':t_time', $t_time);
$statement->bindvalue(':t_duration', $t_duration);
$statement->bindvalue(':t_fee', $t_fee);
$statement->bindvalue(':t_savedate', $t_savedate);
$statement->bindvalue(':t_closing_date', $t_closing_date);
$statement->bindvalue(':t_description', $t_description);
$statement->execute();
?>

How can I seek in a video outputted by PHP?

For outputting a big video (duration 20m46s, size 1.34 GB),
I use the following code (file video.php):

<?php
define('CHUNK_SIZE', 1024*1024); // Size (in bytes) of tiles chunk
// Read a file and display its content chunk by chunk
function readfile_chunked($filename, $retbytes = TRUE) {
    $buffer = '';
    $cnt    = 0;
    $handle = fopen($filename, 'rb');

    if ($handle === false) {
        return false;
    }

    while (!feof($handle)) {
        $buffer = fread($handle, CHUNK_SIZE);
        echo $buffer;
        ob_flush();
        flush();

        if ($retbytes) {
            $cnt += strlen($buffer);
        }
    }

    $status = fclose($handle);

    if ($retbytes && $status) {
        return $cnt; // return num. bytes delivered like readfile() does.
    }

    return $status;
}

$filename = 'video.mp4';
$mimetype = 'video/mp4';
header('Content-Type: '.$mimetype );
readfile_chunked($filename);

?>

The video is watched in a HTML page with the following code:

<video controls>

<source src='video.php' type='video/mp4'>
  
</video>

However, seeking in the video doesn’t work correctly.
For example, if I move the play cursor for seeking to the 18:00 timestamp, it will
instead seek to the 0:58 timestamp.

How can I solve this?

pass multiple params from function to funtion and access inputs -Laravel

$myCourseData['points'] = "1";                 
 $myCourseData['totalPoints'] = "2";

$this->update($myCourseData,$myCourseId);

i wanted to pass points & totalPoints from a function to the function update() and access points in update() as $request->points;.How can i do that? Only points & totalPoints are passed from the above function , other params in the update() function input are getting from somewhere else.

function update($request,$id){

 $validator = Validator::make(
            $request->all(),
            [
                'course_id'       => 'nullable|integer',  
                'exam_numbers'    => 'nullable|integer',
                'points'          => 'nullable|integer', 
                'subscription' => 'nullable|boolean',
                'totalPoints'=>'nullable|integer'
            ]
        );     

$points =  $request->points;
}          
    

    

HOW TO GET QUERY IN SQL USING PHP IN SQL TIGGERING

This is my code my $sql variable didn’t give query plese help me for this I try this but I couldn’t please help me with that

<?php 
    $connect = mysqli_connect("localhost", "root", "", "finger");
    $f= "";
    $l= "";
    $sql = "CREATE TRIGGER `ersdmmmmecv` AFTER INSERT ON `event` FOR EACH ROW  SELECT fname,Lname INTO $f,$l  FROM user WHERE id=NEW.id;"
    $result = mysqli_query($connect, $sql);
?>

PHP Doctrine DTO integer id to uuid from ResultSetMapping

I am fetching results from doctrine native query and want to convert the id into uuid using result set mapper,I am using the below code:

$rsm = new ResultSetMapping();
    $rsm->addScalarResult('id', 'id', 'uuid_magic_optimised');
    $rsm->addScalarResult('title', 'title');
    $rsm->addScalarResult('vendor', 'vendor');
    $rsm->addScalarResult('icon_name', 'icon_url');

But getting the following error:

Doctrine  DBAL  Types  ConversionException
Could not convert database value "1" to Doctrine Type uuid_binary_ordered_time

Why can you call a private method on a new instance made inside a public method of the same class type, in PHP?

Why can you call a private method on a new instance made inside a public method of the same class type?

class Foo
{
    private function thePrivateMethod()
    {
        echo 'can not be called publicly?';
    }

    public function thePublicMethod()
    {
        $clone = new Foo;
        $clone->thePrivateMethod();
    }
}

$foo = new Foo();
$foo->thePublicMethod();
$foo->thePrivateMethod();

The above results in the following output when run in PHP 7.3.18

can not be called publicly?

Fatal error:  Uncaught Error: Call to private method Foo::thePrivateMethod() from context

Intuitively, I would expect the first call to Foo::thePrivateMethod() to also cause a fatal error. But I’m not able to find in the documentation that this behaviour would be allowed?