Skip to main content
Filter by
Sorted by
Tagged with
-1 votes
3 answers
103 views

Declare custom $_SERVER variable

I am setting $_SERVER variables in an include file as follows - $_SERVER['BOT'] = isset($_SERVER['BOT']) ? $_SERVER['BOT'] : 0; // assume this is not a bot $_SERVER['REALPAGE'] = isset($_SERVER['...
Adrian Hall's user avatar
1 vote
1 answer
128 views

Issue with $_GET being empty despite a valid URL parameter in PHP

I'm currently trying to pass a URL parameter to a PHP page on my local server, but I'm facing an issue with the $_GET superglobal that appears to be empty despite a valid URL parameter. Here's a ...
Aqu1tain's user avatar
-1 votes
2 answers
40 views

Could you plz tell the file uploading using jquery with easiest way?

I want to use the easiest method for uploading file through jquery ajax. My code is: <body> <form action="?" method="POST" enctype="multipart/form-data"> ...
user avatar
0 votes
1 answer
141 views

What data can be accessed through the $_SESSION superglobal

I had this question in a quiz: Once a session is started, all data related to the session is accessible through the $_SESSION superglobal. A. True B. False My answer was false, because I thought only ...
PopCornnnn's user avatar
0 votes
1 answer
134 views

Can PHP superglobals be changed or appended with another variable?

I'm wondering if I do something like $_SERVER['myVar'] = "myValue", does it change in other sessions? Could I access that custom variable from other sessions?
Attila Gál's user avatar
1 vote
1 answer
731 views

Where should I save the access token value shared by multiple sessions in php?

You are about to send an email using the outgoing email api. At this time, access_token only needs to be acquired once, so I want to run the authentication process once and share it in several ...
DuRu Kang's user avatar
1 vote
1 answer
74 views

Superglobal GET using PHP

I am new to php and I couldn't find the answer on stack. I am experimenting and trying to figure out how I can use the superglobal GET to display an image and also change the *count depending on how ...
justAnAlien's user avatar
0 votes
0 answers
15 views

How to send data of disabled HTML input field of the form to another page through PHP superglobals? [duplicate]

<form action="../../Controllers/add-service-action.php" method="GET"> <label for="service_id">Service Id: </label> <input type="...
TIAS's user avatar
  • 33
0 votes
0 answers
127 views

How to properly restore a deleted PHP $_SESSION

So I have the following problem; I'm using a PHP $_SESSION to authenticate logged-in users and allow access to specific pages of a website A. As the protected parts of A allow to execute payments, its ...
DevelJoe's user avatar
  • 1,262
0 votes
1 answer
45 views

PHP Xdebug dosen't show variables

PHP Xdebug always says POST (superglobal) undefined but web program works fine. Either of other local variables or Superglobals aren't shown. I use XAMPP as local server. What could be the problem?
Dhammika Wijesinghe's user avatar
0 votes
1 answer
521 views

$_FILES super global variable

why doesn't the unset function remove $_FILES contents or empty it after uploading a file . how can I empty my $FILES variable after uploading a file . <html> <head> <...
Omar AbdElwahhab's user avatar
1 vote
1 answer
41 views

What is the new proper way to pass a variable between Ajax code and a PHP file?

I am writing a login page for a web application. I am using ajax to pass a user name and pwd to a php file. In the php file I started with the following code. if(isset($_POST)) { $uname = $_POST['...
user avatar
0 votes
1 answer
132 views

php superglobal function ($GLOBALS['headers']['Authorization']) in never set. why?

I have php function that is supposed to verify if there is a token, and if so, search my table for a company name that matches. The function works fine when I use xampp in localhost. When I do it in ...
Heidi E's user avatar
  • 251
0 votes
1 answer
446 views

How don't direct use $_FILES Superglobal in PHP?

I'm looking for an alternative to get the data inside the $_FILES due to a codacy issue I don't know how to don't use directly the superglobals. I can't use filter_input like I did for resolve the ...
user avatar
1 vote
1 answer
22 views

A session variable doesn't get passed properly?

So, I am trying to set a $_SESSION variable and pass it to another page, but the variable on the other page is different than the one it must be. In petitionlist.php the $_SESSION['petitionNameT'] = $...
Bryan Coding's user avatar
0 votes
1 answer
249 views

PHP Debugging, $_SERVER Not all superglobals are shown in debugger

I was using a debugger in VScode: called PHP Debug 1.13.0. And XDebug installed on PC. When I open superglobals I don't see many of them which are actually exists and printable like "$_SERVER['...
Ivan Savchenco's user avatar
0 votes
1 answer
187 views

Can global variables be created with the keyword global and through a superglobal variable within a function in PHP?

I have heard using global variables is not good, however I am just trying to understand how the PHP language works. I am a beginner in the coding world. Why can global variables be created within ...
spiderman0297's user avatar
1 vote
0 answers
107 views

How do certain aspects of superglobals work in relation to functions in PHP?

I am new to coding and this website, so I apologize in advance if I word my questions incorrectly or do not know the proper way of communicating. I have heard that using global variables is bad ...
spiderman0297's user avatar
1 vote
1 answer
107 views

Client access to Superglobals

PHP Superglobals behave in different ways and I'm never sure about which one to use. When can the client (I'm not talking about hackers or security attacks, but "normal users") edit, create or access ...
user avatar
0 votes
1 answer
307 views

How to best replace global variables in Joomla extensions [duplicate]

The Joomla Extensions Directory puts pressure on developers not to use global variables (superglobals) such as $_SERVER, $_REQUEST, $_POST, $_GET, $_FILES, $_ENV, $_COOKIE, and $_SESSION to prevent ...
Wink's user avatar
  • 1
0 votes
1 answer
724 views

$_REQUEST can not get query parameter

Payment is successful but it is still displaying error, the Transaction with this ID is not found. I'm performing the transaction form https://pay.digiwallet.nl/test-transaction This is ...
MuzammilKhan's user avatar
0 votes
0 answers
36 views

PHP from shell: Provide environment for enabling $_POST & $_GET superglobals

Disclaimer: This one's just for curiosity, I have no actual problem to solve... When I run a PHP script from the shell, is there a way to provide a process environment where PHP can derive it's $...
Benni's user avatar
  • 1,033
0 votes
2 answers
216 views

How to echo a php code using ob_start in another function?

I've tried to copy my php code from foreach loop using ob start but failed. Does anyone knows how to do this? I wanted to add my php code in another function like below. foreach($kekei as $good => ...
spider aladin's user avatar
0 votes
1 answer
130 views

How to redirect to a page according to URL parameter in php? [duplicate]

I am working on project in php where I want to create parameter in main index page and redirect page according to the parameter Example: if URL is "index.php?page=about.php" the page shoudld be ...
Cybil K's user avatar
  • 96
0 votes
1 answer
367 views

PHP Superglobals in another file

I want to declare a variable (php code) in file file_one and use it in file_two. According to its documentation, superblogals can be accessed from everywhere. But not in my case maybe?? I declared $...
user3513782's user avatar
0 votes
0 answers
26 views

How can i get SESSION variables to work when the variable is set in a function? displaying index not set

The issue i have is that within my login system of a database, i create session variables within a function so that they can be used in another file however they do not seem to be accessible outside ...
Jobless Joe's user avatar
0 votes
0 answers
605 views

How to set POST message variable value to null

I am trying to erase the data stored in $_POST['message'] or set it to null. I'm just trying to clear the data somehow. Here is my mini chat program. <?php require_once("connection.php"); if(...
nedsmith's user avatar
0 votes
1 answer
48 views

Get value of variable by name in case it is array item, possibly from superglobal

Is this at all possible to get a value from variable accessed by name in case it refers to an indexed array item? Actually I planned to do this trick with $_SERVER['HTTP_HOST'] but I found out that $$ ...
Barvinok's user avatar
-2 votes
1 answer
64 views

Get value of hidden inpute to $_POST

I've assigned a hidden input into my form which will store values of checked checkboxes (that part is working fine as can be seen in this picture): The value of this hidden input is converted to a ...
TheProphet's user avatar
0 votes
2 answers
89 views

What is the php function to simultaneously check the existence of a $_GET parameter and access its value

In PHP, to avoid Undefined Index errors, one can write if(isset $_GET['var1'] && $_GET['var1'] == 'My Matching Text'){ //do stuff } But I remember using a function (or language construct)...
TecBrat's user avatar
  • 3,719
3 votes
4 answers
3k views

PHP Session Id in $_COOKIES superglobal stays the same after destroy

Hy I am new to php and trying to destroy a session according to the php documentation here: http://php.net/manual/en/function.session-destroy.php so I am using this code: <?php session_start()...
Deli Sandor's user avatar
-1 votes
1 answer
29 views

Choosing between superglobals for navigation in admin section

I'm creating a custom admin page that will enable the client to navigate the content list and edit/delete/add items to and from database(myPhpAdmin) in PHP and I was wondering about the correct way to ...
Aleksandar Jocic's user avatar
0 votes
2 answers
865 views

PHP - $_SERVER('PHP_SELF') error using XAMPP [duplicate]

I am a Windows 7 user and I am creating a website on localhost:8080/ using XAMPP. I want to make a contact form using PHP for getting the data from the form(name, email, message) and sending them to ...
A.Tressos's user avatar
2 votes
1 answer
118 views

PHP builtin server/routing script: Empty superglobals

I'm trying to start a local server that catches all Urls called. Basically I want to simulate a REST-Interface for testing purposes, and write all Urls and the POST/PUT/PATCH Data to a file. I start ...
Fels's user avatar
  • 1,343
0 votes
0 answers
516 views

php thread safety of using static class members as super global variable

I want to have my own super global variables accessible from all of my scripts and I'm using static class members to achieve this but I'm concerned that as the php server creates a separate thread for ...
Amir Rasti's user avatar
-1 votes
2 answers
72 views

Unable to print items from an array in php

My code is supposed to fix the name of the courses by capitalizing the first letter of each word. Then I need to sort them in the globals array and print out a message with them. I think I have done ...
yes indeed's user avatar
1 vote
1 answer
78 views

What is the reason for overwriting super global $_FILES while uploading multiple files using code igniter

Assume post request is validated, and functional code is good enough and just an observation mostly multiple file uploading Code Igniter Sample code looks like this, Concern is why Super global ...
Om Prakash Pachoriya's user avatar
0 votes
0 answers
48 views

A missing name, ReferenceError in NodeJS

I've been working during the last 4 weeks in a multiplayer game based on NodeJS and Express. The game has a few different classes inside the /lib/ folder. So, let's focus on 2: Game.Js Player.Js ...
Chris Russo's user avatar
-1 votes
2 answers
199 views

Can we create a Superglobal Boolean variable in php that can be manipulated from any php script?

I have a php script that runs every minute to check something. What I need is, if the script finds what it is checking for then set a Boolean to true so that on subsequent run of the script it can ...
rockfight's user avatar
  • 1,996
0 votes
1 answer
435 views

Turn on/off PHP making superglobal array elements available as global variables

$_SESSION['myvar'] becomes available as $myvar after a session_start() call. $_POST['myvar'] becomes available as $myvar after a form is posted. I find the above behavior with the PHP installation/...
rtdrury's user avatar
-2 votes
2 answers
917 views

Where can I get a complete list of variables that PHP automatically makes available to my script by looking at the output of the phpinfo() function?

I'm using PHP 7.2.3 on my machine that runs on Windows 10. I've installed PHP using latest version of XAMPP. I come across following text from PHP Manual : $_SERVER is just one variable that PHP ...
PHPLover's user avatar
  • 13k
-1 votes
1 answer
606 views

update with multiple ids from form

I can't get rid of this error Notice: Array to string conversion , when trying to validate array of IDs from form form code (takes IDs from database): <tr> <td><input type="hidden" ...
razvan's user avatar
  • 13
0 votes
3 answers
52 views

Show in the email from which page the form was submitted

I have a html form on every page and I need to be able to show in the receiver email from which page the visitor submitted the form. How can I achieve this in PHP? I have tried using $_SERVER['...
Limpuls's user avatar
  • 876
0 votes
1 answer
123 views

Superglobals as parameters in php functions [duplicate]

I found myself in a need to set a default value for some method parameter from superglobal like: public function some_function ($foo = $_POST['foo'], $bar = $_POST['bar']){ //some action } This ...
RWS's user avatar
  • 548
0 votes
3 answers
656 views

Pass entire URL to $_GET variable in PHP built-in server

I'm running a PHP built-in server with php -S 127.0.0.1:80 index.php I want to pass the entire URI string to a field called "url" in the $_GET array. When I enter http://localhost/thisIsAURLString, ...
Magnus's user avatar
  • 718
0 votes
1 answer
231 views

Multidimensional associative array in $_POST returns only last value

I've tryed to make a multidimensional associative array but only one value is returned in the $_post. See working example: <html> <?php if (isset( $_POST['form_submit'])){ $Step=...
genespos's user avatar
  • 3,301
0 votes
1 answer
78 views

Why the key representing radio buttons goes missing from the HTTP POST method's $_POST superglobal array when none of them are selected?

I've written following PHP code : <!DOCTYPE HTML> <html> <head> </head> <body> <?php // define variables and set to empty values $name = $...
PHPLover's user avatar
  • 13k
-1 votes
1 answer
176 views

Why does the behavior like unset() in case of global variables is not the same for other operations too?

As per the PHP documentation on unset() function : The behavior of unset() inside of a function can vary depending on what type of variable you are attempting to destroy. If a globalized variable is ...
PHPLover's user avatar
  • 13k
1 vote
3 answers
1k views

Check if php script was called by the server or remotely in php?

I have a crontab php script that resides in one of the folders on abc.tld. The problem is that the script could also be fired by calling it directly (i.e. http://abc.tld/crontab.php) To eliminate such ...
Pavel's user avatar
  • 674
1 vote
1 answer
60 views

How does the function unset() behaves differently depending on the way to access a global variable inside the function?

As per my knowledge, any variable declared outside the function is treated as a 'Global Variable' in PHP. To access such global variable inside the function there are two ways one is to declare is as ...
PHPLover's user avatar
  • 13k

1
2 3 4 5