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]<?PHP
$submitMessage = $_GET[‘value’];
if ($submitMessage == success)
{
echo ‘
}else if($submitMessage == NULL){
}else if($submitMessage == fail){
echo ‘
}
?>
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" />
</form>[/php]
My admin_save_sm_db.php file is as follows:
[php]<?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);
?>[/php]
And finally my sm_admin_db.php file is as follows:
[php]<?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", "[email protected]", TRUE);
?>[/php]
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