hi all, i have been making a php mysql login, however it is throwing up a 500 server error and i have no clue why, here's the code: <? if (isset($_POST['submitted'])) { $errors = array(); if (empty($_POST['first_name'])) { $errors[] = 'You forgot to enter your First Name.'; } else { $fn = trim($_POST['first_name']); } if (empty($_POST['last_name'])) { $errors[] = 'You forgot to enter your Last Name.'; } else { $ln = trim($_POST['last_name']); } if (empty($_POST['email'])) { $errors[] = 'You forgot to enter your email address.'; } else { $e = trim($_POST['email']); } if (!empty($_POST['pass1'])) { if ($_POST['pass1'] != $_POST['pass2']) { $errors[] = 'Your password did not match the confirmed password.'; } else { $p = trim($_POST[['pass1']); } } else { $errors[] = 'Your forgot to enter your password.'; } if (empty($errors)) { require_once ('mysqli_connect.php'); $q = "insert into users (first_name, last_name, email, pass, registration_date) values ('$fn', '$ln', '$e', sha1('$p'), now() )"; $r = @mysqli_query ($dbc, $q); if ($r) { echo '<h1>Thank you!</h1> <p>You are now registered</p>'; } else { echo '<h1>System error</h1> <p>You could not be registered due to a system error</p>'; echo '<p>' . mysqli_error($dbc) . '<br /><br /> Query: ' . $q . '</p>'; } mysqli_close(); exit(); } else { echo '<h1>Error!</h1> <p>The following errors occurred:<br />'; foreach ($errors as $msg) { echo " - $msg<br />\n"; } echo '</p><p>Please try again.</p>'; } } ?> <h1>Register</h1> <form action="register.php" method="post"> <p>First Name: <input type="text" name="first_name" size="15" maxlength="20" value="<? if (isset($_POST['first_name'])) echo $_POST['first_name']; ?>" /> </p> <p> Last Name: <input type="text" name="last_name" size="15" maxlength="40" value="<? if (isset($_POST['last_name'])) echo $_POST['last_name']; ?>" /> </p> <p> Email Address: <input type="text" name="email" size="20" maxlength="80" value="<? if (isset($_POST['email'])) echo $_POST['email']; ?>" /> </p> <p>Password: <input type="password" name="pass1" size="10" maxlength="20" /> </p> <p>Confirm Password: <input type="password" name="pass2" size="10" maxlength="20" /> </p> <p> <input type="submit" name="submit" value="Register" /> </p> <input type="hidden" name="submitted" value="true" /> </form> PHP: can anyone see a reason why this may be?
$p = trim($_POST[['pass1']); PHP: Extra [ there Also your server is not configured correctly if it is throwing a 500 error rather than telling you where the error is.
but it isn't only mistake webber, it can't just start to work if you deleted that [ It's server-side problem, not PHP. try to remove/rename .htaccess and it should work
If PHP hasn't been configured to properly handle errors, it could result in an internal server error.
A lot more than .htaccess can cause internal server errors. It could be an error within the PHP configuration file (php.ini), for example, which is what I was hinting at.
i have no .htaccess for this. all seams to work as soon as i got rid of the extra [ and it is working as intended
it is hosted with birch hosting and the mysql is on the same server i guess. all the details are in the mysqli_connect.php which is used in the require_once function
yes I saw it Umm, maybe screwed php.ini configuration but I am not sure. However, it doesn't matter if it works!