Hello Guys,
I dont know how to do these, i have a existing code from the internet and use it and Successful Ok. But i dont kow how to save this to database. can you please help me guys? thanks in advance this is my code
<link rel="stylesheet" href="../css/bootstrap-3.1.1.min.css" type="text/css" />
<link rel="stylesheet" href="../css/bootstrap-multiselect.css" type="text/css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript" src="../js/bootstrap-2.3.2.min.js"></script>
<script type="text/javascript" src="../js/bootstrap-multiselect.js"></script>
<form id="form1" class="clearfix" method="POST" action="sendannouncement.php">
<fieldset>
<legend>Post Announcement</legend>
<br>
<label>Subject</label>
<div class="input-control text size8" data-role="input-control">
<input type="text" name="subject" required placeholder="Subject">
<button class="btn-clear" tabindex="-1"></button>
</div>
<label>Recipients</label>
<select id="chkveg" multiple="multiple" name="recipients" required>
<?php
$acdemployee = new Acdemployee;
$acdemployees = $acdemployee->fetch_all();
foreach($acdemployees as $acdemployee) { ?>
<option value="<?php echo $acdemployee['empid']; ?>"><?php echo $acdemployee['fname']; ?></option>
<?php } ?>
</select><br /><br />
<script type="text/javascript">
$(function() {
$('#chkveg').multiselect({
includeSelectAllOption: true
});
$('#btnget').click(function() {
})
});
</script>
<script type="text/javascript">
$(document).ready(function() {
$('#chkveg').multiselect();
});
</script>
<label>Message</label>
<div class="input-control textarea size8">
<textarea name="msg">Type Here</textarea>
</div>
<br>
<button class="primary" name="send">Send</button>
</fieldset>
</form>
and this is my code for saving to database
<?php
include_once('../include/connection.php');
if(isset($_POST['send'])){
$empid = $_POST['recipient'];
$msgdate = date("m/d/Y");
$sender = "Administrator";
$msg = $_POST['msg'];
$subject = $_POST['subject'];
$sql = "INSERT INTO empinbox (empid,msgdate,sender,msg,subject) VALUES (:empid,:msgdate,:sender,:msg,:subject)";
$q = $pdo->prepare($sql);
$q->execute(array(':empid'=>$empid, ':msgdate'=>$msgdate,':sender'=>$sender, ':msg'=>$msg,':subject'=>$subject,));
header('location:postannounce.php');
}
?>a
thanks in advance guys.