Ok, so, I am writing a script to add users to my database. All you do is input the new username and the new password. Here is the code for the form.
Here is the code for add.php.PHP Code:<h2>Add A User</h2>
<?php
$add = $_GET['add'];
if ($add == "false") {
echo("<div class=\"failure\">All fields are required</div>");
}
if ($add == "true") {
echo("<div class=\"success\">User has been added</div>");
}
$form = "<br /><form method=\"post\" action=\"add.php\">
Username: <input type=\"text\" name=\"user2\" />
<br /><br />Password: <input type=\"password\" name=\"passwd\" />
<br /><br />
<input type=\"submit\" name=\"submit\" value=\"Add User\"/>
</form>";
echo $form;
?>
Here is the code for config.php.PHP Code:<?php
$user2 = mysql_escape_string($_POST['user2']);
$passwd = md5($_POST['passwd']);
include("config.php");
mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());
if ($user2 == "" && $passwd == "") {
header("Location:admin_users.php?add=false");
} elseif ($user2 == "") {
header("Location:admin_users.php?add=false");
} elseif ($passwd == "") {
header("Location:admin_users.php?add=false");
} else {
$query = mysql_query("insert into '$dbtable' values(0, '$user2', '$passwd')");
$row = mysql_fetch_array($query);
header("Location:admin_users.php?add=true");
}
exit;
die;
?>
Here is the error I get.PHP Code:<?php
$dbhost = 'localhost';
$dbuser = 'demiur_helpdesk';
$dbpass = 'me1234';
$dbtable = 'helpdesk';
$db = 'demiur_helpdesk';
?>
Any ideas as to why this is happening? Thanks in advance.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/demiur/public_html/demo/helpdesk/add.php on line 19
Warning: Cannot modify header information - headers already sent by (output started at /home/demiur/public_html/demo/helpdesk/add.php:19) in /home/demiur/public_html/demo/helpdesk/add.php on line 21![]()





Bookmarks