1

Well what my goal is to get the values of the selected checkboxes and then implode the array so that it is in a string format and then I could already insert in the database.

echo "  
<div class='modal fade' id='modalRejectCEO' role='dialog'>
    <div class='modal-dialog modal-lg'>
      <div class='modal-content'>
        <div class='modal-header'>
          <button type='button' class='close' data-dismiss='modal'>&times;</button>
          <h4 class='modal-title'>Reject ".$strings["project"].": ".$projectDetail->pro_name[0]."</h4>
        </div>
        <div class='modal-body'>
          <h5>Please specify the reason for rejecting the project ".$projectDetail->pro_name[0].". (eg. Reason is too vague)</h5>
          <form>
          <input type='checkbox' name='projectInfo[]' value='location'><b>Location: </b>".nl2br($projectDetail->pro_street_address[0]).", ".nl2br($projectDetail->pro_city_province[0])." <br><br>
          <input type='checkbox' name='projectInfo[]' value='date'><b>Date: </b>".$projectDetail->pro_start_date[0]." - ".$projectDetail->pro_end_date[0]." <br><br>
          <input type='checkbox' name='projectInfo[]' value='summary'><b>Project Description: </b><br><br>".nl2br($projectDetail->pro_description[0])."<br><br>
          <input type='checkbox' name='projectInfo[]' value='objectives'><b>Objectives: </b>".nl2br($projectDetail->pro_objectives[0])."<br><br>
          </form>

            <div class='input-group'>
                <span class='input-group-addon' id='basic-addon1' style='width:500px;'>Reason for Rejection:</span>
                <input type='text' id='reasonCEO' name='reasonCEO' class='form-control' style='width:500px;' placeholder='' aria-describedby='basic-addon1'>
            </div>

        </div>
        <div class='modal-footer'>
            <input type='submit' id='rejectCEO' class='btn btn-primary' name='rejectCEO'>
        </div>
      </div>
    </div>
  </div>

  ";

And this is triggers the update method of SQL

    if(isset($_POST['rejectCEO']) && $_POST['reasonCEO'] != ""){
        $selectedReason = implode(', ',$_POST['projectInfo']);

        $query3="UPDATE projects 
        SET project_status = '3', reason = '".$_POST['reasonCEO']."', reason_referrer = '".implode(',',$_POST['projectInfo'])."'
        WHERE id =".$idProj."";      

        retrieveTable($query3);
        header('Location: listprojectsprojectproposal.php');
}
4
  • 1
    for one thing, you closed off your </form> too early. Probably "thee" reason why your code failed. Commented Mar 6, 2017 at 21:37
  • Error reporting would have helped you out here. Commented Mar 6, 2017 at 21:42
  • @Fred-ii- Hi fred! Please do send it as an answer . Will accept you answer as it solved the problem Commented Mar 6, 2017 at 21:42
  • I've posted a community answer which you can accept; it's just as valid an answer, cheers. I don't want to make rep anymore, I'm in this for pure honest to goodness "help" ;-) Commented Mar 6, 2017 at 21:45

1 Answer 1

2

I'm posting this as a community wiki. I don't want rep for it, nor should any be made from it.


As I said, you closed off your </form> too early.

Error reporting would have helped here also.

Btw, your code's open to an SQL injection. Use a prepared statement:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.