Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. If you are using PHP's mail function then you need configure the mail settings in the php.ini As you are using XAMPP locally you may find this helpful
  2. CKEditor uses the contents.css file distributed by CKEditor for styling the contents in the editor. Make sure you are also including this stylesheet in your pages. If you want the editor to use your stylesheet then use the stylesheet plugin
  3. $_SERVER['DOCUMENT_ROOT'] is inherited form the http servers configuration. It will contain the absolute path to your sites root folder. If you are using absolute files paths there should not be an issue for knowing what path to use to include any file in your application. File paths can become a lot more tricky when you start using relative paths.
  4. $q is most likely set to a value that is not in your table? Why not echo the query to see what value $q contains and maybe dump the query results to see if they are what you are expecting them to be $sql = "SELECT * FROM guests WHERE adminid='{$adminid}' && table='$q'"; $seatedguests = DB::getInstance()->query($sql); echo "<pre>Query: $sql"; // dump query results echo "\nQuery Results: " . print_r($seatnumbers->results(), true) . "</pre>";
  5. So you only want plain text to be inserted into seo_page_description textarea, stripping out all html tags returned by CKEditor? In that case use JQuery.text method $('#seo_page_description').val($(evt.editor.getData()).text());
  6. Your form for registering the user has a submit button named register <input type="submit" value="Register" name="register"/> But your code for registering the user will only run if POST value named submit exists if(isset($_POST['submit'])){ You want to be checking if $_POST['register'] exists Why are you using filepaths in header redirects? header('Location: C:/xampp/htdocs/home.php'); header('Location: .C:/xampp/htdocs/index.php?action=joined'); You should be using urls header('Location: /home.php'); header('Location: /index.php?action=joined'); Also I wouldn't recommend hard coding absolute file paths. Instead either define a constant containing an absolute file path the root of your application (C:/xampp/htdocs) and prepend your file paths with that constant or use $_SERVER['DOCUMENT_ROOT'] instead define('ROOT', 'C:/xampp/htdocs/'); require_once(ROOT . 'includes/dbconfig.php'); // OR use require_once($_SERVER['DOCUMENT_ROOT'] . 'includes/dbconfig.php'); That way you only need to edit the file path in one place rather than having to hunt throughout your code to modify filepaths
  7. In that case you want to use CKEditors on change event. Then use editor.getData to get contents of the editor setting the the value for seo_page_description textarea using jquerys .val() method Updated example https://jsfiddle.net/mmm69xfo/2/
  8. Modifying Jacques1 code example https://jsfiddle.net/mmm69xfo/1/
  9. You need to use CKEditors setData method in order set the value for the editor
  10. You have a logic flaw in allocatetables.php foreach ($seatnumbers->results()as $seatresults) { if ($q="position1") {$seats=$seatresults->seat1; } else { if ($q="position2") {$seats=$seatresults->seat2; } else { if ($q="position3") {$seats=$seatresults->seat3; } else { if ($q="position4") {$seats=$seatresults->seat4; } else { if ($q="position5") {$seats=$seatresults->seat5; } else { if ($q="position6") {$seats=$seatresults->seat6; } else { if ($q="position7") {$seats=$seatresults->seat7; } else { if ($q="position8") {$seats=$seatresults->seat8; } else { if ($q="position9") {$seats=$seatresults->seat9; } else { if ($q="position10") $seats=$seatresults->seat10; } else { if ($q="position11") {$seats=$seatresults->seat11; } else { if ($q="position12") {$seats=$seatresults->seat12; }}}}}}}}}}}}} Your are using the wrong operator for checking $q, you should be using the comparison operator == not the assignment operator = This will result in $q being always set to position12 (overriding the value the user had submitted). So when your code goes to query the guests table it will always be looking for table position12
  11. Nothing wrong with the code Cobra23 has given. It appears you have caused that syntax error when using that code. The usual cause for that type of error is mis-matching curly braces { } . Each opening { brace should pair up with a closing } brace.
  12. Because you are using PHP tags within a string your are echo'ing. Remove the PHP tags echo "<a class=\"btn btn-danger delete-button\" id=\"$id\" role=\"button\">Delete</a>";
  13. What is your current code for receiving/outputting the results of your query?
  14. I thought you are setting up tasks for assigning to employees? Why is customer information being inserted into the tasks table? Should that information not be stored in its own table? What does customer details go to do with the task?
  15. After rowCount add () , it is a function not a variable.
  16. Why start a new topic? You already have a topic with the same question here. Please do not post duplicate topics, carry on where you left off. Locked.
  17. Yes, you would check to make sure the update query did execute and it did affect a row by checking PDOStatement::rowCount $result = $stmt->execute(array($_POST['descrip'], $_POST['status'], $_GET['task_id'])); if($result && $stmt->rowCount !== 0) { $msg = 'Task has been updated successfully'; } else { $msg = 'Sorry unable to update task.'; } Then before the opening <form> tag output the message <?php if(isset($msg)): ?> <p><?=$msg; ?></p> <?php endif; ?>
  18. No, you dont to do as Muddy_Funster suggested. What you want to do is similar to what Barand used for inserting the data. You only need to perform the update query if a post request has been made. Something like this // if form is submitted update task details if ($_SERVER['REQUEST_METHOD']=='POST') { // was data sent if ($_POST['descrip'] != '') { try { $sql = "UPDATE task SET description = ?, status = ? WHERE task_id = ?"; $stmt = $db->prepare($sql); $stmt->execute([$_POST['descrip'], $_POST['status'], $_GET['task_id']]); } catch (PDOException $e) { $db->rollBack(); die($e->getMessage()); } } } // select query here
  19. You are getting that error because when the form is submited it is not passing the task_id in the query string, therefor the variable $_GET['task_id'] will no longer exist. If you are going to be submitting the form to itself, then leave the form action blank <form method="post" action=""> If you want the description and status to be updated when the form is submitted then you need to use an update query, you will want to to do this before the select query.
  20. Left off the table alias and also the WHERE clause should of been AND $sql = "SELECT e.emp_id, e.emp_name, IF(a.emp_id IS NULL, 0, 1) as isAssigned FROM employees e LEFT JOIN assignment a ON e.emp_id = a.emp_id AND a.task_id = ?"; $stmt = $db->prepare($sql);
  21. Sorry, Remove 'task_id' => from this line $stmt->execute(array('task_id' => $task_id)); So it reads as $stmt->execute(array($task_id));
  22. Not sure why you are querying the employee table when you are editing a task. You need to be querying the task table to return the row where the task_id column matches the task_id query string parameter ($_GET['task_id']). // return the task which matches $_GET['task_id']; $sql=$dbh->prepare(" SELECT task_id description FROM task WHERE task_id = ?"); $sql->execute(array($_GET['task_id'])); After calling $sql->setFetchMode(PDO::FETCH_ASSOC); you need to actually fetch the row using // fetch the row from the result $row = $sql->fetch(); To show which employess that are assigned to the task you need to create a new function, you pass the task id to the function when calling it. The function will query the employees table, joining the assignment table on the emp_id columns. You will check the checkbox if the emp_id is not null in the joined table. function emps_assigned_by_taskid($db, $task_id) /******************************************* * function to list employees with checkboxes - checkbox is checked if they are assigned to the task ********************************************/ { $sql = "SELECT e.emp_id, e.emp_name, IF(a.emp_id IS NULL, 0, 1) as isAssigned FROM employee LEFT JOIN assignment a ON e.emp_id = a.emp_id WHERE a.task_id = ?"; $stmt = $db->prepare($sql); $stmt->execute(array('task_id' => $task_id)); $emps=''; foreach($stmt->fetchAll() as $row) { // if isAssigned is set to 1 then set the checked attribute, otherwise leave blank $checked = $row['isAssigned'] == 1 ? ' checked="checked" ' : ''; $emps .= "<input type='checkbox' name='emp_id[]' value='{$row['emp_id']}'{$checked}> {$row['emp_name']}<br>"; } return $emps; } To call the function you will use <?= emps_assigned_by_taskid($db, $_GET['task_id']) ?>
  23. No, your first query is not secure. You should be binding the $userName value to a placeholder in your select query, just like you did with your your second query. You should not be using md5 to hash passwords, instead use password_hash Also why are you using the users first and last names as their username? Not everyone in the word has unique names, alot of people that are not related share the same names. Why not just let the user pick there own username?
  24. Oh, you are outputting two different types of download links . You need to apply the cv-download class for this type of link too <td><a class="login_first_messg" href="#" class="cv-download">Download</a></td>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.