I tried using a code on a site, but I keep getting Parse error.... unexpected $end in line..... Ive done all I can, its not working. Can anybody help me? this is the code.
Code:
<?php
// execute script only if form has been submitted
if (array_key_exists('register', $_POST)) {
// remove backslashes from the $_POST array
include('../includes/corefuncs.php');
include('../includes/connection.inc.php');
nukeMagicQuotes();
// check length of username and password
$username = trim($_POST['username']);
$pwd = trim($_POST['pwd']);
// initialize message array
$message = array();
// check length of username
if (strlen($username) < 6) {
$message[] = 'Username must be at least 6 characters long';
}
// check password
if (strlen($pwd) < 8 || preg_match('/\s/', $pwd)) {
$message[] = 'Password must be at least 8 characters; no spaces';
}
// check that the passwords match
if ($pwd != $_POST['conf_pwd']) {
$message[] = 'Your passwords don\'t match';
}
// if no errors so far, check for duplicate username
if (!$message) {
// connect to database as administrator
$conn = dbConnect('admin');
$checkDuplicate = "SELECT user_id FROM users WHERE username = '$username'";// rest of code goes here
$result = $conn->query($checkDuplicate) or die(mysqli_error($conn));
$numRows = $result->num_rows;
if ($numRows) {
$message[] = "$username is already in use. Please choose another username.";
}
// otherwise, it's OK to insert the details in the database
else {
// create a salt using the current timestamp
$salt = time();
// encrypt the password and salt with SHA1
$pwd = sha1($pwd.$salt);
// insert details into database
$insert1= "INSERT INTO data_registration (company_name, company_address, city, state, postal_address, zip_code, country, mobile_number, e_mail, company_website)
VALUES (â$company_nameâ, â$company_addressâ, â$ cityâ, â$stateâ, â$postal_addressâ, â$zip_codeâ, â$countryâ, â$mobile_numberâ, â$e_mailâ,
â$company_websiteâ)";
$result1 = $conn->query($insert1) or die(mysqli_error($conn));
$insert2 = "INSERT INTO users (username, salt, pwd, security_queestion, answer)
VALUES ('$username', $salt, '$pwd', '$securityâ, â$answerâ)";
$result2 = $conn->query($insert2) or die(mysqli_error($conn));
if ($result1 && $result2) {
$message[] = "Account created for $username";
}
else {
$message[] = "There was a problem creating an account for $username";
}
}
}
?>
Thanks!