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
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();

}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.