Why do i get a blank page when running this code? [closed]

When i uncomment any one of the commented lines and reload the webpage i end up with a blank page.
If I run the file in the command line the result looks fine.
Do you know where my mistake is?

This is my code:

<?php
   $daten = fopen("statistikpool.txt","a+");
   //$zeile = fgetcsv($daten,100);
   //fclose($daten);
?>
<!DOCTYPE html>
<html>

<body>
The content of the body element is displayed in your browser.
<?php
echo "test";
?>
</body>
</html>

A database error only returns a nothing more error and the code is short

Error:

Fatal error: Uncaught Error: Call to undefined function
mysqli_result() in > C:xampphtdocsunityodczytDanych.php:12 Stack
trace: #0 {main} thrown in C:xampphtdocsunityodczytDanych.php on
line 12

Hello, I am a learning programmer, I do not know why the code does not work or someone can help me find the problem or help me fix it.

code:

<?PHP
$tabela = $_POST['tabela'];
$gracz = $_POST['gracz'];
$zmiennaIN = $_POST['zmienna'];

$con = mysqli_connect("localhost","root","") or ("Blad polaczenia: "  . mysqli_error());
if (!$con)
    die('Nie mozna polaczayc: ' . mysqli_error());
    
mysqli_select_db($con, "konta") or die ("Nie mozna wczytac bazy danych" . mysqli_error());

$zmiennaOUT = mysqli_result(mysqli_query($con, "SELECT '".$zmiennaIN."' FROM '".$tabela."' WHERE login='".$gracz."'"), 0);

die ($zmiennaOUT);

?>

Symfony5 – AJAX | How to change options of select dynamically?

Good morning everyone! This is my first question, and also my first project with Symfony (student project), so please be indulgent! 😀

I’m trying to create an application with Symfony, which aims to allow a user to manage his budget, by creating, removing and editing transactions. I have created my project, and also my entities with Doctrine, everything is well for now, the project perfectly works with Crud and database.

But, I have a problem (of course, if I hadn’t, I wouldn’t be writing this question!). As you can see on the wollowing picture, a new transaction is created with a form, with the following inputs: a name, an amount, a type and a category. A type is either a debit or a credit, and the category input represents the usage of the transaction (salary, bills, shopping, etc.)

My problem is that I would like to adapt the options of the Category select dynamically, depending on the value of the Type select (for example, if credit is chosed, it shows salary, and if it’s debit, then the options will be bills and shopping). I know that the best way to proceed is to use AJAX, but I have some problems implementing it. Indeed, I already developed the adaptation of the Category options depeding on the value setted for the Type select, but on load of the webpage. Now, I would like to trigger this event on change with AJAX, and this is where I struggle… 🙁 Here is my code:

templatestransactionnew.html.twig

{% extends 'base.html.twig' %}

{% block title %}New Transaction{% endblock %}

{% block body %}
    <h1>Create new Transaction</h1>

    {{ form(form)}}

    <button type="submit" class="btn" formonvalidate>Valider</button>

    <a href="{{ path('app_transaction_index') }}">back to list</a>
{% endblock %}

templatesbase.html.twig

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>{% block title %}Welcome!{% endblock %}</title>
        <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>⚫️</text></svg>">
        {# Run `composer require symfony/webpack-encore-bundle` to start using Symfony UX #}
        {% block stylesheets %}
            {{ encore_entry_link_tags('app') }}
        {% endblock %}
    </head>
    <body>
        {% block body %}{% endblock %}
        {% block javascripts %}{% endblock %}
    </body>
</html>

srcControllerHomeController.php

<?php

namespace AppController;

use SymfonyBundleFrameworkBundleControllerAbstractController;
use SymfonyComponentHttpFoundationResponse;
use SymfonyComponentRoutingAnnotationRoute;

class HomeController extends AbstractController
{
    #[Route('/home', name: 'app_home')]
    public function index(): Response
    {
        return $this->render('home/index.html.twig', [
            'controller_name' => 'HomeController',
        ]);
    }
}

srcRepositoryCategoryRepository.php

<?php

namespace AppRepository;

use AppEntityCategory;
use DoctrineBundleDoctrineBundleRepositoryServiceEntityRepository;
use DoctrinePersistenceManagerRegistry;
use AppEntityType;

/**
 * @extends ServiceEntityRepository<Category>
 *
 * @method Category|null find($id, $lockMode = null, $lockVersion = null)
 * @method Category|null findOneBy(array $criteria, array $orderBy = null)
 * @method Category[]    findAll()
 * @method Category[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
 */
class CategoryRepository extends ServiceEntityRepository
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, Category::class);
    }

    public function add(Category $entity, bool $flush = false): void
    {
        $this->getEntityManager()->persist($entity);

        if ($flush) {
            $this->getEntityManager()->flush();
        }
    }

    public function remove(Category $entity, bool $flush = false): void
    {
        $this->getEntityManager()->remove($entity);

        if ($flush) {
            $this->getEntityManager()->flush();
        }
    }

    public function findByTypeOrderedByAscName(Type $type): array
    {
        return $this->createQueryBuilder('c')
            ->andWhere('c.type = :type')
            ->setParameter('type', $type)
            ->orderBy('c.title', 'ASC')
            ->getQuery()
            ->getResult()
        ;
    }
}

srcFormTransactionType.php

<?php

namespace AppForm;

use AppEntityTransaction;
use SymfonyComponentFormAbstractType;
use SymfonyComponentFormFormBuilderInterface;
use SymfonyComponentOptionsResolverOptionsResolver;
use SymfonyComponentFormFormEvents;
use SymfonyComponentFormFormEvent;
use SymfonyBridgeDoctrineFormTypeEntityType;
use AppRepositoryTypeRepository;
use AppRepositoryCategoryRepository;

class TransactionType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('name')
            ->add('montant')
            ->add('type')
            ->add('category')
        ;
    }

    public function configureOptions(OptionsResolver $resolver): void
    {
        $resolver->setDefaults([
            'data_class' => Transaction::class,
        ]);
    }
}

srcControllerTransactionController.php

<?php

namespace AppController;

use AppEntityTransaction;
use AppFormTransactionType;
use AppRepositoryTransactionRepository;
use SymfonyBundleFrameworkBundleControllerAbstractController;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentHttpFoundationResponse;
use SymfonyComponentRoutingAnnotationRoute;
use SymfonyComponentFormFormEvents;
use SymfonyComponentFormFormEvent;
use SymfonyBridgeDoctrineFormTypeEntityType;
use AppRepositoryTypeRepository;
use AppRepositoryCategoryRepository;
use SymfonyComponentValidatorConstraintsNotBlank;

#[Route('/transaction')]
class TransactionController extends AbstractController
{
    #[Route('/', name: 'app_transaction_index', methods: ['GET'])]
    public function index(TransactionRepository $transactionRepository): Response
    {
        return $this->render('transaction/index.html.twig', [
            'transactions' => $transactionRepository->findAll(),
        ]);
    }

    #[Route('/new', name: 'app_transaction_new', methods: ['GET', 'POST'])]
    public function new(Request $request, TypeRepository $typeRepository, CategoryRepository $categoryRepository): Response
    {
        $form = $this->createFormBuilder(['type' => $typeRepository->find(0)])
            ->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event) use ($categoryRepository) {
                $type = $event->getData()['type'] ?? null;

                $categories = $type === null ? [] : $categoryRepository->findByTypeOrderedByAscName($type);

                $event->getForm()->add('category', EntityType::class, [
                    'class' => 'AppEntityCategory',
                    'choice_label' => 'title',
                    'choices' => $categories,
                    'disabled' => $type === null,
                    'placeholder' => "Sélectionnez une catégorie",
                    'constraints' => new NotBlank(['message' => 'Sélectionnez une catégorie'])
                ]);
            })
            ->add('name')
            ->add('montant')
            ->add('type', EntityType::class, [
                'class' => 'AppEntityType',
                'choice_label' => 'title',
                'placeholder' => "Sélectionnez un type",
                'constraints' => new NotBlank(['message' => 'Sélectionnez un type'])
            ])
            ->getForm();

        return $this->renderForm('transaction/new.html.twig', compact('form'));
    }

    #[Route('/{id}', name: 'app_transaction_show', methods: ['GET'])]
    public function show(Transaction $transaction): Response
    {
        return $this->render('transaction/show.html.twig', [
            'transaction' => $transaction,
        ]);
    }

    #[Route('/{id}/edit', name: 'app_transaction_edit', methods: ['GET', 'POST'])]
    public function edit(Request $request, Transaction $transaction, TransactionRepository $transactionRepository): Response
    {
        $form = $this->createForm(TransactionType::class, $transaction);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $transactionRepository->add($transaction, true);

            return $this->redirectToRoute('app_transaction_index', [], Response::HTTP_SEE_OTHER);
        }

        return $this->renderForm('transaction/edit.html.twig', [
            'transaction' => $transaction,
            'form' => $form,
        ]);
    }

    #[Route('/{id}', name: 'app_transaction_delete', methods: ['POST'])]
    public function delete(Request $request, Transaction $transaction, TransactionRepository $transactionRepository): Response
    {
        if ($this->isCsrfTokenValid('delete'.$transaction->getId(), $request->request->get('_token'))) {
            $transactionRepository->remove($transaction, true);
        }

        return $this->redirectToRoute('app_transaction_index', [], Response::HTTP_SEE_OTHER);
    }
}

srcEntityTransaction.php

<?php

namespace AppEntity;

use AppRepositoryTransactionRepository;
use DoctrineORMMapping as ORM;
use MonologDateTimeImmutable;

#[ORMEntity(repositoryClass: TransactionRepository::class)]
class Transaction
{
    #[ORMId]
    #[ORMGeneratedValue]
    #[ORMColumn(type: 'integer')]
    private $id;

    #[ORMColumn(type: 'string', length: 255)]
    private $name;

    #[ORMColumn(type: 'float')]
    private $montant;

    #[ORMColumn(type: 'datetime_immutable')]
    private $createdAt;

    #[ORMManyToOne(targetEntity: Type::class, inversedBy: 'transactions')]
    #[ORMJoinColumn(nullable: true)]
    private $type;

    #[ORMManyToOne(targetEntity: User::class, inversedBy: 'transactions')]
    #[ORMJoinColumn(nullable: false)]
    private $user;

    #[ORMManyToOne(targetEntity: Category::class, inversedBy: 'transactions')]
    #[ORMJoinColumn(nullable: false)]
    private $category;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getName(): ?string
    {
        return $this->name;
    }

    public function setName(string $name): self
    {
        $this->name = $name;

        return $this;
    }

    public function getMontant(): ?float
    {
        return $this->montant;
    }

    public function setMontant(float $montant): self
    {
        $this->montant = $montant;

        return $this;
    }

    public function getCreatedAt(): ?DateTimeImmutable
    {
        return $this->createdAt;
    }

    public function setCreatedAt(DateTimeImmutable $createdAt): self
    {
        $this->createdAt = $createdAt;

        return $this;
    }

    public function getType(): ?Type
    {
        return $this->type;
    }

    public function setType(?Type $type): self
    {
        $this->type = $type;

        return $this;
    }

    public function getUser(): ?User
    {
        return $this->user;
    }

    public function setUser(?User $user): self
    {
        $this->user = $user;

        return $this;
    }

    public function getCategory(): ?Category
    {
        return $this->category;
    }

    public function setCategory(?Category $category): self
    {
        $this->category = $category;

        return $this;
    }

    public function __construct() {
        $this->createdAt = new DateTimeImmutable(date('d-m-Y H:i:s'), new DateTimeZone("Europe/Paris"));
    }

    public function __toString() {
        return $this->getName();
    }
}

srcEntityType.php

<?php

namespace AppEntity;

use AppRepositoryTypeRepository;
use DoctrineCommonCollectionsArrayCollection;
use DoctrineCommonCollectionsCollection;
use DoctrineORMMapping as ORM;

#[ORMEntity(repositoryClass: TypeRepository::class)]
class Type
{
    #[ORMId]
    #[ORMGeneratedValue]
    #[ORMColumn(type: 'integer')]
    private $id;

    #[ORMColumn(type: 'string', length: 50)]
    private $title;

    #[ORMColumn(type: 'integer')]
    private $coefficient;

    #[ORMOneToMany(mappedBy: 'type', targetEntity: Category::class, orphanRemoval: true)]
    private $categories;

    #[ORMOneToMany(mappedBy: 'type', targetEntity: Transaction::class)]
    private $transactions;

    public function __construct()
    {
        $this->categories = new ArrayCollection();
        $this->transactions = new ArrayCollection();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getTitle(): ?string
    {
        return $this->title;
    }

    public function setTitle(string $title): self
    {
        $this->title = $title;

        return $this;
    }

    public function getCoefficient(): ?int
    {
        return $this->coefficient;
    }

    public function setCoefficient(int $coefficient): self
    {
        $this->coefficient = $coefficient;

        return $this;
    }

    /**
     * @return Collection<int, Category>
     */
    public function getCategories(): Collection
    {
        return $this->categories;
    }

    public function addCategory(Category $category): self
    {
        if (!$this->categories->contains($category)) {
            $this->categories[] = $category;
            $category->setType($this);
        }

        return $this;
    }

    public function removeCategory(Category $category): self
    {
        if ($this->categories->removeElement($category)) {
            // set the owning side to null (unless already changed)
            if ($category->getType() === $this) {
                $category->setType(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, Transaction>
     */
    public function getTransactions(): Collection
    {
        return $this->transactions;
    }

    public function addTransaction(Transaction $transaction): self
    {
        if (!$this->transactions->contains($transaction)) {
            $this->transactions[] = $transaction;
            $transaction->setType($this);
        }

        return $this;
    }

    public function removeTransaction(Transaction $transaction): self
    {
        if ($this->transactions->removeElement($transaction)) {
            // set the owning side to null (unless already changed)
            if ($transaction->getType() === $this) {
                $transaction->setType(null);
            }
        }

        return $this;
    }

    public function __toString() {
        return $this->getTitle();
    }
}

srcEntityCategory.php

<?php

namespace AppEntity;

use AppRepositoryCategoryRepository;
use DoctrineCommonCollectionsArrayCollection;
use DoctrineCommonCollectionsCollection;
use DoctrineORMMapping as ORM;

#[ORMEntity(repositoryClass: CategoryRepository::class)]
class Category
{
    #[ORMId]
    #[ORMGeneratedValue]
    #[ORMColumn(type: 'integer')]
    private $id;

    #[ORMColumn(type: 'string', length: 50)]
    private $title;

    #[ORMColumn(type: 'text', nullable: true)]
    private $description;

    #[ORMManyToOne(targetEntity: Type::class, inversedBy: 'categories')]
    #[ORMJoinColumn(nullable: false)]
    private $type;

    #[ORMOneToMany(mappedBy: 'category', targetEntity: Transaction::class, orphanRemoval: true)]
    private $transactions;

    public function __construct()
    {
        $this->transactions = new ArrayCollection();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getTitle(): ?string
    {
        return $this->title;
    }

    public function setTitle(string $title): self
    {
        $this->title = $title;

        return $this;
    }

    public function getDescription(): ?string
    {
        return $this->description;
    }

    public function setDescription(?string $description): self
    {
        $this->description = $description;

        return $this;
    }

    public function getType(): ?Type
    {
        return $this->type;
    }

    public function setType(?Type $type): self
    {
        $this->type = $type;

        return $this;
    }

    /**
     * @return Collection<int, Transaction>
     */
    public function getTransactions(): Collection
    {
        return $this->transactions;
    }

    public function addTransaction(Transaction $transaction): self
    {
        if (!$this->transactions->contains($transaction)) {
            $this->transactions[] = $transaction;
            $transaction->setCategory($this);
        }

        return $this;
    }

    public function removeTransaction(Transaction $transaction): self
    {
        if ($this->transactions->removeElement($transaction)) {
            // set the owning side to null (unless already changed)
            if ($transaction->getCategory() === $this) {
                $transaction->setCategory(null);
            }
        }

        return $this;
    }

    public function __toString() {
        return $this->getTitle();
    }
}

I hope that someone will be able to help me! Thanks in advance, and have a nice day! 😀

PS: I would also like the Category select to be disabled when the Type select’s placeholder is selected, and the Category select to be enabled when a value is selected with the Type select.

How to Allow only Valid Gmail users sign up in my PHP Laravel website?

I have this my sign up form in my php Laravel site which I think hackers and robots are making unnecessary sign-ups. But now, I want to allow only Valid Gmail users to create an account. I have configured this form but users with unknown mails are able to sign up. I’m a newbie in php Laravel codes. Someone should please help me configure this to achieve the goal. Thanks in advance. See form bellow.

 @csrf
                            <div class="form-group">
                                <input type="text" name="name" class="form-control" placeholder="{{__('Full Name')}}">
                            </div>
                            <div class="form-group">
                                <input type="text" name="username" class="form-control" placeholder="{{__('Username')}}">
                            </div>
                            <div class="form-group">
                                <input type="email" name="email" class="form-control" placeholder="{{__('Gmail')}}">
                            </div>
                            <div class="form-group">
                                <input type="tel" name="tel" class="form-control" placeholder="{{__('WhatsApp Number')}}">
                            </div>
                            <div class="form-group">
                                <input type="text" name="gender" class="form-control" placeholder="{{__('Gender')}}">
                            </div>
                            <div class="form-group">
                                <input type="text" name="item" class="form-control" placeholder="{{__('What do you want to buy? Please type in your issues here')}}">
                            </div>

PHP SoapFault Exception : Unsupported Media Type

When I make a request with PHP Soap I get an error like this : “Unsupported Media Type”.

My code :

<?php

try{
$soapUrl = "https://n11integrationtest.digitalplanet.com.tr/IntegrationService.asmx?WSDL";

$client = new SoapClient($soapUrl);
$client->__setLocation($soapUrl);
$postData = array(
    "CorporateCode"=>"xxxxxx",
    "LoginName"=>"xxxxxx",
    "Password"=>"xxxxxx"
);

$result = $client->GetFormsAuthenticationTicket($postData);
echo $result->GetFormsAuthenticationTicketResult;
}
catch(Exception $a){
  echo $a;
}
?>

The solution for this error is in the document it says: “If the messageEncoding format is not selected correctly, “Unsupported Media Type” error is received.

The app config file is written like this in the document :

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"
/> </startup>
<system.serviceModel>
<bindings>
<basicHttpsBinding>
<binding name="IntegrationServiceSoap"
maxReceivedMessageSize="2147483647" sendTimeout="23:59:59" receiveTimeout="23:59:59"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" messageEncoding="Mtom" />
</basicHttpsBinding>
</bindings>
<client>
<endpoint
address="https://n11integrationtest.digitalplanet.com.tr/IntegrationService.asmx"
binding="basicHttpsBinding" bindingConfiguration="IntegrationServiceSoap"
contract="applicationName.IntegrationServiceSoap" name="IntegrationServiceSoap" />
</client>
</system.serviceModel>
</configuration>

So, how can edit my php code ? Thanks..:)

Splitting data between table and drop-down menu Yii2

I have a task to make the following functionality:

enter image description here

The case is I need to be able to add to the table below items from the drop-down menu, so they should be either in drop-down (if tag is not added to the Material model) or in the table (if tag is added). I could easily hard-code it, but it’s also required Add(big blue button) button to add tags and delete button to remove them, which I have no idea how to implement. Tags are stored in another model which has no relation to Material, tags in Material are stored as a string divided by comma. Here’s what I’ve managed to do so far:

Controller:

public function actionView(int $id): string
    {
        $tagSearchModel = new TagSearch();
        $tagDataProvider = $tagSearchModel->search($this->request->queryParams);

        $model = $this->findModel($id);
        $tagsInModel = explode(', ', $model->tags);

        $tag = new Tag();
        $allTags = ArrayHelper::map($tag::find()->all(), 'id', 'name');

        $unUsedTags = [];

        foreach ($allTags as $oneTag) {
            if (!in_array($oneTag, $tagsInModel)){
                $unUsedTags[] = $oneTag;
            }
        }

        return $this->render('view', [
            'model' => $model,
            'unUsedTags' => $unUsedTags,
            'tagDataProvider' => $tagDataProvider
        ]);
    }

View:

<div class="col-md-6">
        <form>
            <h3>Теги</h3>
            <?php $form = ActiveForm::begin(); ?>
            <div class="input-group">
                <?= $form->field($model, 'type')->dropDownList(
                    $unUsedTags,
                    ['prompt' => 'Выберите тип', 'style' => 'width: 270px']
                )->label(false) ?>
                <?= Html::submitButton('Добавить', ['class' => 'btn btn-primary mb-3',])?>
            </div>
            <?php ActiveForm::end(); ?>
        </form>
    </div>
    <?= GridView::widget([
        'dataProvider' => $tagDataProvider,
        'summary' => '',
        'tableOptions' => [
            'class' => 'table table-responsive',
        ],
        'columns' => [
            [
                'attribute' => 'name',
                'label' => 'Название',
                'value' => function (Tag $model) {
                    return Html::a(
                        $model->name,
                        ['index', 'search_query' => $model->name],
                        [
                            'title' => 'View',
                        ]
                    );
                },
                'headerOptions' => ['style' => 'width:90%;'],
                'header' => false,
                'format' => 'raw',
            ],
            [
                'class' => ActionColumn::class,
                'template' => '{delete}',
                'urlCreator' => function ($action, Tag $model, $key, $index, $column) {
                    return Url::toRoute([$action, 'id' => $model->id]);
                }
            ],
        ],
    ]); ?>

TagSearch model:

class TagSearch extends Tag
{
    /**
     * {@inheritdoc}
     */
    public function rules(): array
    {
        return [
            [['id'], 'integer'],
            [['name'], 'safe'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function scenarios(): array
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search(array $params): ActiveDataProvider
    {
        $query = Tag::find();
        
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'id' => $this->id,
        ]);

        $query->andFilterWhere(['like', 'name', $this->name]);

        return $dataProvider;
    }
}

Store PHP value in JSON

I was wondering if there was a way to retrieve a value of a php variabile in a JSON file.
For example, I have this following JSON file (file.json):

{
   "Hello": "Hello $name"
}

And this PHP file:

<?php
$name = "Rick";
$jsonFile = json_decode("file.json", true);
$hello = $jsonFile["Hello"];
echo $hello;
?>

What if I want to echo Hello Rick, instead of Hello $name?
Is it impossibile or is there a way to do it?

How to securely send data from one website to another

I own 2 websites, example.com and domain.com. I want to securely transfer data from example.com to domain.com. I was looking at this question which is trying to answer my main question of how to send data securely from one website to another. However, the answer’s are very old.

I am wondering how I can send do this. I have the below code which basically has the encryption keys saved locally on both websites and encrypts/decrypts data based on that. However, if someone managed to guess the key, they can decrypt all the messages. Is the way I have stated below a secure method to transfer data? Or is there a better way?

function encrypt($key, $data) {
    $encryption_key = base64_decode( $key );
    if ($encryption_key === FALSE) {
        return FALSE;
    }

    $iv = openssl_cipher_iv_length('aes-256-cbc');
    if ($iv === FALSE) {
        return FALSE;
    }

    $iv = openssl_random_pseudo_bytes($iv);
    if ($iv === FALSE) {
        return FALSE;
    }

    $encrypted = openssl_encrypt($data, 'aes-256-cbc', $encryption_key, 0, $iv);
    if ($encrypted === FALSE) {
        return FALSE;
    }

    return base64_encode($encrypted . '::' . $iv);
}

function decrypt($key, $data) {

    $encryption_key = base64_decode( $key );
    if ($encryption_key === FALSE) {
        return FALSE;
    }

    $decoded_data = base64_decode($data);
    if ($decoded_data === FALSE) {
        return FALSE;
    }

    list($encrypted_data, $iv) = array_pad(explode('::', $decoded_data, 2),2,null);

    $decryption = openssl_decrypt($encrypted_data, 'aes-256-cbc', $encryption_key, 0, $iv);
    if ($decryption === FALSE) {
        return FALSE;
    }

    return $decryption;
}

So this is what would be used, and I would send the encrypted data via POST request using cURL to domain.com

// On example.com (aka sending data)
$example_key = 'key_is_123';
$data = "My secret is that I like apples";
$encrypted_msg = encrypt($example_key, $data);

echo("Sending encrypted message:n$encrypted_msgnn");

// Send $encrypted_msg message via a POST request using cURL to domain.com

// On domain.com (aka receiving data)
$domain_key = $example_key;
$decrypted_msg = decrypt($domain_key, $encrypted_msg);

echo("Recieved messaged and decrypted message:n$decrypted_msg");

I needed to enter a maximum capacity and enter 3 different weights

So here is the code to my current inputs for getting the max capacity and the three weights:

$maxW = readline('Enter the maximum capacity: ');
    $wei = readline('Enter the three weights: ');

Here is a loop for getting the max two numbers:

$array = array_map('intval',explode(" ", $wei));
    $max=$max2=0;
    
    for ($i = 0; $i < count($array); $i++){
        if($i==0){
            $max2 = $array[$i];
        }

        if($array[$i] > $max){
            $max = $array[$i];
        }

        if($max > $array[$i] && $array[$i] > $max2){
            $max2 = $array[$i];
        }
    }

    echo "The two weights are " . $max . "and " . $max2;

Where did I mess up?

My real output should be this:

Enter the Maximum capacity: 10

Enter the three weights: 5 3 4

The Two weights are 5 and 4.

Telegram sendPhoto with multipart/form-data not working?

Hi I am trying to send an image. The documentation states that I can send a file using multipart/form-data.

enter image description here

Here is my code:

// I checked it, there really is a file.
$file = File::get(Storage::disk('local')->path('test.jpeg')) // it's the same as file_get_contents();

// Here I use the longman/telegram-bot library.
$serverResponse = Request::sendPhoto([
    'chat_id' => $this->tg_user_chat_id,
    'photo' => $file
]);

// Here I use Guzzle because I thought that there might be an 
// error due to the longman/telegram-bot library.
$client = new Client();
$response = $client->post("https://api.telegram.org/$telegram->botToken/sendPhoto", [
    'multipart' => [
        [
            'name'     => 'photo',
            'contents' => $file
        ],
        [
            'name'     => 'chat_id',
            'contents' => $this->tg_user_chat_id
        ]
    ]
]);

Log::info('_response', ['_' => $response->getBody()]);
Log::info(env('APP_URL') . "/storage/$url");
Log::info('response:', ['_' => $serverResponse->getResult()]);
Log::info('ok:', ['_' => $serverResponse->getOk()]);
Log::info('error_code:', ['_' => $serverResponse->getErrorCode()]);
Log::info('raw_data:', ['_' => $serverResponse->getRawData()]);

In both cases, I get this response:

{"ok":false,"error_code":400,"description":"Bad Request: invalid file HTTP URL specified: Wrong URL host"}

Other download methods (by ID and by link) work. Can anyone please point me in the right direction?

Apache php-fpm mod_rewrite ignoring php files

I have an issue with using php-fpm and mod_rewrite
There are mulitple rewrite rules as follows.

ReWriteRule ^/accounts$ /accounts.php [L]

If I go directly to accounts.php the page loads fine. If I go via the rule is loads the php code.

I believe it is caused because the apache config is looking for .php files to pass to php-fpm

ProxyPassMatch ^/(.*.php(/.*)?)$ "fcgi://127.0.0.1:9000/var/www/vhosts/example.com/public"

I am unable to find a good solution to allow php files to be detected with search engine friendly rewrite rules.

How to get values in an array from nested array of objects based on a lodash? I need retrieve only DMA values

I need retrieve only DMA values

[
{
“RMId”: 1,
“RSCId”: 1,
“RMName”: “Colombo South”,
“BillingRegionCode”: “10”,
“MobileNo”: “0773785860”,
“CostCenterCode”: “01/2/00”,
“EmailAddress”: “[email protected]”,
“Areas”: [
{
“AEId”: 1,
“AEName”: “AE_Pamankada”,
“ContactNo”: “2086266”,
“MobileNo”: “0761303591”,
“EmailAddress”: “[email protected]”,
“RMId”: 1,
“OICList”: [
{
“OICId”: 243,
“OICZoneName”: “Night Gang (Pamankada)”,
“MobileNo”: “0773907134”,
“CostCenterCode”: null,
“ZoneOfficers”: [
{
“ZoneOfficerId”: 69,
“OICId”: 243,
“MobileNo”: “2222222222”,
“EmpNo”: 2044617,
“NameOfOfficer”: “AN Rifas”,
“TelNo”: “0773479809”,
“EmailAddress”: “[email protected]”,
“Zone”: null,
“DMA”: []
},
{
“ZoneOfficerId”: 87,
“OICId”: 243,
“MobileNo”: “0716185452”,
“EmpNo”: 1111111,
“NameOfOfficer”: “Nadeeka”,
“TelNo”: “0112853844”,
“EmailAddress”: “111”,
“Zone”: “”,
“DMA”: []
},
{
“ZoneOfficerId”: 88,
“OICId”: 243,
“MobileNo”: “0773948767”,
“EmpNo”: 111111,
“NameOfOfficer”: “Rajapaksha”,
“TelNo”: “0773948767”,
“EmailAddress”: “111”,
“Zone”: null,
“DMA”: []
},
{
“ZoneOfficerId”: 89,
“OICId”: 243,
“MobileNo”: “0718464550”,
“EmpNo”: 11111111,
“NameOfOfficer”: “Champika Siriwardana”,
“TelNo”: “0112853844”,
“EmailAddress”: “11”,
“Zone”: null,
“DMA”: []
}
]
},
{
“OICId”: 244,
“OICZoneName”: “OIC_Pamankada”,
“MobileNo”: “0718721080”,
“CostCenterCode”: “01206”,
“ZoneOfficers”: [
{
“ZoneOfficerId”: 86,
“OICId”: 244,
“MobileNo”: “0718721080”,
“EmpNo”: 2037114,
“NameOfOfficer”: “P.G.D.K. Jayawardana”,
“TelNo”: “0112853844”,
“EmailAddress”: “[email protected]”,
“Zone”: “OIC”,
“DMA”: [
{
“Description”: “Thimbirigasyaya”,
“AEId”: 39,
“NRWZoneId”: 172,
“DMAZoneName”: “10_13_03”,
“BillingZoneId”: 86
}
]
},
{
“ZoneOfficerId”: 164,
“OICId”: 244,
“MobileNo”: “0716185452”,
“EmpNo”: 2046679,
“NameOfOfficer”: “N. Ranasinghe”,
“TelNo”: “0112853844”,
“EmailAddress”: “[email protected]”,
“Zone”: “Pam_Zone_1”,
“DMA”: [
{
“Description”: “Independence Square”,
“AEId”: 39,
“NRWZoneId”: 170,
“DMAZoneName”: “170”,
“BillingZoneId”: 164
},
{
“Description”: “Independence Square”,
“AEId”: 39,
“NRWZoneId”: 170,
“DMAZoneName”: “10_13_01”,
“BillingZoneId”: 164
}
]
},
{
“ZoneOfficerId”: 525,
“OICId”: 244,
“MobileNo”: “0718464550”,
“EmpNo”: 2022206,
“NameOfOfficer”: “P.C. Siriwardena”,
“TelNo”: “0112853844”,
“EmailAddress”: “[email protected]”,
“Zone”: “Pam_Zone_2”,
“DMA”: []
},
{
“ZoneOfficerId”: 739,
“OICId”: 244,
“MobileNo”: “0718186830”,
“EmpNo”: 2026180,
“NameOfOfficer”: “R.A.S.A. Rajapaksha”,
“TelNo”: “0112853844”,
“EmailAddress”: “[email protected]”,
“Zone”: “Pam_OIC”,
“DMA”: []
}
]
},
{
“OICId”: 245,
“OICZoneName”: “OIC_Thimbirigasyaya”,
“MobileNo”: “0777800162”,
“CostCenterCode”: “01205”,
“ZoneOfficers”: [
{
“ZoneOfficerId”: 724,
“OICId”: 245,
“MobileNo”: “777800162”,
“EmpNo”: 2024144,
“NameOfOfficer”: “R.A.P. Ranasinghe”,
“TelNo”: “112769003”,
“EmailAddress”: “[email protected]”,
“Zone”: “OIC”,
“DMA”: []
},
{
“ZoneOfficerId”: 725,
“OICId”: 245,
“MobileNo”: “0715533613”,
“EmpNo”: 2075705,
“NameOfOfficer”: “D. Heenatigala”,
“TelNo”: “0112769003”,
“EmailAddress”: “[email protected]”,
“Zone”: “Thimbiri_Zone_1”,
“DMA”: []
},
{
“ZoneOfficerId”: 726,
“OICId”: 245,
“MobileNo”: “0775287594”,
“EmpNo”: 2018268,
“NameOfOfficer”: “P.K. Welikala”,
“TelNo”: “0112769003”,
“EmailAddress”: “[email protected]”,
“Zone”: “Thimbiri_Zone_2”,
“DMA”: []
},
{
“ZoneOfficerId”: 743,
“OICId”: 245,
“MobileNo”: “777328851”,
“EmpNo”: 2040026,
“NameOfOfficer”: “R. Abesiriwardana”,
“TelNo”: “0112769003”,
“EmailAddress”: “[email protected]”,
“Zone”: “Thimbiri_Zone_3”,
“DMA”: []
}
]
},
{
“OICId”: 721,
“OICZoneName”: “Night Gang Fort (Hultsdrof / SlaveIsland)”,
“MobileNo”: “0773909868”,
“CostCenterCode”: null,
“ZoneOfficers”: []
}
]
},
{
“AEId”: 2,
“AEName”: “AE_Fort”,
“ContactNo”: “2681975”,
“MobileNo”: “0711531359”,
“EmailAddress”: “[email protected]”,
“RMId”: 1,
“OICList”: [
{
“OICId”: 246,
“OICZoneName”: “OIC Slave Island”,
“MobileNo”: “0773620347”,
“CostCenterCode”: “01207”,
“ZoneOfficers”: [
{
“ZoneOfficerId”: 556,
“OICId”: 246,
“MobileNo”: “0777227798”,
“EmpNo”: 2020114,
“NameOfOfficer”: “M T G Senanayaka”,
“TelNo”: “0112448547”,
“EmailAddress”: “[email protected]”,
“Zone”: “Slave_Zone_1”,
“DMA”: [
{
“Description”: “Pettah”,
“AEId”: 38,
“NRWZoneId”: 217,
“DMAZoneName”: “10_14_02”,
“BillingZoneId”: 556
},
{
“Description”: “Fort”,
“AEId”: 38,
“NRWZoneId”: 218,
“DMAZoneName”: “10_14_03”,
“BillingZoneId”: 556
},
{
“Description”: “Port City”,
“AEId”: 38,
“NRWZoneId”: 219,
“DMAZoneName”: “10_14_04”,
“BillingZoneId”: 556
},
{
“Description”: “York Street”,
“AEId”: 38,
“NRWZoneId”: 220,
“DMAZoneName”: “10_14_05”,
“BillingZoneId”: 556
},
{
“Description”: “Galle Face”,
“AEId”: 38,
“NRWZoneId”: 229,
“DMAZoneName”: “10_14_14”,
“BillingZoneId”: 556
},
{
“Description”: “D R Wijewardane Mawatha”,
“AEId”: 38,
“NRWZoneId”: 226,
“DMAZoneName”: “10_14_11”,
“BillingZoneId”: 556
},
{
“Description”: “Slave Island”,
“AEId”: 38,
“NRWZoneId”: 227,
“DMAZoneName”: “10_14_12”,
“BillingZoneId”: 556
}
]
},
{
“ZoneOfficerId”: 557,
“OICId”: 246,
“MobileNo”: “0717545229”,
“EmpNo”: 2077510,
“NameOfOfficer”: “N.D. Panditharathne”,
“TelNo”: “0112448547”,
“EmailAddress”: “[email protected]”,
“Zone”: “Slave_Zone_2”,
“DMA”: [
{
“Description”: “Kollupitiya North”,
“AEId”: 38,
“NRWZoneId”: 233,
“DMAZoneName”: “10_14_18”,
“BillingZoneId”: 557
},
{
“Description”: “Kollupitiya South”,
“AEId”: 38,
“NRWZoneId”: 234,
“DMAZoneName”: “10_14_19”,
“BillingZoneId”: 557
}
]
},
{
“ZoneOfficerId”: 740,
“OICId”: 246,
“MobileNo”: “0773359774”,
“EmpNo”: 2076249,
“NameOfOfficer”: “D. N. De Silva”,
“TelNo”: “0112448547”,
“EmailAddress”: “[email protected]”,
“Zone”: “Slave_Zone_3”,
“DMA”: [
{
“Description”: “Union Place”,
“AEId”: 38,
“NRWZoneId”: 228,
“DMAZoneName”: “10_14_13”,
“BillingZoneId”: 740
},
{
“Description”: “Temple Trees”,
“AEId”: 38,
“NRWZoneId”: 232,
“DMAZoneName”: “10_14_17”,
“BillingZoneId”: 740
},
{
“Description”: “Nawam Mawatha”,
“AEId”: 38,
“NRWZoneId”: 230,
“DMAZoneName”: “10_14_15”,
“BillingZoneId”: 740
},
{
“Description”: “Gangaramaya”,
“AEId”: 38,
“NRWZoneId”: 231,
“DMAZoneName”: “10_14_16”,
“BillingZoneId”: 740
}
]
},
{
“ZoneOfficerId”: 741,
“OICId”: 246,
“MobileNo”: “0773620347”,
“EmpNo”: 77828,
“NameOfOfficer”: “S M L A de Alwis”,
“TelNo”: “0112448547”,
“EmailAddress”: “[email protected]”,
“Zone”: “Night Gang OIC Slave Island”,
“DMA”: []
}
]
},
{
“OICId”: 247,
“OICZoneName”: “OIC Hultsdrof”,
“MobileNo”: “0773621018”,
“CostCenterCode”: “01208”,
“ZoneOfficers”: [
{
“ZoneOfficerId”: 120,
“OICId”: 247,
“MobileNo”: “0753368322”,
“EmpNo”: 2005693,
“NameOfOfficer”: “T.N.K.Weerakkodi”,
“TelNo”: “0112445036”,
“EmailAddress”: “[email protected]”,
“Zone”: “OIC”,
“DMA”: []
},
{
“ZoneOfficerId”: 121,
“OICId”: 247,
“MobileNo”: “0765003754”,
“EmpNo”: 2075612,
“NameOfOfficer”: “A. H. Samararathne”,
“TelNo”: “0112445036”,
“EmailAddress”: “[email protected]”,
“Zone”: “Hultsd_Zone_1”,
“DMA”: [
{
“Description”: “Sangamitta Mawatha”,
“AEId”: 38,
“NRWZoneId”: 224,
“DMAZoneName”: “10_14_09”,
“BillingZoneId”: 121
},
{
“Description”: “Sangaraja Mawatha”,
“AEId”: 38,
“NRWZoneId”: 225,
“DMAZoneName”: “10_14_10”,
“BillingZoneId”: 121
}
]
},
{
“ZoneOfficerId”: 452,
“OICId”: 247,
“MobileNo”: “0765006319”,
“EmpNo”: 2060540,
“NameOfOfficer”: “D. M. S. Saparamadu”,
“TelNo”: “0112445036”,
“EmailAddress”: “[email protected]”,
“Zone”: “Hultsd_Zone_2”,
“DMA”: [
{
“Description”: “Dam Street”,
“AEId”: 38,
“NRWZoneId”: 222,
“DMAZoneName”: “10_14_07”,
“BillingZoneId”: 452
},
{
“Description”: “Aluthkade”,
“AEId”: 38,
“NRWZoneId”: 223,
“DMAZoneName”: “10_14_08”,
“BillingZoneId”: 452
}
]
},
{
“ZoneOfficerId”: 555,
“OICId”: 247,
“MobileNo”: “0765006303”,
“EmpNo”: 2054523,
“NameOfOfficer”: “R.I.U. Karunathilaka”,
“TelNo”: “0112445036”,
“EmailAddress”: “[email protected]”,
“Zone”: “Hultsd_Zone_3”,
“DMA”: [
{
“Description”: “Jampettah”,
“AEId”: 38,
“NRWZoneId”: 216,
“DMAZoneName”: “10_14_01”,
“BillingZoneId”: 555
},
{
“Description”: “Ginthupitiya”,
“AEId”: 38,
“NRWZoneId”: 221,
“DMAZoneName”: “10_14_06”,
“BillingZoneId”: 555
}
]
},
{
“ZoneOfficerId”: 742,
“OICId”: 247,
“MobileNo”: “0718123699”,
“EmpNo”: 2075612,
“NameOfOfficer”: “Achala Samararatna”,
“TelNo”: “0112445036”,
“EmailAddress”: “[email protected]”,
“Zone”: “Hultsd_Zone_4”,
“DMA”: []
}
]
},
{
“OICId”: 248,
“OICZoneName”: “Night Gang (Hultsdrof)”,
“MobileNo”: “0773909868”,
“CostCenterCode”: null,
“ZoneOfficers”: [
{
“ZoneOfficerId”: 122,
“OICId”: 248,
“MobileNo”: “0714553919”,
“EmpNo”: 111,
“NameOfOfficer”: “Upul Karunathilake”,
“TelNo”: “0112524830”,
“EmailAddress”: “111”,
“Zone”: null,
“DMA”: []
},
{
“ZoneOfficerId”: 319,
“OICId”: 248,
“MobileNo”: “0714970203”,
“EmpNo”: 11111,
“NameOfOfficer”: “samitha saparamadu”,
“TelNo”: “4444444”,
“EmailAddress”: “ggggggggg”,
“Zone”: null,
“DMA”: []
},
{
“ZoneOfficerId”: 451,
“OICId”: 248,
“MobileNo”: “0718123699”,
“EmpNo”: 1111,
“NameOfOfficer”: “Achala Samararathna”,
“TelNo”: “0112321830”,
“EmailAddress”: “****”,
“Zone”: null,
“DMA”: []
}
]
},
{
“OICId”: 249,
“OICZoneName”: “Night Gang (Slave Island)”,
“MobileNo”: “0773909868”,
“CostCenterCode”: null,
“ZoneOfficers”: []
},
{
“OICId”: 683,
“OICZoneName”: “Area Engineer (Fort)”,
“MobileNo”: “0773909868”,
“CostCenterCode”: null,
“ZoneOfficers”: [
{
“ZoneOfficerId”: 558,
“OICId”: 683,
“MobileNo”: “0112681975”,
“EmpNo”: 93416,
“NameOfOfficer”: “W.M.U.D.Pathmasiri”,
“TelNo”: “0112681975”,
“EmailAddress”: “[email protected]”,
“Zone”: “4”,
“DMA”: []
},
{
“ZoneOfficerId”: 559,
“OICId”: 683,
“MobileNo”: “0112681975”,
“EmpNo”: 2018756,
“NameOfOfficer”: “B.K.G.D.Rodrigo”,
“TelNo”: “0112681975”,
“EmailAddress”: “[email protected]”,
“Zone”: “5”,
“DMA”: []
},
{
“ZoneOfficerId”: 560,
“OICId”: 683,
“MobileNo”: “0112681975”,
“EmpNo”: 2076931,
“NameOfOfficer”: “A.M.N.K.Thilakaratna”,
“TelNo”: “0112681975”,
“EmailAddress”: “[email protected]”,
“Zone”: “6”,
“DMA”: []
}
]
},
{
“OICId”: 722,
“OICZoneName”: “Night Gang Pamankada ( Thimbirigasyaya/ Pamankada)”,
“MobileNo”: “0773907134”,
“CostCenterCode”: null,
“ZoneOfficers”: []
}
]
}
]
}
]

i have a problem in my laravel code i have a product model and a category model i am trying to show the details for the product

public function productDetails($category_slug , $product_slug)
{
    if(Category::where('slug' , $category_slug)->exists())
    {
        if(Product::where('slug' , $product_slug)->exists());
        {
            $product = Product::where('slug' , $product_slug)->first();
            return view('show product details' , compact('product'));
        }
    }else{
        return redirect('/');
    }
}

// thats my controllerenter code here

{{ $product->id }}
{{ $product->name }}
{{ $product->description }}

image) }}” class=”cate-image” alt=”image here” style=”width: 75px;”>

//that’s my view where am trying to show the details of the product

Route::get(‘/product-details/{slug}/{name}’ , [CategoryController::class , ‘productDetails’])->name(‘product-details’);

//here is my route

Symfony 5 tests phpunit Doctrine problem update database row

I have the following problem with doctrine when testing a symfony 5 application. Instead of updating the rows in the database, new rows are created when the persist () method is called or when cascade = {“persist”} is defined in Entity. The above issue only occurs in a test environment. Everything works fine in the app itself.
sample test code (maximally simplified to show the problem)

class GetReadyArticlesTest extends FunctionalDBTest
{
    protected function setUp():void
    {
        parent::setUp();
        $this->addFixture(new ConfigurationFixtures());
        $this->addFixture(new CopyWriterTextOrderFixtures());
        $this->executeFixtures();

    }
    protected function tearDown(): void
    {
        parent::tearDown();
    }
    public function testProcessSaveArticles()
    {
        $textOrderRepository = $this->entityManager->getRepository(CopywriterTextOrder::class);
        $textOrderEntity = $textOrderRepository->find(1);
        $textOrderEntity->setCharacters(4500);
        $this->entityManager->persist($textOrderEntity);
        $this->entityManager->flush();
    }
}

Abstract class FunctionalDBTest:

abstract class FunctionalDBTest extends FunctionalTest
{
    /**
     * @var EntityManagerInterface
     */
    protected $entityManager;

    /**
     * @var ORMExecutor
     */
    private $fixtureExecutor;

    /**
     * @var ContainerAwareLoader
     */
    private $fixtureLoader;

    protected function setUp(): void
    {
        parent::setUp();

        if ($this->getContainer()->getParameter('kernel.environment') !== 'test') {
            die('Wymagane środowisko testowe');
        }

        $this->entityManager = $this
            ->getContainer()
            ->get('doctrine')
            ->getManager();
        $schemaTool = new SchemaTool($this->entityManager);
        $schemaTool->updateSchema($this->entityManager->getMetadataFactory()->getAllMetadata());
    }

    protected function addFixture(FixtureInterface $fixture): void
    {
        $this->getFixtureLoader()->addFixture($fixture);
    }


    protected function executeFixtures(): void
    {
        $this->getFixtureExecutor()->execute($this->getFixtureLoader()->getFixtures());
    }

    private function getFixtureExecutor(): ORMExecutor
    {
        if (!$this->fixtureExecutor) {
            $this->fixtureExecutor = new ORMExecutor($this->entityManager, new ORMPurger($this->entityManager));
        }

        return $this->fixtureExecutor;
    }

    private function getFixtureLoader(): ContainerAwareLoader
    {
        if (!$this->fixtureLoader) {
            $this->fixtureLoader = new ContainerAwareLoader($this->getContainer());
        }

        return $this->fixtureLoader;
    }

    protected function tearDown(): void
    {
        (new SchemaTool($this->entityManager))->dropDatabase();

        parent::tearDown();

        $this->entityManager->close();
        $this->entityManager = null; 
    }
}

Removing the persist () method in this example fixes the problem. But in case I want to save a new relation to the table, it also generates a new main object. the problem only occurs in tests.

The session id is fixed even if you change the browser and device

I use curl but on the other page the session id remains constant and does not change and I changed the browser or device and the same result

Curl Code :

    session_start();
    $Request = curl_init();
    curl_setopt($Request, CURLOPT_URL,'##################');
    curl_setopt($Request, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($Request, CURLOPT_COOKIEJAR, 'Sessionsd.txt');
    curl_setopt($Request, CURLOPT_COOKIEFILE, 'Sessionsd.txt');
    curl_setopt($Request, CURLOPT_ENCODING, '');
    curl_setopt($Request, CURLINFO_HEADER_OUT, true);
    curl_setopt($Request, CURLOPT_CUSTOMREQUEST, 'POST');
    curl_setopt($Request, CURLOPT_POST, 1);
    curl_setopt($Request, CURLOPT_POSTFIELDS,$RequestData);


    $Result = curl_exec($Request);
    if ($Result === false)
    {
        echo 'Curl error: ' . curl_error($Request);
        return false;
    }
    else
    {
        $json_response = $Result;
    }

    curl_close ($Request);

    print_r($json_response);

other Page :

    if(!isset($_SESSION)){
        ini_set('session.save_path', '../Sessions');
        session_start();
        session_regenerate_id();
        $_SESSION['ahmed'] = "fwfwef";
    }
    
    $session_id = $SessionID = session_id();

How Can fix it ?