Search code examples
phpserver-error

Servererror 500 php register script


So, i made a website with a login for a friend, to host on his server. Although when testing this for me, it worked all the way, inserting, reading from DB. But when i set it up at his server, it gives an Servererror 500 after clicking Register. This is the register.php:

<?php
require("inc/db.php");
?>
<?php
if (!empty($_POST)){
$form = $_POST;
$username = $form[ 'uname' ];
$password = $form[ 'pword' ];
$email = $form[ 'email' ];
$bday = $form[ 'bday' ];


$sql = "INSERT INTO users ( username, password, email, bday ) VALUES ( :username, :password, :email, :bday )";
$query = $conn->prepare( $sql );
$result = $query->execute( array( ':username'=>$username, ':password'=>$password, ':email'=>$email, ':bday'=>$bday ) );

if($result){
    header("Location:login.php");
  }else{
    echo "There was a problem with your registration!";
  }
}
?>

The permissions are set correctly on his side with the connection info... So we really dont know what the problem is...

If anybody could help us figuring this out?

Thanks alot!


Solution

  • As you said that my form has no action so you will never reach to register.php code and that's why you are getting that error page.

    So add action to your form like this:- <form action = "register.php">

    Also always try to add error_reporting(E_ALL);ini_set('display_errors',1); in your php scripts.