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
https://forums.phpfreaks.com/topic/88502-phpmysql-registration-form-i-need-help/
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"]."');

  • 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

}

?>

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.