I've been fiddling around with some code but it doesn't seem to work right, I been trying several things but to no success, anyone able to help me on this one?
<?php
$username = $_POST['username'];
$password = $_POST['password'];
$fullname = $_POST['full_name'];
$email = $_POST['email'];
$url = $_SERVER['PHP_SELF'];
ini_set('display_errors',1);
error_reporting(E_ALL & ~E_NOTICE);
if (isset ($_POST['submit'])) {
DEFINE (DB_USER, "username");
DEFINE (DB_PASSWORD, "password");
DEFINE (DB_HOST, "localhost");
DEFINE (DB_NAME, "database");
if ($dbc = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD))
{
if (@mysql_select_db(DB_NAME))
{
die ('<p>Could not select the database because: <b>' . mysql_error() . '</b></p>');
}
} else {
die ('<p>Could not connect to MySQL because: <b>' . mysql_error() . '</b></p>');
}
$query = "INSERT INTO members (member_userid, member_username, member_password, member_fullname, member_email, member_rank) VALUES (
0,
'$username',
'$password',
'$fullname',
'$email',
'3'
)";
if (@mysql_query($query)) {
print '<p>The blog entry has been added.</p>';
} else {
print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>";
}
}
mysql_close();
?>
<form action="<? echo $url ?>" method="post">
<input type="text" name="full_name" cols="60" /><br />
<input type="text" name="username" cols="60" /><br />
<input type="text" name="password" cols="60" /><br />
<input type="text" name="email" cols="60" /><br />
<input type="submit" name="submit" value="Add Member!" /><br />
everytime i enter information it brings up the database error but nothing appears with mysql_error(), this is what I get:
Could not select the database because:
if I knew what the error was maybe I'd know what I'm meant to be doing but it doesn't seem to want to show up.
any suggestions?