Something Wrong With PHP

Hello
I created an administration part on the site http://kittyworld.be/admin.php. It worked very well until a few days (3, I think) but since then, I do not reach the page to enter the login and password to link at the database, it plugs me directly to the page that processes these informations and obviously it crashes, it shows me some of the php code and it loops indefinitely … I do not understand what happens. Can you restablish a correct treatment of php code, thankx

Did you put session_start(); at the top of your code?

I do some tests, but I have a problem with sessions
I have the code on the head on my page

<?php
session_start();

$_SESSION['login'] = $_POST['login'];

$_SESSION['pass'] = $_POST['pass'];
?>

to retrieve the contents of the form but when I do

<?php 
echo $_SESSION['pass'];echo $_SESSION['login'];
?>

I get as answer

**Notice** : Undefined variable: _SESSION in **/storage/ssd4/392/7278392/public_html/admin_connexion.php** on line **16**

But

echo $_POST['pass'];
echo $_POST['login'];

display the good informations.
I can understand when I open the page for the first time, but not when I fill the fields
Note that the complete original code may be

<?php
session_start();
if (isset($_POST['envoyer']) && $_POST['envoyer'] == 'Envoyer')
	{
		if ((isset($_POST['login']) && !empty($_POST['login'])) && (isset($_POST['pass']) && !empty($_POST['pass']))) 
		{
			$_SESSION['login'] = $_POST['login'];
			$_SESSION['pass'] = $_POST['pass'];
		}
	}
?>

but it is worst
please try it on http://kittyworld.be/admin_connexion.php

There is a big problem with the recognition of sessions, I redid the code line by line, I can go a little further now (with chrome, but not with firefox), but if I ask the display of another page, I get the message that I am not an administrator, it is a control that I defined with the code

if (!isset($_SESSION['login'])) {
echo '<script language="Javascript">alert ("Si cette page ne n\' affiche pas, c\'est que vous n\'\352tes pas connect\351" );
window.location.replace("admin_connexion.php");</script>';
exit();
}
if ($_SESSION['login'] <> "....") 
{
	echo '<script language="Javascript">alert ("Tu n\'es pas administrateur alors retour" );window.location.replace("admin.php");</script>';
			exit();			
}

of course the order ($_SESSION['login'] <> "....") includes the name of the administrator

oups, javascript tags are not displayed on this forum except in edit mode. Wel, there are only alert boxes in javascript
the first one say “you are not connected”, the second “you are not adminitrator” et I do a redirection to original page

the behavior of the php interpreter varies from one page to another and responds poorly to the script statement

script language=“Javascript”

and prevents any further processing
It’s very annoying.
Have you put any restrictions on this instruction?
what I do not understand is that I was able to recover the use of some pages and not others, but it is the same code (copy-paste). Even if I update my pages, nothing helps
I need to put some alert box in javascript but the construction of certain pages are blocked

Please check if there is a file called tmp in the same directory as the public_html

1 Like

Yes, there are 10 files in this directory, I suppose I must delete them ?
4 of them content nothing
Others content the session’s variables
some modified on the 25th and others on the 26/10

I deleted the contents of the temp folder, I reconnected to the page and I have a file containing the result of the session variables on today’s date. Some pages works like this

Wel I stay with this errors on another page !


notice that I use a parameter and that normally the server must build and provide a new version of the page but I tested by removing the code starting the session and javascript and … the server provides me the same page. I have also uploaded a copy of this page under a different name. I tested this on 3 browsers, empty their cache, nothing changes … The code crashes after the tag echo script language=‘Javascript’; and you can also see that it does not recover the session variables

I don’t understand

Within the .htaccess file can you remove any lines related to php error reporting, this might remove the code but it won’t fix any real issues hiding behind the error code.

I remake this page from zero, I’m fed up. we stay in touch, I’ll let you know

1 Like

No worries do let us know how you get on and sorry we couldn’t get a resolution with your first issue.

the mysteries of computer science are impenetrable. Here’s what I did …
a first mystery

  1. I create a new page with a new name: sess.php (whatever, the name, I wanted to start something new again)
  2. I redid my code … I have a correct display
  3. The update in database is realized but I do not get javascript alerts which say “it’s ok” or “it’s not ok”
  4. I can not copy the javascrip here :frowning: to show you on this forum :frowning: it does not show up

a second mystery

  1. I completely erase the content of the page that was causing me problem: exposition_modifier.php
  2. I copy-paste the contents of sess.php
  3. I reload everything on the server with filezilla and …
  4. the exposition_modifier page rejects me indicating that I am not administrator (that is my javascript code). it crashes any future treatment. I am still in the same session,it seems that the variable $ _SESSION [‘login’] is not taken into account. But :rage: it is the same code in sess.php !!!
  5. ok, i do a copy of sess.php on my computer. I rename it with exposition_modifier.php . I have the same behaviour with the two pages (no messages javacript for confirmation of the database update)

So, on one page, javascript tags do not work and in the other they are triggered when they should not do it. Unfortunately as they are included in php tags, they do not appear if I consult the code of the page in the browser

Why the mentions script language = “Javascript” seem to be neutralized by the server when it builds the php page, executions are done in the client browser…so ??

Hmm are you able to test this locally on XAMPP etc?

If not try adding php_flag output_buffering on to .htaccess?

Wel mea culpa, by dint of changing my code, my javascript was incorrect some ; were missing, it works now … We can close this post but I still have not understood

  1. why my starting situation started to plant when I had used it until then without worry.
  2. why identical pages did not give the same result, in short all that I have explained so far but good efforts are bearing fruit, everything seems to be back in order.

We can close this post, if I meet again worries, I will recreate a new one

1 Like