Page 1 of 1

Code at the top of my website

Posted: Fri May 24, 2019 10:21 am
by NarellanProbus
https://narellanprobus.org.au/
I have been creating a database and have just loaded the login to the index page (database not up yet) but this is what I have at the top. I use cpanel. Can other people hack into the site with this viewable?

0) { $items = file($database, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach($items as $line) { list($username, $password, $email, $name, $active) = explode('|', trim($line)); if ($username == $_POST['username'] && $active != "0" && $password == $crypt_pass) { $found = true; $fullname = $name; } } } if($found == false) { header('Location: '.$error_page); exit; } else { if (session_id() == "") { session_start(); } $_SESSION['username'] = $_POST['username']; $_SESSION['fullname'] = $fullname; $_SESSION['expires_by'] = time() + $session_timeout; $_SESSION['expires_timeout'] = $session_timeout; $rememberme = isset($_POST['rememberme']) ? true : false; if ($rememberme) { setcookie('username', $_POST['username'], time() + 3600*24*30); setcookie('password', $_POST['password'], time() + 3600*24*30); } header('Location: '.$success_page); exit; } } $username = isset($_COOKIE['username']) ? $_COOKIE['username'] : ''; $password = isset($_COOKIE['password']) ? $_COOKIE['password'] : ''; ?>

Many thanks for your help, Sue

Re: Code at the top of my website

Posted: Fri May 24, 2019 10:29 am
by BaconFries
This indicates that you have used the wrong page extension name. Please ensure that it is set to .php rather than .html or .htm Please also ensure that your host supports PHP as well.

Re: Code at the top of my website

Posted: Fri May 24, 2019 10:39 am
by NarellanProbus
Thank you for your quick response. I have the file extension set to php and my host supports php. The document type is set at HTML 4.01 Transitional. is this correct. I have my host company looking at the problem now but thought it was worth adding this information.

Re: Code at the top of my website

Posted: Fri May 24, 2019 10:46 am
by BaconFries
It looks fine now, but when I first viewed it wasn't set to .php. The Doctype doesn't matter in this instance, if you use a form or any script the uses PHP then the page extension must be set to .php to ensure thst it gets properly processed by your server.

Re: Code at the top of my website

Posted: Fri May 24, 2019 10:49 am
by NarellanProbus
Thank you. It is good to know that help is there.

Re: Code at the top of my website

Posted: Fri May 24, 2019 12:08 pm
by NarellanProbus
I have been playing with the website again since talking with you and the host company. They support php but the help desk said to change the extension back to html rather than php - I knew that was not correct. What I have found is to have the login on another page, not the index page. I could then set that to php and the code did not come up at the top. I will continue with developing the database and login and hopefully this solves my problem. Hopefully if anyone else has the same issue then that may solve their problems too. Many many thanks once again because just talking with you gave me the incentive to keep going. I am a senior but I love technology although it gives me a headache at times.