In phpMyAdmin I am able to create databases and tables, and insert information in the tables, but for some reason when I code in PHP and try to use a form to insert information into tables, it won't do it.
Here's the code, please ignore the simplicity, it's for testing only:
- Code: Select all
<?
// Site Admin - Create Admin
if ( isset($HTTP_GET_VARS['pid']) || isset($HTTP_POST_VARS['pid']) )
{
$pid = ( isset($HTTP_GET_VARS['pid']) ) ? $HTTP_GET_VARS['pid'] : $HTTP_POST_VARS['pid'];
if ($pid == 'submit')
{
if ( ($admin_name == "") || ($admin_user == "") || ($admin_pass == "") || ($admin_email == "") )
{
$error .= "<b>ERROR!</b>";
$error .= "<br></br>";
$error .= "<b>ALL FIELDS MUST BE ENTERED IN</b>";
$error .= "<br></br>";
include('admin_create.tpl');
}
else if ($admin_pass != $confirm_admin_pass)
{
$error .= "<b>ERROR!</b>";
$error .= "<br></br>";
$error .= "<b>YOUR PASSWORD AND CONFIRMATION PASSWORD DO NOT MATCH</b>";
$error .= "<br></br>";
}
else
{
$sql = "SELECT * FROM admin_info
WHERE admin_user = '$admin_user'
AND admin_email = '$admin_email'";
$result = mysql_query($sql);
$number = mysql_num_rows($result);
$row = mysql_fetch_array($result);
if ($number == 1)
{
$error .= "<b>ERROR!</b>";
$error .= "<br></br>";
$error .= "<b>EITHER THE USERNAME OR EMAIL ENTERED IS ALREADY IN USE</b>";
$error .= "<br></br>";
include('admin_create.tpl');
}
else
{
$admin_pass = md5($user_pass);
$admin_since = date("F j, Y");
$admin_date = date("F j, Y");
$sql = "INSERT INTO admin_info (admin_id, admin_name, admin_user, admin_pass, admin_email, admin_since, admin_date, admin_title, admin_logins, admin_auth, admin_active, admin_deactive)
VALUES ('', '$admin_name', '$admin_user', '$admin_pass', '$admin_email', '$admin_since', '$admin_date', 'Admin', '$admin_logins', 1, '', '');";
mysql_query($sql);
$sql = "SELECT * FROM admin_info
WHERE admin_name = '$admin_name'";
$result = mysql_query($sql);
$number = mysql_num_rows($result);
$row = mysql_fetch_array($result);
$admin_id = $row['admin_id'];
$admin_title = "User Created Successfully!";
$admin_message .= "The following user has been created successfully:";
$admin_message .= "<br></br>";
$admin_message .= "Name: $admin_name</br>";
$admin_message .= "Username: $admin_user</br>";
$admin_message .= "Email: $admin_email</br>";
include('admin_created.tpl');
}
}
}
}
else
{
include('admin_create.tpl');
}
?>
When I go into localhost and into phpMyAdmin I have one error toward the bottom that says:
Cannot load mcrypt extension. Please check your PHP configuration.
I'm not sure if that is what the problem with the SQL is, so if not then you can ignore that statement. But please help with the other!