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">
    <legend>Post Announcement</legend>
    <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>
        <select id="chkveg" multiple="multiple" name="recipients" required>
      $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() {
                                includeSelectAllOption: true
                            $('#btnget').click(function() {

      <script type="text/javascript">
          $(document).ready(function() {

    <div class="input-control textarea size8">
        <textarea name="msg">Type Here</textarea>
    <button class="primary" name="send">Send</button>

and this is my code for saving to database


    $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,));


thanks in advance guys.

Errr... This is why copy-and-paste is not teaching one to learn... If you are asking people here to give you the code, then I have to decline. If you ask us to guide you how to do it, I would say you need to read on how to pass variable from one page to the other, and then VERIFY that all user input are valid BEFORE insert into your database. Your PHP file to handle this should also be named the same as whatever action your form is sending to.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.