Jump to content

PHP/MYSQL Registration Form


edah527

Recommended Posts

Ive got a problem every time i try to fix this; here is the errer message:

 

Parse error: syntax error, unexpected T_CATCH in C:\xampp\htdocs\register2.php on line 18

 

and here is the code for the finished part of registration:

 

<?php
if (! isset($_POST["submit"])) {
echo file_get_contents("C:\xampp\htdocs\register.html");
} else {
$mysqli=mysqli_connect("localhost", "mysqluser1", "", "users");
if ($_POST["password"] != $_POST["password2"]) {
echo "<p>The passwords don't match. Go back and try again.</p>";
} else { 
$query="INSERT INTO authusers ('first', 'last', 'email', 'username', 'password') VALUES ('$_POST[first]', '$_POST[last]', '$_POST[email]', '$_POST[username]', '$_POST[password]');";
$result=mysqli_query($mysqli, $query);
if (! $result) {
throw new Exception(
"Registration problems were encountered!"
);
} else {
echo "<p>Registration was succussful!</p>";
}
} catch(Exception $e) {
echo "<p>".$e->getMessage(),"</p>";
} #endCatch
}
?>

Link to comment
https://forums.phpfreaks.com/topic/92545-phpmysql-registration-form/
Share on other sites

Trie this way ok.......

 

<?php

if (!isset($_POST["submit"])) {

echo file_get_contents("C:\xampp\htdocs\register.html");

} else {

$mysqli=mysqli_connect("localhost", "mysqluser1", "", "users");

if ($_POST["password"] != $_POST["password2"]) {

echo "<p>The passwords don't match. Go back and try again.</p>";

} else {

$query="INSERT INTO authusers ('first', 'last', 'email', 'username', 'password') VALUES ('$_POST[first]', '$_POST[last]', '$_POST[email]', '$_POST[username]', '$_POST[password]');";

$result=mysqli_query($mysqli, $query);

if (! $result) {

throw new Exception("Registration problems were encountered!");

} else {

echo "<p>Registration was succussful!</p>";
}

}

$e="This wasent here before"; //defineing varable $e

throw new Exception($e);


echo $e->getMessage();

}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.