I'm a beginner at PHP, I'm attempting a website to sign up and etc. I keep in getting an error "unexpected 'catch' (T_CATCH) in C:\wamp\www\ass\signup.php on line 67" whenever I click submit on my sign up form (It's in a different html form). The following is the code for my php file that's called when I hit submit on the html form. Please help and very sorry if there are a lot of rookie mistakes here. As I said, I'm a beginner.
<?php
include('connect.php');
$username =$_POST['username'];
$firstname = $_Post['firstName'];
$lastname = $_Post['lastName'];
$emailadd = $_POST['emailAdd'];
$gender = $_POST['gender'];
$userpassword = $_Post['userPassword'];
$dayofbirth = $_POST['dayOfBirth'];
$monthofbirth = $_POST['monthOfBirth'];
$yearofbirth = $_POST['yearOfBirth'];
$profiledesc = $_POST['profileDesc'];
$date = $_POST['yearOfBirth'] . '-' . $_POST['monthOfBirth'] . '-' . $_POST['dayOfBirth'];
try {
$host = "localhost";
$username = "root";
$password = "";
$database = "users";
$dsn = "mysql:host=$host;dbname=$database";
$conn = new PDO( $dsn, $username, $password );
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "INSERT INTO userProfile("
. "username, firstName, lastName, emailAdd, gender, userPassword, birthday, profileDesc"
. " ) VALUES ("
. "'" . $lastname . "',"
. "'" . $firstname . "',"
. "'" . $emailadd . "',"
. "'" . $gender ."';"
. "'" . $userpassword ."';"
. "'" . $date ."';"
. "'" . $profiledesc ."';";
$conn->query($sql);
$sql = "SELECT * FROM users";
$users = $conn-query($sql);
echo '<table>';
echo '<tr>';
echo '<th>First Name</th>
<th>Last Name</th>
<th>Email Address</th>
<th>Gender</th>';
echo '<tr>';
foreach ($users as $users) {
echo '<tr>';
echo ' <td>' . $users['firstName'] . '</td>';
echo ' <td>' . $users['lastName'] . '</td>';
echo ' <td>' . $users['emailAdd'] . '</td>';
echo ' <td>' . $users['gender'] . '</td>';
echo ' </tr> ';
}
echo '</table>';
$conn = null;
catch (PDOException $e) {
$conn = null;
exit("Connection failed: " . $e->getMessage());
}
?>