How to connect azure cloud database to android using php?

developers, I wanted to connect the azure cloud database to android I researched some via the internet but it did not work well and I found a solution that I can use PHP to connect the database and send the response to Jason object in java.
please guide me to write PHP(back end) code well I am not good at PHP so.

Does PHP have a password_verify bug?

The following code snippet should not emit ‘MATCHED’ because the password ‘testtest’ does not match ‘testtesttest’, but does on PHP 7.4.3 for me. Am I doing something wrong?

<?php
$sPass = 'testtesttest';
$sSalt = hash('sha256','this is my salt');
$sShadow = password_hash($sSalt . $sPass,PASSWORD_BCRYPT);
echo (password_verify($sSalt . 'testtest',$sShadow) ? 'MATCHED' : 'nomatch');

Laravel 8 call other model relationship in model relationship

enter image description here

i have that relationship, and the mainproblem is how do i show Product where have relationship with product_image / discounts and render that on blade?

There my Cart class model :

 public function products()
{
    return $this->belongsTo(Product::class, 'product_id','id');
}

There’s my product class model :

  public function discounts()
{
    return $this->hasMany(Discount::class, 'product_id', 'id');
}

public function images()
{
    return $this->hasMany(ProductImage::class, 'product_id', 'id');
}

public function getProductImage()
{
    return $this->images->image_name;
}

This is both whatdiscount and product_images code to returning relationship

 public function products()
{
    return $this->belongsTo(Product::class, 'product_id','id');
}

and how do i show that on my Cart blade? i’ve use this but still error

@foreach($cart as $data)
                                            @foreach ($data->products as $item)
                                            <th scope="row">
                                                <img src="{{ asset('images/'.$item->image->image ) }}"class="border" style="width:120px;" alt="">
                                            </th>
                                            @endforeach
@endforeach

How can I improve my site security? Ajax requests with token?

I think I need to improve my site security where I have bunch of ajax requests.

Until now I used SESSION variables to log-in a user. Example of my login page:

login.php

/// START SECURE SESSION
function startSession($lifetime, $path, $domain, $secure, $httpOnly)
{
    session_set_cookie_params($lifetime, $path, $domain, $secure, $httpOnly);
    session_start();
}
// Initialize the session
if (!isset($_SESSION)) {
    startSession(0, '/', 'example.com', true, true);
}
// Check if the user is already logged in
if (isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] == true || !empty($_SESSION["username"])) {
    header("location: https://example.com/admin/");
    exit;
}

if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Check if username is empty
    if (empty(trim($_POST["username"]))) {
        $username_err = "Username field is empty.";
    } else {
        $username = trim($_POST["username"]);
    }
    
    // Check if password is empty
    if (empty(trim($_POST["password"]))) {
        $password_err = "Password field is empty.";
    } else {
        $password = trim($_POST["password"]);
    }
if (empty($username_err) && empty($password_err)) {
            // Prepare a select statement
            $sql = "SELECT id, username, password FROM login WHERE username = :username";
            
            if ($stmt = $pdo->prepare($sql)) {
                $stmt->bindParam(":username", $param_username, PDO::PARAM_STR);
                
                // Set parameters
                $param_username = trim($_POST["username"]);
                
                // Attempt to execute the prepared statement
                if ($stmt->execute()) {
                    // Check if username exists, if yes then verify password
                    if ($stmt->rowCount() == 1) {
                        if ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                            $id              = $row["id"];
                            $username        = $row["username"];
                            $hashed_password = $row["password"];
                            $options = ['cost' => 12];
                            if (password_verify($password, $hashed_password)) {
                                // Password is correct, so start a new session
                                if (!isset($_SESSION)) {
                                    startSession(0, '/', 'example.com', true, true);
                                }
                                // Check if the hash needs to be created again. 
                                    if (password_needs_rehash($hashed_password, PASSWORD_DEFAULT, $options))
                                    {
                                      $hash = password_hash($password, PASSWORD_DEFAULT, $options);
                                      
                                      /* Update the password hash on the database. */
                                      $query = 'UPDATE login SET password = :passwd WHERE id = :id';
                                      $values = [':passwd' => $hash, ':id' => $id];
                                      try
                                      {
                                        $res = $pdo->prepare($query);
                                        $res->execute($values);
                                      }
                                      catch (PDOException $e)
                                      {
                                        /* Query error. */
                                        echo 'Query error.';
                                        die();
                                      }
                                    }
                                // Store data in session variables
                                $_SESSION["loggedin"]      = true;
                                $_SESSION["id"]            = $id;
                                $_SESSION["username"]      = $username;
                                $_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp
                                $_SESSION["twofactory"]    = false;
                                // Redirect user to welcome page
                                session_regenerate_id(true);
                                $url = $_POST["url"];
                                if (!empty($url)) {
                                    header("location: https://example.com/" . $url);
                                } else {
                                    header("location: https://example.com/admin/index.php");
                                }
                            } else {
                                // Password is not valid, display a generic error message
                                $login_err = "Wrong name or password.";
                                //error_log("Wrong pass/username " . $ipadress . " URL: " . $actual_link, 0);
                            }
                        }
                    } else {
                        // Username doesn't exist, display a generic error message
                        $login_err = "Wrong name or password.";
                        error_log("Wrong pass/username! IP: " . $ipadress . " URL: " . $actual_link, 0);
                    }
                } else {
                    echo "Error occured try again later.";
                }
                
                // Close statement
                unset($stmt);
            }
        }

That’s how user can log-in to admin.

And in all other files (what I want to secure) I included (to top of the file) a sessioncheck.php named file and check out if the SESSION is set or not.

sessioncheck.php

  if (!isset($_SESSION))
  {
    session_set_cookie_params(0, '/', 'example.com', true, true);
    session_start();
  }

$url = dirname($_SERVER['PHP_SELF']);

// Check if the user is logged in, if not then redirect him to login page
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true || empty($_SESSION["username"])){
    header("location: https://example.com/admin/config/login.php?url=".$url);
    exit;
}

If the last activity more then 1800 sec
if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 1800)) {
    // last request was more than 30 minutes ago
    session_unset();     // unset $_SESSION variable for the run-time 
    session_destroy();   // destroy session data in storage
    header("location: https://example.com/admin/config/login.php?url=".$url);
    exit;
}

$_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp

So my question is that if I request a file with ajax which have in the top included the sessioncheck.php file then it’s enough or I need to improve something with verification (session check?) Maybe I need to POST token with ajax and verify that also?

What do you think? What I need to improve to make my site more secure?

Get data from a form using post

I have three dropdowns and I can’t get data from two of them using POST, here is my code:

<form action="{url module=ProductManagement action=downloadFilteredImages}" method="post">
<table>
    <tbody>
        <tr>
            <td>
                <select class="form-control selectpicker filter" name="category_id" multiple data-live-search="true">
                    {foreach $suppliers as $supplier}
                        <option value="{$supplier.supplier_id}" {if $value eq $supplier.supplier_id}selected{/if}>{$supplier.supplier_name}</option>
                    {/foreach}
                </select>
            </td>
            <td>
                <select class="form-control selectpicker filter" name="category_id" multiple data-live-search="true">
                    <option value="0" selected>{t}Category filter{/t}</option>
                    {include file="./ProductManagement_filters_category.tpl" categories=$categories}
                </select>
            </td>
            <td>
                <select class="form-control selectpicker filter" name="category_id" multiple data-live-search="true">
                    {foreach $order_statuses as $status}
                        <option value="{$status.order_status_id}" {if $value eq $status.order_status_id}selected{/if}>{$status.order_status_name}</option>
                    {/foreach}
                </select>
            </td>
            <td>
                <button type="submit" class="btn btn-primary">
                    {'Download'|t}
                </button>
            </td>
        </tr>
    </tbody>
</table>

I can get the categoryID but not from the supplier or order status

Object functions don’t work inside sql_query in php

I want to create a query that Inserts user data to a database. The connection works fine but for some reason the functions from the object don’t return their values inside the sql_query and instead the value () is stored inside the columns of the database. The code used is the following:

function addAccountToDB($conn, $user) {
    //echo user->getUsername();
    $sql_query = "INSERT INTO users(username, email, address, password, telephone) VALUES ('$user->getUsername()', '$user->getEmail()', '$user->getAddress()', '$user->getPassword()','$user->getTelephone()')";
    if(mysqli_query($conn, $sql_query)) {
        //logIn($conn, $user, false);
        return true;
    }
    echo "query error " . mysqli_error($conn);
    return false;
}

And I get the following error:

Warning: Undefined property: User::$getUsername in D:Vs CodeComposting-Projectphpfunctions.php on line 45

Warning: Undefined property: User::$getEmail in D:Vs CodeComposting-Projectphpfunctions.php on line 45

Warning: Undefined property: User::$getAddress in D:Vs CodeComposting-Projectphpfunctions.php on line 45

Warning: Undefined property: User::$getPassword in D:Vs CodeComposting-Projectphpfunctions.php on line 45

Warning: Undefined property: User::$getTelephone in D:Vs CodeComposting-Projectphpfunctions.php on line 45

The echo right before the query works fine and the line 45 that the error is refering to is the $sql_query = "INSERT INTO users(username, email, address, password, telephone) VALUES ('$user->getUsername()', '$user->getEmail()', '$user->getAddress()', '$user->getPassword()','$user->getTelephone()')"; line.

The following code is the functions.php and classes.php files that are used:

functions.php:

<?php
session_start();
include("../php/connect.php");
include("../php/classes.php");

function addAccountToDB($conn, $user) {
    $sql_query = "INSERT INTO users(username, email, address, password, telephone) VALUES ('$user->getUsername()', '$user->getEmail()', '$user->getAddress()', '$user->getPassword()','$user->getTelephone()')";
    if(mysqli_query($conn, $sql_query)) {
        //logIn($conn, $user, false);
        return true;
    }
    echo "query error " . mysqli_error($conn);
    return false;
}
?>

classes.php;

<?php 
class User {
    private $username;
    private $email;
    private $address;
    private $password;
    private $telephone;

    public function __construct($username, $email, $address, $password, $telephone) {
        $this->username = $username;
        $this->email = $email;
        $this->address = $address;
        $this->password = $password;
        $this->telephone = $telephone;
    }

    public function getUsername() {
        return $this->username;
    }

    public function getEmail() {
        return $this->email;
    }

    public function getAddress() {
        return $this->address;
    }

    public function getPassword() {
        return $this->password;
    }

    public function getTelephone() {
        return $this->telephone;
    }
}
?>

How to find freetime slots during working hours of 8 to 17hrs given an array of busytime slots in a day using php

Given this array

[
        {
          "date": "2015-01-01",
          "starttime": "2015-01-01 07:30",
          "endtime": "2015-01-01 08:30"
        },
        {
          "date": "2015-01-01",
          "starttime": "2015-01-01 11:00",
          "endtime": "2015-01-01 11:30"
        },
        {
          "date": "2015-01-01",
          "starttime": "2015-01-01 14:00",
          "endtime": "2015-01-01 15:00"
        },
        {
          "date": "2015-01-03",
          "starttime": "2015-01-03 08:30",
          "endtime": "2015-01-03 12:30"
        },
        {
          "date": "2015-01-03",
          "starttime": "2015-01-03 14:00",
          "endtime": "2015-01-03 15:00"
        },
        {
          "date": "2015-01-03",
          "starttime": "2015-01-03 15:30",
          "endtime": "2015-01-03 16:30"
        }
]

am trying to write a function to find freetime slots during working hours 8 – 17hrs

can anyone help with an algorithm please

PHP blank page bug ( PDO)

So, I created an HTML form to retrieve the data with PDO, the problem is here, every time I run my code, a blank page appears without any error and I don’t understand why. This happens to me a lot, that’s why I’m asking for your help, thank you very much

this is my Php code

<?php 
include "connectBdd.php";

try {
$sql="INSERT into journaliste(noemile, nomjourna,prenomjourna,villejourna,adressmailjourna,adressjourna,journaltel, codepostaljourna)  values(:prenom,:ville,:mail,:perso,:tel,:code,:nom,:emile)";



   
if($_POST["listem"]=="-1"){
$em=null;
}

else
{
    $em=$_POST["listem"];
}


$resultat = $cnx->prepare($sql);
$nbLignes= $resultat->execute(array(":nom"=> $_POST["nom"],  
 ":emile"=> $em,
":ville"=> $_POST["ville"],
":mail"=> $_POST["mail"],
":perso"=> $_POST["perso"],
":tel"=> $_POST["numero"],
":code"=> $_POST["code"],
":prenom"=> $_POST["prenom"]));
echo $nbLignes." ligne ajoutée";

}

Thank you

How to set content type in php curl?

I need to send a post request to a website using php curl. I set header Content-type = application/json but curl_info still shows Content-type = null.

$url = "https://api.business.kazanexpress.ru/api/oauth/token";

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

$headers = array(
'Content-Type: application/json',
"Accept: application/json",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
var_dump(curl_getinfo($curl));

How to redirect to the previous page after a login

To make it fast i send mail with urls to my customers. But to reach the link you have to be connected so before reach an $_get[‘action’] you have to log in to my ConnexionController.

The main issue is, my ConnexionController after a log in redirect to the home page of my website and dont give a direct acces to the initial url the customer clicked for.

Here is a part of the code that make the connection.

if (!isset($_SESSION['UserID']) && htmlspecialchars($_GET['action']) != 'connectionIntranet' && htmlspecialchars($_GET['action']) != 'nouveauMotDePasse' && htmlspecialchars($_GET['action']) != 'recupeMotDePasse' && htmlspecialchars($_GET['action']) != 'recupeMotDePasseAttente')
    header("location: index.php?action=connectionIntranet");

if (isset($_POST['userName']) && isset($_POST['password'])) {
    $resConnect = $nrj_user->connect(htmlspecialchars($_POST['userName']), htmlspecialchars($_POST['password']));
    if ($resConnect > 0) { //connexion reussi
        $_SESSION['UserID'] = $resConnect;
        $infoUser = $nrj_user->getUserInfos($resConnect);
        if ($infoUser) { //Infos récupérés
            $_SESSION['UserID'] = $infoUser['UserID'];
            $_SESSION['IdentUser'] = $infoUser['IdentUser'];
            $_SESSION['initiales'] = $infoUser['initiales'];
            $_SESSION['Nom'] = $infoUser['Nom'];
            $_SESSION['Prenom'] = $infoUser['Prenom'];
            $_SESSION['TPortable'] = $infoUser['TPortable'];
            $_SESSION['email'] = $infoUser['email'];
            $_SESSION['teldom'] = $infoUser['teldom'];
            $_SESSION['TBureau'] = $infoUser['TBureau'];
            $_SESSION['civilite'] = $infoUser['civilite'];
            $_SESSION['Adress1'] = $infoUser['Adress1'];
            $_SESSION['Adress2'] = $infoUser['Adress2'];
            $_SESSION['CodPost'] = $infoUser['CodPost'];
            $_SESSION['Ville'] = $infoUser['Ville'];
            $_SESSION['TFax'] = $infoUser['TFax'];
            $_SESSION['entre_le'] = $infoUser['entre_le'];
            $_SESSION['sortie_le'] = $infoUser['sortie_le'];
            $_SESSION['modif_le'] = $infoUser['modif_le'];
            $_SESSION['modif_par'] = $infoUser['modif_par'];
            $_SESSION['Dpt_Id'] = $infoUser['Dpt_id'];
            $_SESSION['ref_cde'] = $infoUser['ref_cde'];
            $_SESSION['modif_pw'] = $infoUser['modif_pw'];

            header("location: index.php?action=AccueilIntranet");
        }
    } else
        $mesConnectionErreur = 'Identifiant ou mot de passe incorrecte';```

I already tried to save the url like this 

$action = $_SERVER[‘REQUEST_URI’];
$_POST[‘action’] = $action;

but i've got issues on the finals steps.

Thank you 

Laravel 8 Seeding Pivot Table Integrity constraint violation: 1048 Column ‘roleid’ cannot be null

Trying to seed a database with users that have many roles. This is a many-to-many relationship. Why is the roleid column not being populated and why am I receiving this error:

P.S. I’m aware my table naming conventions are incorrect.

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'roleid' cannot be null (SQL: insert into `user_role` (`userid`, `videoid`) values (9, ?), (6, ?))

User Model:

public function role() {
    return $this->belongsToMany(Video::class, 'user_roll', 'userid', 'roleid')->withTimestamps();
}

Role Model:

public function user() {
    return $this->belongsToMany(Actress::class, 'user_role', 'roleid', 'userid');
}

Pivot Table

public function up()
{
    Schema::create('user_role', function (Blueprint $table) {
        $table->foreignId('userid')->constrained('users','userid')->cascadeOnDelete();
        $table->foreignId('roleid')->constrained('roles','roleid')->cascadeOnDelete();
        $table->timestamps();
    });
}

Seeder:

foreach (Role::all() as $role) {
    $users= User::inRandomOrder()->take(rand(1,3))->pluck('userid');
    $video->user()->attach($users);
}

Laravel::with doesn’t pull the relationship when columns are specified

I want to get a comment with just it’s id belonging to a post.

Route::get('/', function () {
  $post = Post::with([
    'comment' => fn ($query) => $query->select('id')
  ])->find(1);
  return $post;
});

However, the comment is null in response.

{
    "id": 1,
    "title": "Alias iste quo tempore quis totam maxime. Illo fuga qui modi ut quae. Nobis eum soluta quas.",
    "body": "Officiis id earum suscipit magnam reiciendis alias fugiat. Deserunt rerum in tempora odit nobis. Sunt similique accusamus suscipit aliquam quia. Sunt harum rem incidunt rerum id nesciunt. Reiciendis rerum placeat sed dolores temporibus ducimus autem. Quidem ullam ut ut voluptatum ea. Et magni aut ut animi ea cupiditate eum. Ut similique consequuntur et enim officiis nobis. Occaecati nostrum sint labore sint quia. Reprehenderit veritatis qui provident eum reprehenderit commodi.",
    "created_at": "2022-05-12T10:39:12.000000Z",
    "updated_at": "2022-05-12T10:39:12.000000Z",
    "comment": null
}

When I remove the select method, I do get the comment,

Route::get('/', function () {
  $post = Post::with('comment')->find(1);
  return $post;
});
{
    "id": 1,
    "title": "Alias iste quo tempore quis totam maxime. Illo fuga qui modi ut quae. Nobis eum soluta quas.",
    "body": "Officiis id earum suscipit magnam reiciendis alias fugiat. Deserunt rerum in tempora odit nobis. Sunt similique accusamus suscipit aliquam quia. Sunt harum rem incidunt rerum id nesciunt. Reiciendis rerum placeat sed dolores temporibus ducimus autem. Quidem ullam ut ut voluptatum ea. Et magni aut ut animi ea cupiditate eum. Ut similique consequuntur et enim officiis nobis. Occaecati nostrum sint labore sint quia. Reprehenderit veritatis qui provident eum reprehenderit commodi.",
    "created_at": "2022-05-12T10:39:12.000000Z",
    "updated_at": "2022-05-12T10:39:12.000000Z",
    "comment": {
        "id": 1,
        "post_id": 1,
        "comment": "Exercitationem voluptatibus eos velit consequatur aut voluptatem voluptas. Sed et magnam omnis nesciunt dignissimos rerum enim. Accusamus ipsa non aspernatur iure architecto.",
        "created_at": "2022-05-12T10:39:13.000000Z",
        "updated_at": "2022-05-12T10:39:13.000000Z"
    }
}

Post.php

<?php

namespace AppModels;

use IlluminateDatabaseEloquentFactoriesHasFactory;
use IlluminateDatabaseEloquentModel;

class Post extends Model
{
  use HasFactory;

  public function comment()
  {
    return $this->hasOne(Comment::class);
  }
}

What am I doing wrong?

Why is my PHP loop only creating a single HTML row?

I’m very new to programming and have an assignment that i need help with. I need to use my foreach loop in “index.php” to iterate over some data. It should use the HTML ‘blueprint’ from “layout_tabelleninhalt.html” for every single row and show the entire table in “layout_main.html”.

My index.php file:

$previous="";
$gesamttabelle ="";
foreach( $anzahlmonate as $monat => $Farbe ) {

 foreach($Farbe as $Farbe => $anzahl){
  $tabellen_template = file_get_contents('layout_tabelleninhalt.html');
   
   if ($previous == $monat)
   {
     echo "" ;
   } 
   else
   {
      echo $monat;
   }
     echo   $Farbe ;
     echo  $anzahl ;

   $previous = $monat;
   $gesamttabelle .= $tabellen_template;
 
     }
     
    }

$content = file_get_contents ( 'layout_main.html');
$content = str_replace ( '{DATUM_VON}' , $post_datum_von , $content );
$content = str_replace ( '{DATUM_BIS}' , $post_datum_bis , $content );
$content = str_replace ( '{ANZAHL}' , $post_anzahl , $content );
$content = str_replace ( '{TABELLENINHALT}' , $tabellen_template , $content );
$content = str_replace ( '{FARBE}' , $Farbe , $content );
$content = str_replace ( '{ANZAHL}' , $anzahl , $content );
$content = str_replace ( '{MONAT}' , $monat , $content );
[echo($content);][1]

The layout_main.html file:

<table>
    <caption>Liste der Button-presses</caption>
     <tr>
       <th>Monat und Jahr</th>
       <th>Farbe</th>
       <th>Anzahl</th>
     </tr>
   
     {TABELLENINHALT}
     
   
</table>

The layout_tabelleninhalt.html file:

<tr>
    <td> {MONAT} </td>
    <td class="tabelle_links"> {FARBE} </td>
    <td class="tabelle_rechts"> {ANZAHL} </td>
</tr>

This is an image of my output. As you can see, only the first row is filled. How can i get the rest of the data in the table? Sorry if i’m missing something this is my first post.
[1]: https://i.stack.imgur.com/jPFvh.jpg

Nginx & php-fpm on kubernetes giving 404

I have a kubernetes setup with nginx pod and php pod, with a service for the php on port 9000. The files are mounted to the host on both nginx and php:

/usr/share/nginx/html -> /data/website/current

The nginx root is:

/usr/share/nginx/html/current/public

If i access in the browser for example.com/test.html it loads, this file is located in /usr/share/nginx/html/current/public.index.html

Now if i put a test.php file in the same folder and try to access example.com/test.php i get a 404 error.

All the files that are shared are owned by user 1001 and group 1001 which is the www-data user id in php and nginx user id in the nginx containers. All the pods and services are up and running.

I must be doing something wrong somewhere, my kubernetes setup looks like this:

PHP Deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: php-deployment
  labels:
    deploy: php
spec:
  replicas: 1
  selector:
    matchLabels:
      pod: php-deployment
  template:
    metadata:
      labels:
        pod: php-deployment
    spec:
      containers:
        - name: php
          imagePullPolicy: Always
          image: glenelkinsdev/gofollow-php-backend:latest
          ports:
            - containerPort: 80
          volumeMounts:
            - mountPath: /usr/share/nginx/html
              name: website-volume
      volumes:
        - name: website-volume
          hostPath:
            path: /data/website
            type: Directory


---

apiVersion: v1
kind: Service
metadata:
  name: php-service
spec:
  selector:
    pod: php-deployment
  ports:
    - protocol: TCP
      port: 9000
      targetPort: 9000

Nginx Deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-backend-deployment
  labels:
    deploy: nginx-backend
spec:
  replicas: 1
  selector:
    matchLabels:
      pod: nginx-backend
  template:
    metadata:
      labels:
        pod: nginx-backend
    spec:
      containers:
        - name: nginx
          imagePullPolicy: Always
          image: glenelkinsdev/gofollow-nginx-backend:latest
          ports:
            - containerPort: 80
          volumeMounts:
            - mountPath: /usr/share/nginx/html
              name: website-volume
      volumes:
        - name: website-volume
          hostPath:
            path: /data/website
            type: Directory


---

apiVersion: v1
kind: Service
metadata:
  name: nginx-backend-service
spec:
  type: NodePort
  selector:
    pod: nginx-backend
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
      nodePort: 30002

Nginx config:

events {
    worker_connections 1024;
}

http {

    server {
        listen 80;
        root /usr/share/nginx/html/current/public;

        location / {
            try_files $uri /index.php?$is_args$args;
        }

        location ~ ^/index.php(/|$) {
            fastcgi_pass localhost:9000;
            fastcgi_split_path_info ^(.+.php)(/.*)$;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT $realpath_root;
            internal;
         }

         location ~ .php$ {
            return 404;
         }

         error_log /usr/share/nginx/html/log/error.log;
         access_log /usr/share/nginx/html/log/access.log;
    }

}

Another problem is, i seem to have to use fastcgi_pass localhost:9000; instead of fastcgi_pass php-service:9000; otherwise the pods won’t start? I get:

nginx: [emerg] host not found in upstream “php-service” in
/etc/nginx/nginx.conf:16

Kubectl output:

NAME                                             READY   STATUS    RESTARTS   AGE    IP           NODE    NOMINATED NODE   READINESS GATES
pod/mysql-deployment-55bbf4d8d8-w52lx            1/1     Running   0          16h    172.17.0.2   node1   <none>           <none>
pod/nginx-backend-deployment-d969fcdf4-dggh8     1/1     Running   0          82m    172.17.0.5   node1   <none>           <none>
pod/nginx-frontend-deployment-5776fc574f-plbsq   1/1     Running   0          120m   172.17.0.3   node1   <none>           <none>
pod/php-deployment-7f856b4757-g7zsx              1/1     Running   0          82m    172.17.0.4   node1   <none>           <none>

NAME                             TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE    SELECTOR
service/kubernetes               ClusterIP   10.96.0.1       <none>        443/TCP        2d1h   <none>
service/mysql-service            ClusterIP   10.99.10.232    <none>        3306/TCP       16h    pod=mysql
service/nginx-backend-service    NodePort    10.109.86.98    <none>        80:30002/TCP   16h    pod=nginx-backend
service/nginx-frontend-service   NodePort    10.106.42.107   <none>        80:30001/TCP   16h    pod=nginx-frontend
service/php-service              ClusterIP   10.104.223.83   <none>        9000/TCP       126m   pod=php-deployment

NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE    CONTAINERS   IMAGES                                        SELECTOR
deployment.apps/mysql-deployment            1/1     1            1           16h    mysql        mysql:5.7                                     pod=mysql
deployment.apps/nginx-backend-deployment    1/1     1            1           82m    nginx        glenelkinsdev/gofollow-nginx-backend:latest   pod=nginx-backend
deployment.apps/nginx-frontend-deployment   1/1     1            1           120m   nginx        nginx:latest                                  pod=nginx-frontend
deployment.apps/php-deployment              1/1     1            1           82m    php          glenelkinsdev/gofollow-php-backend:latest     pod=php-deployment

NAME                                                   DESIRED   CURRENT   READY   AGE    CONTAINERS   IMAGES                                        SELECTOR
replicaset.apps/mysql-deployment-55bbf4d8d8            1         1         1       16h    mysql        mysql:5.7                                     pod=mysql,pod-template-hash=55bbf4d8d8
replicaset.apps/nginx-backend-deployment-d969fcdf4     1         1         1       82m    nginx        glenelkinsdev/gofollow-nginx-backend:latest   pod=nginx-backend,pod-template-hash=d969fcdf4
replicaset.apps/nginx-frontend-deployment-5776fc574f   1         1         1       120m   nginx        nginx:latest                                  pod=nginx-frontend,pod-template-hash=5776fc574f
replicaset.apps/php-deployment-7f856b4757              1         1         1       82m    php          glenelkinsdev/gofollow-php-backend:latest     pod=php-deployment,pod-template-hash=7f856b4757

Laravel admin panel blank page and not responding [closed]

I’m having a problem in the admin panel. This is the first time it happens to me and I can’t find the solution. Admin panel is connected to database. When I add an article from the admin panel, I encounter a blank page. I will add the photos to the description.

This is the part where I update and add articles and so on in the admin panel:
admin panel image

As soon as I press the save button, a blank page appears. Normally, a green warning should appear before me.
after save image

The green warning that will appear is as follows, but it definitely does not appear.
success warning

I am attaching the backend codes below.

This is index.blade.php code screen.

@extends('backend.app')
@section('content')
    <div class="m-alert m-alert--icon m-alert--air m-alert--square alert alert-dismissible m--margin-bottom-30" role="alert">
        <div class="m-alert__icon">
            <i class="flaticon-exclamation m--font-brand"></i>
        </div>
        <div class="m-alert__text">
            Bu bölümden sitenizin haberlerini yönetebilirsiniz.
        </div>
    </div>
    <div class="m-portlet m-portlet--mobile">
        <div class="m-portlet__head">
            <div class="m-portlet__head-caption">
                <div class="m-portlet__head-title">
                    <h3 class="m-portlet__head-text">
                    Haberler
                    </h3>
                </div>
            </div>
        </div>
        <div class="m-portlet__body">
    <!--begin: Search Form -->
    <div class="m-form m-form--label-align-right m--margin-top-20 m--margin-bottom-30">
        <div class="row align-datas-center">
            <div class="col-xl-8 order-2 order-xl-1">
                <div class="form-group m-form__group row align-datas-center">
                    <div class="col-md-4">
                        <div class="m-input-icon m-input-icon--left">
                            <input type="text" class="form-control m-input" placeholder="Search..." id="generalSearch">
                            <span class="m-input-icon__icon m-input-icon__icon--left">
                                <span>
                                    <i class="la la-search"></i>
                                </span>
                            </span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xl-4 order-1 order-xl-2 m--align-right">
                <a href="{!! url('admin/news/trash') !!}" class="btn btn-danger m-btn m-btn--custom m-btn--icon m-btn--air m-btn--pill">
                    <span>
                        <i class="la la-trash"></i>
                        <span>
                            Çöp kutusu
                        </span>
                    </span>
                </a>
                <a href="{!! route('news.create') !!}" class="btn btn-primary m-btn m-btn--custom m-btn--icon m-btn--air m-btn--pill">
                    <span>
                        <i class="la la-plus"></i>
                        <span>
                            Yeni
                        </span>
                    </span>
                </a>

                <div class="m-separator m-separator--dashed d-xl-none"></div>
            </div>
        </div>
    </div>
    <!--end: Search Form -->
    <!--begin: Datatable -->
    <table class="m-datatable" id="html_table" width="100%">
        <thead>
            <tr>
                <th>
                    ID
                </th>
                
                <th>
                    Haber
                </th>
                <th>
                    Oluşturma Tarihi
                </th>
                <th>
                    Düzenlenme Tarihi
                </th>
                <th>
                    Status
                </th>
                <th>
                    İşlemler
                </th>
                
            </tr>
        </thead>
        <tbody>
            @foreach($datas as $data)
            <tr>
                <td>
                    {{ $data->id }}
                </td>
                <td>
                    {{ $data->title }}
                </td>
                <td>
                    {{ $data->created_at }}
                </td>
                <td>
                    {{ $data->updated_at }}
                </td>
                <td>
                    @if($data->status=='active') 4 @else 6 @endif
                </td>
                <td data-field="Actions" class="m-datatable__cell">
                    <span style="overflow: visible; position: relative; width: 110px;">
                        
                        <a href="{!! url('admin/news/'.$data->id.'/edit/') !!}" class="pull-left m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill" title="Düzenle"><i class="la la-edit"></i></a>

                        {!! Form::open(['method' => 'Delete', 'route' => ['news.destroy', $data->id], 'id'=> 'deleteID'.$data->id ]) !!}
                        <button type="submit" value="deleteID{{$data->id}}" class="delete m-portlet__nav-link btn m-btn m-btn--hover-danger m-btn--icon m-btn--icon-only m-btn--pill"><i class="la la-trash"></i></button>
                        {!! Form::close() !!}

                    </span>
                </td>
            </tr>
            @endforeach
        </tbody>
    </table>

    <!--end: Datatable -->
</div>
    </div>

@section('js')
    <script src="/backend/assets/demo/default/custom/header/actions.js" type="text/javascript"></script>
    <script src="/backend/assets/demo/default/custom/components/forms/widgets/bootstrap-switch.js" type="text/javascript"></script>
    <script src="/backend/assets/demo/default/custom/components/base/sweetalert2.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $('.delete').click(function(){
                var action = "#" + $(this).attr('value');
                Swal({
                  title: 'Emin misin?',
                  text: 'Bunu silmek istediğine emin misin?',
                  type: 'warning',
                  showCancelButton: true,
                  confirmButtonText: 'Evet!',
                  cancelButtonText: 'Hayır'
                }).then((result) => {
                  if (result.value) {
                    Swal(
                      'Silindi!',
                      'Silme işleminiz başarı ile gerçekleştirildi!',
                      'success'
                    )
                    setTimeout( function () { 
                        $(action).submit();
                    }, 600);
                  } else if (result.dismiss === Swal.DismissReason.cancel) {
                    Swal(
                      'İptal edildi',
                      'Silme işleminiz iptal edildi, içeriğiniz güvende!',
                      'error'
                    )
                  }
                })  
                return false;
            });
        });
    </script>
@endsection

@section('css')
    <link href="/backend/assets/custom/css/style.css" rel="stylesheet" type="text/css" />
@endsection

@endsection

Form.blade.php code screen.

@if(request()->route()->action['as']=='news.edit')
{!! Form::open(['url' => 'admin/news/'.$datas->id, 'method' => 'PATCH', 'enctype' => 'multipart/form-data', 'class'=>'m-form m-form--fit m-form--label-align-right']) !!}
@else
@php($meta_title = 'Lorem Ipsum is simply dummy text of the printing and typeset')
@php($meta_desc  = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries')
@php($datas = ['location'=> null,'en_title'=> null,'date'=> null, 'en_body'=> null, 'sort'=> null, 'category_id' => 0, 'created_at' => null, 'slug' => null, 'title' => null, 'body' => null, 'video' => null, 'status' => null, 'cover' => null, 'meta_title' => $meta_title, 'meta_image' => 'http://via.placeholder.com/600x315', 'meta_description' => $meta_desc])
{!! Form::open(['route' => 'news.store', 'enctype' => 'multipart/form-data', 'method' => 'POST', 'class'=>'m-form m-form--fit m-form--label-align-right']) !!}
@endif

<div class="m-portletx">
   <div class="m-portlet__body">
      <ul class="nav nav-pills nav-fill" role="tablist">
         <li class="nav-item">
            <a class="nav-link active" data-toggle="tab" href="#genel">
               Genel
            </a>
         </li>
         <li class="nav-item">
            <a class="nav-link" data-toggle="tab" href="#galeri">
               Galeri
            </a>
         </li>
         <li class="nav-item">
            <a class="nav-link" data-toggle="tab" href="#seo">
               SEO
            </a>
         </li>
      </ul>
      <div class="tab-content marginTop-40">
         <div class="tab-pane active" id="genel" role="tabpanel">
            
            <div class="form-group m-form__group row">
               <label class="col-xl-3 col-lg-3 col-form-label">
               Kategori :
               </label>
               <div class="col-xl-9 col-lg-9">
                  <select selectedvalue="{{ $datas['category_id'] }}" name="category_id" class="form-control m-input type" >
                     <option value="0">Seçiniz</option>
                     <option value="1">Haber</option>
                     <option value="2">Yayın</option>
                     <option value="3">Video</option>
                  </select>
                  <span class="m-form__help">
                  Ait olduğu kategoriyi seçin.
                  </span>
               </div>
            </div>
            {{
            Form::bsText(
            'title',
            'Başlık',
            'İçeriğinizin başlığı en az 3 ve en fazla 255 karakter olmalıdır.',
            $datas['title']
            )
            }}
            <div class="form-group m-form__group row">
               <label class="col-xl-3 col-lg-3 col-form-label">
                  Açıklama :
               </label>
               <div class="col-xl-9 col-lg-9">
                  <textarea name="body" class="form-control m-input summernote" >{{$datas['body']}}</textarea>
                  <span class="m-form__help">
                     İçeriğinizi bu alana yazın
                  </span>
               </div>
            </div>

            <div class="form-group m-form__group row">
               <label class="col-xl-3 col-lg-3 col-form-label">
                  Tarih : 
               </label>
               <div class="col-xl-9 col-lg-9">
                   <input style="width: 20%;" class="form-control m-input" type="date" name="created_at" 

                   
                  @if(request()->route()->action['as']=='news.edit')
                     value="{{$datas['created_at']->format('Y-m-d')}}"
                  @else
                     value="{{ date('Y-m-d') }}"
                   @endif

                    min="2018-01-01" >
                   <div class="clearfix"></div>
                  <span class="m-form__help">
                     İçerik bu alandan belirlediğiniz tarihe göre sıralanacaktır.
                  </span>
               </div>
            </div>
            {{
            Form::bsText(
            'video',
            'Video url',
            'Youtube Video kodu Ör. https://www.youtube.com/watch?v=Bl3KM79-fzo adresindeki v= den sonraki kod Bl3KM79-fzo',
            $datas['video']
            )
            }}


            <div class="form-group m-form__group row">
               <label class="col-form-label col-lg-3 col-sm-12">
                  Durumu :
               </label>
               <div class="col-lg-9 col-md-9 col-sm-12">
                  <input name="status" value="active" data-switch="true" type="checkbox" id="m_switch_1"
                  @if($datas['status']=='active' || $datas['status']=='') checked="checked" @endif
                  >
               </div>
            </div>
            <div class="clearfix"></div>
         </div>
         <div class="tab-pane" id="galeri" role="tabpanel">
            <div class="form-group m-form__group row">
               <div class="col-lg-12 col-md-12 col-sm-12">
                  <div class="m-dropzone dropzone m-dropzone--primary" id="m-dropzone-two">
                     
                     <div class="custom-file col-xl-9 col-lg-9">
                        <input name="img[]" multiple="" type="file" class="custom-file-input m-dropzone dropzone m-dropzone--primary" id="customFile">
                     </div>
                     <div class="clearfix"></div>
                     <div class="m-dropzone__msg dz-message needsclick">
                        <i class="la la-cloud-upload fontsize-40"></i>
                        <div class="clearfix"></div>
                        <h3 class="m-dropzone__msg-title">
                        Yüklemek istediğiniz resimleri buraya bırakın veya yüklemek için tıklayın.
                        </h3>
                        <span class="m-dropzone__msg-desc">
                           Boyutu en fazla 2mb olan 10 resim seçiniz, desteklenen resim formatları (jpg, png, gif, svg)dir.
                        </span>
                     </div>
                  </div>
               </div>
            </div>
            @if(request()->route()->action['as']=='news.edit')
            <ul class="editGal">
               @foreach($images as $image)
               <li>
                  <img src="{{ url('assets/images/uploads/news/'.$datas->id.'/thumbnails/'.$image->image) }}">
                  <div class="clearfix"></div>
                  <div class="delete">
                     <label class="m-checkbox">
                        <input name="deletePhoto[{{ $image->id }}]" type="checkbox">Sil
                        <span></span>
                     </label>
                  </div>
               </li>
               @endforeach
            </ul>
            <div class="clearfix"></div>
            @endif
         </div>
         <div class="tab-pane" id="seo" role="tabpanel">
            <div class="col-md-6 pull-left">
               {{
               Form::bsText(
               'slug',
               'Slug',
               'Bu alan benzersiz adresinizi ifade ediyor. Örn. siteniz.com/{slug}',
               $datas['slug'],
               $attribute = ['id' => 'meta-url']
               )
               }}
               {{
               Form::bsText(
               'meta_title',
               'Başlık',
               'Bu alan google aramalarda görünecek başlık kısmını ifade ediyor. (60 karakteri geçmemesi önerilir.)',
               $datas['meta_title'],
               $attribute = ['id' => 'meta-title']
               )
               }}
               {{
               Form::bsTextarea(
               'meta_description',
               'Açıklama',
               'Bu alan google aramalarda görünecek açıklama kısmını ifade ediyor. (320 karakteri geçmemesi önerilir.)',
               $datas['meta_description'],
               $attribute = ['id' => 'meta-desc']
               )
               }}
               {{
               Form::bsText(
               'meta_image',
               'Görsel',
               'Bu alan google aramalarda görünecek resim kısmını ifade ediyor. (600x315px ebatlarında bir görsel adresi girmelisiniz.)',
               $datas['meta_image'],
               $attribute = ['id' => 'meta-featured-image']
               )
               }}
            </div>
            <div class="col-md-6 pull-right">
               <h6>Google arama sonuçu görünümü</h6>
               <div id="seopreview-google"></div>
               <h6>Facebook paylaşım görünümü</h6>
               <div id="seopreview-facebook"></div>
            </div>
            <div class="clearfix"></div>
            
         </div>
         
      </div>
   </div>

   <div class="m-portlet__foot m-portlet__foot--fit">
      <div class="m-form__actions m-form__actions pull-right">
         <div class="row">
            <div class="col-lg-12 ml-lg-auto">
               <a href="{!! route('news.index') !!}" class="btn btn-secondary">Geri</a>

               {!! Form::submit('Kaydet', ['class'=>'btn btn-brand']) !!}
            </div>
         </div>
      </div>
   </div>
   <div class="clearfix"></div>
</div>
<div class="clearfix"></div>

{!! Form::close() !!}

<!--end::Form-->

edit.blade.php code screen.

@extends('backend.app')
@section('content')
    <div class="m-alert m-alert--icon m-alert--air m-alert--square alert alert-dismissible m--margin-bottom-30" role="alert">
        <div class="m-alert__icon">
            <i class="flaticon-exclamation m--font-brand"></i>
        </div>
        <div class="m-alert__text">
            Bu bölümden sitenizin haberlerini yönetebilirsiniz.
        </div>
    </div>
    <div class="m-portlet m-portlet--mobile">
        <div class="m-portlet__head">
            <div class="m-portlet__head-caption">
                <div class="m-portlet__head-title">
                    <h3 class="m-portlet__head-text">
                    Haberler
                    </h3>
                </div>
            </div>
        </div>
        @include('backend.news.form')
    </div>

@section('css')
    <link href="/backend/assets/custom/css/style.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="/backend/assets/app/css/jquery-seopreview.css">
@endsection

@section('js')
    <script src="/backend/assets/demo/default/custom/header/actions.js" type="text/javascript"></script>
    <script src="/backend/assets/demo/default/custom/components/forms/widgets/bootstrap-switch.js" type="text/javascript"></script>
    <script src="/backend/assets/demo/default/custom/components/base/sweetalert2.js" type="text/javascript"></script>
    <script src="/backend/assets/demo/default/custom/components/forms/widgets/dropzone.js" type="text/javascript"></script>
    <script src="/backend/assets/app/js/jquery-seopreview.js"></script>
    <script type="text/javascript">
       $(document).ready(function() {
         $.seoPreview({
           google_div: "#seopreview-google",
           facebook_div: "#seopreview-facebook",
           metadata: {
             title: $('#meta-title'),
             desc: $('#meta-desc'),
             url: {
                use_slug: true,
                base_domain: '{{url('')}}/',
                full_url: $('#meta-url')
             }
           },
           google: {
               show: true,
               date: false
           },
           facebook: {
               show: true,
               featured_image: $('#meta-featured-image')
           }
         });
         $("select[selectedvalue]").each(function(){
            var self = $(this);
            self.val(self.attr("selectedvalue"));
        });
       });
     </script>

@if ($errors->any())
<script type="text/javascript">
    Swal({
      title: 'Hata!',
      text: '@foreach ($errors->all() as $error) {{ $error }} @endforeach',
      type: 'error',
      confirmButtonText: 'Tamam'
    })
</script>
@endif

@endsection

@endsection

create.blade.php code screen.

@extends('backend.app')
@section('content')
    <div class="m-alert m-alert--icon m-alert--air m-alert--square alert alert-dismissible m--margin-bottom-30" role="alert">
        <div class="m-alert__icon">
            <i class="flaticon-exclamation m--font-brand"></i>
        </div>
        <div class="m-alert__text">
            Bu bölümden sitenizin haberlerini yönetebilirsiniz.
        </div>
    </div>
    <div class="m-portlet m-portlet--mobile">
        <div class="m-portlet__head">
            <div class="m-portlet__head-caption">
                <div class="m-portlet__head-title">
                    <h3 class="m-portlet__head-text">
                    Haberler
                    </h3>
                </div>
            </div>
        </div>
        @include('backend.news.form')
    </div>
@section('css')
    <link href="/backend/assets/custom/css/style.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="/backend/assets/app/css/jquery-seopreview.css">
@endsection


@section('js')
    <script src="/backend/assets/demo/default/custom/header/actions.js" type="text/javascript"></script>
    <script src="/backend/assets/demo/default/custom/components/forms/widgets/bootstrap-switch.js" type="text/javascript"></script>
    <script src="/backend/assets/demo/default/custom/components/base/sweetalert2.js" type="text/javascript"></script>
    <script src="/backend/assets/demo/default/custom/components/forms/widgets/dropzone.js" type="text/javascript"></script>
    <script src="/backend/assets/app/js/jquery-seopreview.js"></script>
    <script type="text/javascript">
       $(document).ready(function() {
        $( "#meta-title" ).click(function() {
          $( "#meta-title" ).val('');
        });
        $( "#meta-desc" ).click(function() {
          $( "#meta-desc" ).val('');
        });
        $( "#meta-featured-image" ).click(function() {
          $( "#meta-featured-image" ).val('');
        });
         $.seoPreview({
           google_div: "#seopreview-google",
           facebook_div: "#seopreview-facebook",
           metadata: {
             title: $('#meta-title'),
             desc: $('#meta-desc'),
             url: {
                use_slug: true,
                base_domain: '{{url('')}}/',
               full_url: $('#meta-url')
             }

           },
           google: {
               show: true,
               date: false
           },
           facebook: {
               show: true,
               featured_image: $('#meta-featured-image')
           }
         });
       });
     </script>
@if ($errors->any())
<script type="text/javascript">
    Swal({
      title: 'Hata!',
      text: '@foreach ($errors->all() as $error) {{ $error }} @endforeach',
      type: 'error',
      confirmButtonText: 'Tamam'
    })
</script>
@endif


@endsection

@endsection