generic registration

Hi all,

I am working on a simple registration using php. The problem is that when the form is submitted it does not execute the function registration. Could you please examine and tell me if this is the correct approach? Is there any small error which leads to this?

I have included the whole registration.php file below.

Thanks for reading.

=============================================
[php]<?php

function registration(){

$user = $_POST[“user”];
$pass = $_POST[“pass”];

$connect = mysql_connect(“localhost”, “user”, “pass”);
if(!$connect){die(mysql_error());}
$select_db = mysql_select_db(“database”, $connect);
if(!$select_db){die(mysql_error());}

$insert = mysql_query("INSERT INTO users (username, password) VALUES (’$user’, ‘$pass’) ");
if(!$insert){ die("Error: ".mysql_error());}

echo $user.", welcome.
Login";
}
?>

register " method="post"> Username:
Password:

<?php
if ($_GET[‘register’] == ‘true’) {
registerUser();
}
?>[/php]

Yup, just a small logic error. Your function is named registration(), but in the code, you’re calling registerUser(). Just have to resolve that confusion and you’re all set.

Sponsor our Newsletter | Privacy Policy | Terms of Service