-1

I am getting this error on my page: Warning: require(/FJ5/Connections/Connections.php): failed to open stream: No such file or directory in /var/customers/webs/ni1101438_1/Register.php on line 2 Fatal error: require(): Failed opening required '/FJ5/Connections/Connections.php' (include_path='.:/usr/share/php/:/usr/share/php5/') in /var/customers/webs/ni1101438_1/Register.php on line 2

This is the code I use in my files: Register.php

<?php
require('/FJ5/Connections/Connections.php');
?>
<?php 

if(isset($_POST['Register'])) 

   session_start();
   $FName = $_POST['First_Name'];
   $LName = $_POST['Last_Name'];
   $Email = $_POST['Email'];
   $PW = $_POST['Password'];

   $sql = $con->query("INSERT INTO User (Fname, Lname, Email, 
   Password)Values('{$FName}', '{$LName}', '{$Email}', '{$PW}')")





?>

Connections.php

<?php
$con = mysqli_connect("localhost","ni1101438_1sql1","PW","ni1101438_1sql1");

?>

This is my file structure: File structure

Im new to php, so please dont blame me if the answer is straightforward.

  • 1
    Possible duplicate of [Reference - What does this error mean in PHP?](http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) – Douwe de Haan May 09 '17 at 14:47
  • have you tried relative pathing? `require('FJ5/Connections/Connections.php');` – Don Bhrayan Singh May 09 '17 at 14:50
  • Add dirname(__FILE__) before the path, like: require(dirname(__FILE__).'/../FJ5/Connections/Connections.php'); – YanetP1988 May 09 '17 at 14:51
  • **Never** store plain text passwords. You should use [`password_hash()`](http://us3.php.net/manual/en/function.password-hash.php) and [`password_verify()`](http://us3.php.net/manual/en/function.password-verify.php) instead. If you're using a version of PHP prior to 5.5, do **not** use MD5 or SHA1 to hash passwords. Instead you can use [this compatibility pack](https://github.com/ircmaxell/password_compat). – Alex Howansky May 09 '17 at 14:53
  • 1
    Your code is vulnerable to [**SQL injection**](https://en.wikipedia.org/wiki/SQL_injection) attacks. You should use [**mysqli**](https://secure.php.net/manual/en/mysqli.prepare.php) or [**PDO**](https://secure.php.net/manual/en/pdo.prepared-statements.php) prepared statements with bound parameters as described in [**this post**](https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php). – Alex Howansky May 09 '17 at 14:53

1 Answers1

0

/FJ5/Connections/Connections.php starts looking in the root directory of the server, where /usr, /home, and /etc lie. If you want to start looking in the web root, use

require($_SERVER['DOCUMENT_ROOT'].'/FJ5/Connections/Connections.php');

If you want it to look in the same directory as the file you're running, add a period to the start of the directory:

require('./FJ5/Connections/Connections.php');
aynber
  • 22,380
  • 8
  • 50
  • 63