Jump to content

PHP/SQL Registration


davidknag

Recommended Posts

Could Anyone tell me what's wrong with this besides the fact that it is not connect to any database?

it does not do anything when i click the button.

 

<?php
if ($_GET['register'] == 'true') {
   registerUser();
	}
function registerUser() {
   mysql_connect('server', 'username', 'password', 'database');
   $username = $_POST['username'];
   $password = md5($_POST['password']);

   $sql = "INSERT INTO accounts (login, password, email, gm, flags) VALUES ($username, $password, $email, 0, 24);";

   mysql_query($sql);
}
?>

<div class="form">
       <form action="<?php $_SERVER['PHP_SELF']."?register=true" ?>" method="post">
           Username: <input type="text" name="username">
	<br></br>
	<br></br>
           Email: <input type="text" name="email">
	<br></br>
	<br></br>
           Password: <input type="password" name="password">
	<br></br>
	<br></br>
           <input type="submit" value="Register!">
       </form>

 

thanks if you can help :)

Link to comment
Share on other sites

String values need to be surrounded by quotes

 

So, it should be:

 

$sql = "INSERT INTO accounts (login, password, email, gm, flags) VALUES ('$username', '$password', '$email', 0, 24);";

 

or, doing it your way:

 

$sql = "INSERT INTO accounts (login, password, email, gm, flags) VALUES ('" .$username . "','" . $password . "','" . $email . "', 0, 24');";

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.