So where do i start.
I built a uk CAD system (UK Police roleplay clan). Area in question looks like this:looks like this:HR
I created a Intel page, created the MySQL table column, all is good. However, when i edit the code for the edit user button, to include editing access to intel, it stops working. The entire form doesn't send any info through.
here is the php code for the edit form:
<?php
include('./includes/init.php');
$id = displayData($_POST['id']);
$sql = "SELECT * FROM users WHERE id = '$id';";
$result = mysqli_query($link, $sql);
$row = mysqli_fetch_array($result);
?>
<form>
<label>Rank</label>
<input type="text" class="form-control" id="txtUserRank" value="<?php echo displayData($row['rank']); ?>" />
<label>Division</label>
<input type="text" class="form-control" id="txtUserDiv" value="<?php echo displayData($row['division']); ?>" />
<label>Control Access</label>
<select id="txtControl" class="form-control">
<option value="<?php echo displayData($row['controlAccess']); ?>"><?php echo BoolToLabel(displayData($row['controlAccess'])) ?> (Current)</option>
<option value="0">No</option>
<option value="1">Yes</option>
</select>
<label>SLT Access</label>
<select id="txtSLT" class="form-control">
<option value="<?php echo displayData($row['sltAccess']); ?>"><?php echo BoolToLabel(displayData($row['sltAccess'])) ?> (Current)</option>
<option value="0">No</option>
<option value="1">Yes</option>
</select>
<label>Intel Access</label>
<select id="txtIntel" class="form-control">
<option value="<?php echo displayData($row['intelAccess']); ?>"><?php echo BoolToLabel(displayData($row['intelAccess'])) ?> (Current)</option>
<option value="0">No</option>
<option value="1">Yes</option>
</select>
<br />
<button class="btn btn-block btn-info btnSaveSLTUserChanges">Save Changes</button>
<hr />
<button class="btn btn-block btn-danger btnDeleteUser">Delete User</button>
</form>
Here is the code from the php file sending data to the database:
<?php
include('./includes/init.php');
$id = displayData($_POST['id']);
$rank = displayData($_POST['rank']);
$div = displayData($_POST['div']);
$control = displayData($_POST['control']);
$slt = displayData($_POST['slt']);
$intel = displayData($_POST['intel']);
$sql = "UPDATE `users` SET `rank`='$rank',`division`='$div',`controlAccess`='$control',`sltAccess`='$slt', `intelAccess`='$intel' WHERE id = '$id';";
mysqli_query($link, $sql);
And here is the .js code
$('body').on('click', '.btnSaveSLTUserChanges', function() {
var id = $('#addUnitsModalBody').attr("unitid");
var rank = $('#txtUserRank').val();
var div = $('#txtUserDiv').val();
var control = $('#txtControl').val();
var slt = $('#txtSLT').val();
var intel = $('#txtIntel').val();
var dataString = 'id=' + id + '&rank=' + rank + '&div=' + div + '&control=' + control + '&slt=' + slt + '&intel=' + intel;
$.ajax({
type: "POST",
url: "./sltEditAccount.php",
data: dataString,
success: function(response) {
$('#Members').load(document.URL + ' #Members');
}
});
});
Any help would be mostly appreciated.
NOTE: Before i added anything to do with Intel, the form worked fine, no issues.
Thanks Tyler