Jump to content

PHP/MySQL Registration Form-- I need help!!!


edah527

Recommended Posts

hi pplz,

 

for my website, want people to register a name to have thier own account for forums, etc.

when i wrote the script, tested it(apache 2.2).

I got to the registration page, and when i finished filling it out(and did everything right ::)), it should go to a page that said "Registration was successful!" and the information would go into the MySQL table: "authusers".

 

but instead it said:

 

Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\registerfinished.php on line 9

 

this is what the files' info is:

 

for the form file:

 

<html>
<head>
<title>Register</title>
</head>
<body>
<h1>Register</h1>
<form action="http://localhost/registerfinished.php" method="post">
First Name:<br>
<input type="text" name="first"><br>
Last Name:<br>
<input type="text" name="last"><br>
Email:<br>
<input type="text" name="email"><br>
Desired username:<br>
<input type="text" name="username"><br>
Password:<br>
<input type="password" name="password"><br>
Verify Password:<br>
<input type="password" name="password2"><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>

 

this is what the result page would be:

 

<?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($query);
if (! $result) {
throw new Exception(
"Registration problems were encountered!"
);
} else {
echo "<p>Registration was succussful!</p>";
}
?>

 

please help me figure out the problem!!!! ??? ???

Link to comment
Share on other sites

Look at your query. Your using double quotes within double quotes.

 

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

Link to comment
Share on other sites

  • 2 weeks later...
Post the updated version of your code.

 

k here it is:

 

<?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', '$_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

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.