Alright so I am trying to code a very simple form that adds a user to my SQL database with certain information filled in and certain information kept hidden with default values in a form.
My index.php file is as follows (not all of the code but just the form part):
<?PHP
$submitMessage = $_GET['value'];
if ($submitMessage == success)
{
echo '<div class="congratulations"><font color="#84d20c"><strong>Congratulations:</strong></font> The user has been added.</div>';
}else if($submitMessage == NULL){
}else if($submitMessage == fail){
echo '<div class="error"><font color="#d3430c"><strong>Error:</strong></font> An error occurred please check the error details below:</div>';
echo 'ERROR DETAILS:';
echo mysql_error();
}
?>
<h1><i>Add User</i></h1>
<p>This page is where you would manually add a user to the donations databases (for example you or a member of the community with elevated status that does not need to pay).</p>
<br/>
<form enctype="multipart/form-data" action="scripts/admin_save_sm_db.php" method="post">
<input name="authtype" value="steam"/><br /><br />
<h3><i>STEAM ID:</i></h3>
<input name="identity" value="STEAM_0:X:XXXXXXXX"/><br />
<div class="form_help">Steam ID of the player you wish to add. Must be in the format STEAM_0:X:XXXXXXXX</div><br />
<input name="flags" value="o"/><br /><br />
<input name="name" value="Donator"/><br /><br />
<input name="immunity" value="0"/><br /><br />
<h3><i>Your Email Address</i></h3>
<input name="user_email"/><br />
<div class="form_help">Your Email Address for security purposes.</div><br />
<input name="Submit" type="submit" value="Submit" class="form_submit" />
</form>
My admin_save_sm_db.php file is as follows:
<?php
session_start();
if(!isset($_SESSION["username"]))
{
header('Location: login.php');
exit;
}
@require("../sm_admin_db.php");
$authtype = $_POST['authtype'];
$identity = $_POST['identity'];
$flags = $_POST['flags'];
$name = $_POST['name'];
$immunity = $_POST['immunity'];
$user_email = $_POST['user_email'];
$link = @mysql_connect(_HOST,_USER,_PASS);
@mysql_select_db(_DB);
$sql = @mysql_db_query(_DB,"INSERT INTO "._TBL." (`authtype`, `identity`, `flags`, `name`, `immunity`, `user_email`) VALUES (NULL, '$authtype', '$identity', '$flags', '$name', '$immunity', '$user_email')");
$okay = @mysql_affected_rows();
if($okay > 0) {
header( "Location: ../index.php?value=success" );
} else {
header( "Location: ../index.php?value=fail" );
}
@mysql_close($link);
?>
And finally my sm_admin_db.php file is as follows:
<?PHP
//host loaction
define("_HOST", "localhost", TRUE);
//database username
define("_USER", "thatsact_admin", TRUE);
//database username`s password
define("_PASS", "*********", TRUE);
//database name
define("_DB", "thatsact_sadadmins", TRUE);
//database table name change this to install multiple version on same database
define("_TBL", "sm_admins", TRUE);
//This is the email that you will recieve emails when someone signs up.
define("_EMAIL", "admin@tag-clan.com", TRUE);
?>
All of this together does not work and gives the echo error code, however the mysql_error() string does not return anything. Nothing is inserted into the database. Can I get some help on where I went wrong and please keep in mind I am VERY new to php and didn't write most of this script so just tell me what to edit and exactly how to do it please.
Thanks in advance.