Russ
Well-known member
First off thanks to Jake for helping me get this far I'm a complete novice at this, I've tried googling the crap out of this and can't seem to find a fix. I'll show you the code I'm working with first:
Two things...
Hope that all made sense... I've seen a few ways of possibly doing it... run two queries, and some duplicate functions but I can't get the hang of anything past this point lol .
I do styles, not this crap!
Any help would be appreciated.
Code:
<div id="loadouts">
<?php
if (ISSET($_POST['action']))
{
if ($_POST['action'] == "Update")
{
$cust_loadout_id = $_POST['custloadoutid'];
$unique_id = $_POST['uniqueid'];
$db = @mysql_connect($hostname,$dbusername,$dbpassword);
if(!@mysql_select_db($databasename,$db)) {}
$query = "INSERT INTO cust_loadout_profile (cust_loadout_id, unique_id) VALUES ('$cust_loadout_id','$unique_id')";
$result = mysql_query($query);
print "<div>Updated Loadout</div>";
$mysqli = null;
$stmt = null;
}
}
?>
<form action="" method="POST">
<select name="custloadoutid" class="input_text">
<option value="2">Admin Loadout</option>
<option value="3"> Donator Loadout</option>
</select>
<?php
XenForo_Session::startPublicSession(new Zend_Controller_Request_Http);
$visitor = XenForo_Visitor::getInstance();
echo '<input type="hidden" name="_xfToken" value="'; echo $visitor['csrf_token_page']; echo '"/>'; echo '
<input type="hidden" class="input_text" value="'; echo $visitor['customFields']['dayzuniqueid']; ?>" name="uniqueid">
<input type="submit" class="button" name="action" value="Update">
</form>
</div>
Two things...
- How am I able to make it so the query will check to see if there's an existing unique_id and if so update the column of that specific row with the new cust_loadout_id
- Then if there's no match on the unique_id just create a new row how I have it now
- Next I'd like some proper result messages,(IE no custom field defined to supply a value would cause it to fail) I know the way I have it, it'll just kick back that message no matter what.
Hope that all made sense... I've seen a few ways of possibly doing it... run two queries, and some duplicate functions but I can't get the hang of anything past this point lol .
I do styles, not this crap!
Any help would be appreciated.