Simple add to MySQL Form

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):
$submitMessage = $_GET[‘value’];
if ($submitMessage == success)
echo ‘

Congratulations: The user has been added.
}else if($submitMessage == NULL){
}else if($submitMessage == fail){
echo ‘
Error: There where errors in your information please double check it and try again…

Add User

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).

			<input type="hidden" name="authtype" value="steam"/>

			<h3><i>STEAM ID:</i></h3>
			<input type="text" 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>

			<input type="hidden" name="flags" value="o"/>

			<input type="hidden" name="name" value="Donator"/>

			<input type="hidden" name="immunity" value="0"/><br />

			<h3><i>Your Email Address</i></h3>
			<input type="text" 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" />

My admin_save_sm_db.php file is as follows:
header(‘Location: login.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);
$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” );

And finally my sm_admin_db.php file is as follows:
//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", "[email protected]", TRUE);

All of this together does not work and give the echo error defined index.php file. 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. ;D :smiley:

So after changing:

[php]echo ‘

Error: There where errors in your information please double check it and try again…

[php]echo mysql_error();[/php]

in an effort to return a specific error, I got nothing. This leads me to assume there are no MySQL problems, but I am in no place to make assumptions. So if anyone can help, it is much appreciated.

Sponsor our Newsletter | Privacy Policy | Terms of Service