I was trying to make a update form to update notifications on my database but it wont do nothing i don't even get a error so that means there is nothing wrong with my syntax so maybe i did something wrong on the query ?
code :
<?php
include 'core/int.php';
admin_protect();
include 'includes/head.php';
include 'head.php';
include 'includes/body.php';
include 'body.php';
?>
<?php
if(!isset($_POST['submit'])){
$sql="SELECT * FROM Notification WHERE id = $_GET[edit]";
$data=mysql_query($sql);
$not_data = mysql_fetch_array($data);
}
//What i want to update also i know this is vulnerable to a sql injection ill sanitize it later
if(isset($_POST['submit'])){
$sql = "UPDATE Notification SET name = '$_POST[name]' WHERE id = '$_POST[id]'";
mysql_query($sql);
}
?>
<pre>
<form action="" method="post">
<div class="input-group input-group-lg">
<span class="input-group-addon">Name</span>
<input type="text" name="name" class="form-control" value="<?php echo $not_data['name'];?>">
</div>
<div class="input-group input-group-lg">
<span class="input-group-addon">Date</span>
<input type="text" name="Date" class="form-control" value="<?php echo $not_data['date'];?>">
</div>
<div class="input-group input-group-lg">
<span class="input-group-addon">Content</span>
<textarea type="text" name="content" class="form-control" rows="3"><?php echo $not_data['content'];?></textarea>
</div>
<div class="input-group input-group-lg">
<select class="form-control" name="active">
<?php if($not_data['active'] == 'Active'){
echo '
<option>Active</option>
<option>Not Active</option>
';
} else if($not_data['active'] == 'Not Active'){
echo '<option>Not Active</option>
<option>Active</option>
';
}?>
</select>
</div>
<div class="input-group input-group-lg">
<select class="form-control" name="new">
<?php if($not_data['new'] == 'New'){
echo '
<option>New</option>
<option>Old</option>
';
} else if($not_data['new'] == 'Old'){
echo '<option>Old</option>
<option>New</option>
';
}?>
</select>
</div>
<div class="input-group input-group-lg">
<select class="form-control" name="posted_by">
<option>Sincearly , Duckys Inc Team</option>
<option>Sincearly , <?php echo $user_data['username'];?></option>
</select>
</div>
<div>
<input type="hidden" name="id" value="<?php echo $_GET['edit'];?>">
<input type="submit" value="Edit" class="btn btn-primary btn-lg">
</div>
<?php print_r($_POST);?>
</form>
</pre>