Jump to content

User registration


Pain

Recommended Posts

Im trying to build mysql php user registration. For some reason i cannot insert values into my database.

 

<?php

$submit = $_POST['submit'];
$fullname = strip_tags($_POST['fullname']);
$username = strip_tags($_POST['username']);
$password = strip_tags($_POST['password']);

// Connect the database

$connection = mysql_connect("bla", "bla", "bla") or die ("Could not connect");
mysql_select_db("my_db", $connection);

// mysql query
$query = "INSERT INTO users VALUES (''. 'fullname', 'username', 'password')";

mysql_query($query);

echo "You have successfully registered";
?>

 

Any help spotting the error would be appreciated!

Link to comment
https://forums.phpfreaks.com/topic/249174-user-registration/
Share on other sites

Oops, i didn't put entire script.

 

<?php

// Header
echo "<h1>Register</h1>";

$submit = $_POST['submit'];
$fullname = strip_tags($_POST['fullname']);
$username = strip_tags($_POST['username']);
$password = strip_tags($_POST['password']);

// Connect the database
$connection = mysql_connect("blabla", "blabla", "blabla") or die ("Could not connect");
mysql_select_db("866075_db", $connection);

// Mysql query
$query = "INSERT INTO users VALUES (''. '$fullname', '$username', '$password')";

mysql_query($query);

echo "You have successfully registered";
?>

<html>

<form action="register.php" method="POST" />
<table>
<tr>
<td>
Name:
</td>
<td>
<input type="text" name="fullname" value="<?php echo $fullname;?>"/>
</td>
</tr>

<tr>
<td>
Username:
</td>
<td>
<input type="text" name="username" />
</td>
</tr>

<tr>
<td>
Password:
</td>
<td>
<input type="password" name="password" />
</td>
</tr>
</table>

<input type="submit" name="submit" value="Register" />

</html>

Link to comment
https://forums.phpfreaks.com/topic/249174-user-registration/#findComment-1279583
Share on other sites

maybe i should add

 

[code]
<?php
...
if ($submit)
{
...
}
else
{
echo "error";
}
...
?>

 

and it would be something like:

 

<?php
...
if ($submit)
{

// Connect the database

$connection = mysql_connect("blabla", "blabla", "blabla") or die ("Could not connect");
mysql_select_db("866075_db", $connection);

// mysql query
$query = "INSERT INTO users VALUES (''. '$fullname', '$username', '$password')";

mysql_query($query);

echo "You have successfully registered";

}

else
{
echo "Something went wrong";
}
...
?>

Link to comment
https://forums.phpfreaks.com/topic/249174-user-registration/#findComment-1279585
Share on other sites

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.