I'm trying to create a registration page from a HTML form that validates through to the PHP page (code supplied below), However, when I submit the form, i get the following error:
( ! ) Parse error: syntax error, unexpected 'require_once' (T_REQUIRE_ONCE) in path/user_create.php
Here's the code that enters the input from the form into the database:
<?php
session_start();
require_once __DIR__.'config.php';
if(isset($_POST['submit'])){
$username=$_POST['username'];
$password=$_POST['password'];
$email=$_POST['email'];
$sql = "INSERT INTO users ( username, password, email) VALUES ( :username, :password, :email )";
$query = $dbh->prepare( $sql );
$query->execute( array( ':username'=>$username, ':password'=>$password, ':address'=>$address, ':email'=>$email ) );
$result = $query->execute( array( ':username'=>$username, ':password'=>$password, ':email'=>$email ) );
if ( $result ){
echo "<p>Your Registration is complete</p>";
} else {
echo "<p>There was a problem with registration, please try again.</p>";
}
}
?>
Can anyone tell me how to stop this error? Not sure if it an error in the syntax or something else?