Jump to content

ianhaney

Member
  • Posts

    22
  • Joined

  • Last visited

Everything posted by ianhaney

  1. I am using this script and all works fine but is it possible to add a active class to the pagination so when on page 6 for example, the number 6 is highlighted so know which page number I am on, below is the current code I have // Count the total records $total_records = mysqli_num_rows($result); //Using ceil function to divide the total records on per page $total_pages = ceil($total_records / $per_page); //Going to first page echo "<div class='btn-group' style='margin:0 auto;display:table;'>"; echo "<br><br><center><a href='view-all-customers.php?page=1' class='btn btn-primary float-button-light' style='color:#FFFFFF;padding:6px 15px;'>".'First Page'."</a>"; for ($i=1; $i<=$total_pages; $i++) { echo "<a href='view-all-customers.php?page=".$i."' class='btn btn-primary float-button-light' style='color:#FFFFFF;padding:6px 15px;'>".$i."</a>"; }; // Going to last page echo "<a href='view-all-customers.php?page=$total_pages' class='btn btn-primary float-button-light' style='color:#FFFFFF;padding:6px 15px;'>".'Last Page'."</a></center>"; echo "</div>"; UPDATE: I managed to get it working using the following coding //check page and add active class for ($i=1; $i<=$total_pages; $i++) { $isActive = ''; if($i == $page){ $isActive = 'active'; } echo "<a href='view-all-customers.php?page=".$i."' class='".$isActive."btn btn-primary float-button-light' style='color:#FFFFFF;padding:6px 15px;'>".$i."</a>"; }; The complete code is below if anyone else needs it // Count the total records $total_records = mysqli_num_rows($result); //Using ceil function to divide the total records on per page $total_pages = ceil($total_records / $per_page); //Going to first page echo "<div class='btn-group' style='margin:0 auto;display:table;'>"; echo "<br><br><center><a href='view-all-customers.php?page=1' class='btn btn-primary float-button-light' style='color:#FFFFFF;padding:6px 15px;'>".'First Page'."</a>"; //check page and add active class for ($i=1; $i<=$total_pages; $i++) { $isActive = ''; if($i == $page){ $isActive = 'btn-active'; } echo "<a href='view-all-customers.php?page=".$i."' class='".$isActive." btn btn-primary float-button-light' style='color:#FFFFFF;padding:6px 15px;'>".$i."</a>"; }; // Going to last page echo "<a href='view-all-customers.php?page=$total_pages' class='btn btn-primary float-button-light' style='color:#FFFFFF;padding:6px 15px;'>".'Last Page'."</a></center>"; echo "</div>";
  2. I am using the crud mysqli script and want to be able to insert multiple checkbox values selected to the database table but add the values to one db table column, below is the coding I have but no data is being added <?php /* Allows the user to both create new records and edit existing records */ // creates the new/edit record form // since this form is used multiple times in this file, I have made it a function that is easily reusable function renderForm($customer_name = '', $customer_email = '', $customer_phone = '', $items_booked_in = '', $computer_make = '', $computer_model = '', $technician = '', $status = '', $exrdate = '', $exrtime = '', $exstdate = '', $exstime = '', $deltype = '', $comments = '', $job_cost = '', $part_cost = '', $profit = '', $error = '', $id = '', $send_sms = '', $username = '', $password = '') { ?> <form action="" method="post" class="form-valide"> <div class="form-group row"> <label class="col-lg-4 col-form-label">Items Booked In</label> <div class="col-lg-6"> <label>Laptop<input type="checkbox" class="form-control" name="Items[]" value="Laptop"/></label> &nbsp; <label>Charger<input type="checkbox" class="form-control" name="Items[]" value="Charger"/></label> &nbsp; <label>Laptop Bag<input type="checkbox" class="form-control" name="Items[]" value="Laptop Bag"/></label> </div> </div> </form> <?php } /* EDIT RECORD */ // if the 'id' variable is set in the URL, we know that we need to edit a record if (isset($_GET['id'])) { // if the form's submit button is clicked, we need to process the form if (isset($_POST['submit'])) { // make sure the 'id' in the URL is valid if (is_numeric($_POST['id'])) { // get variables from the URL/form $id = $_POST['id']; $customer_name = htmlentities($_POST['customer_name'], ENT_QUOTES); $customer_email = htmlentities($_POST['customer_email'], ENT_QUOTES); $customer_phone = htmlentities($_POST['customer_phone'], ENT_QUOTES); $items_booked_in = htmlentities($_POST['items_booked_in'], ENT_QUOTES); $computer_make = htmlentities($_POST['computer_make'], ENT_QUOTES); $computer_model = htmlentities($_POST['computer_model'], ENT_QUOTES); $technician = htmlentities($_POST['technician'], ENT_QUOTES); $status = htmlentities($_POST['status'], ENT_QUOTES); $exrdate = htmlentities($_POST['exrdate'], ENT_QUOTES); $exrtime = htmlentities($_POST['exrtime'], ENT_QUOTES); $exstdate = htmlentities($_POST['exstdate'], ENT_QUOTES); $exstime = htmlentities($_POST['exstime'], ENT_QUOTES); $deltype = htmlentities($_POST['deltype'], ENT_QUOTES); $comments = htmlentities($_POST['comments'], ENT_QUOTES); $job_cost = htmlentities($_POST['job_cost'], ENT_QUOTES); $part_cost = htmlentities($_POST['part_cost'], ENT_QUOTES); $profit = htmlentities($_POST['profit'], ENT_QUOTES); // check that firstname and lastname are both not empty if ($customer_name == '' || $customer_phone == '' || $computer_make == '' || $computer_model == '' || $comments == '') { // if they are empty, show an error message and display the form $error = 'ERROR: Please fill in all required fields!'; renderForm($customer_name, $customer_phone, $computer_make, $computer_model, $comments, $error, $id); } else { // if everything is fine, update the record in the database if ($stmt = $mysqli->prepare("UPDATE repairs SET customer_name = ?, customer_email = ?, customer_phone = ?, items_booked_in = ?, computer_make = ?, computer_model = ?, technician = ?, status = ?, exrdate = ?, exrtime = ?, exstdate = ?, exstime = ?, deltype = ?, comments = ?, job_cost = ?, part_cost = ?, profit = ? WHERE id=?")) { $stmt->bind_param("sssssssssssssssssi", $customer_name, $customer_email, $customer_phone, $items_booked_in, $computer_make, $computer_model, $technician, $status, $exrdate, $exrtime, $exstdate, $exstime, $deltype, $comments, $job_cost, $part_cost, $profit, $id); $stmt->execute(); $stmt->close(); } // show an error message if the query has an error else { echo "ERROR: could not prepare SQL statement."; } // redirect the user once the form is updated header("Location: view-all-repairs-tracking.php"); } } // if the 'id' variable is not valid, show an error message else { echo "Error!"; } } // if the form hasn't been submitted yet, get the info from the database and show the form else { // make sure the 'id' value is valid if (is_numeric($_GET['id']) && $_GET['id'] > 0) { // get 'id' from URL $id = $_GET['id']; // get the recod from the database if($stmt = $mysqli->prepare("SELECT id, customer_name, customer_email, customer_phone, items_booked_in, computer_make, computer_model, technician, status, exrdate, exrtime, exstdate, exstime, deltype, comments, job_cost, part_cost, profit, send_sms FROM repairs WHERE id=?")) { $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($id, $customer_name, $customer_email, $customer_phone, $items_booked_in, $computer_make, $computer_model, $technician, $status, $exrdate, $exrtime, $exstdate, $exstime, $deltype, $comments, $job_cost, $part_cost, $profit, $send_sms); $stmt->fetch(); // show the form renderForm($customer_name, $customer_email, $customer_phone, $items_booked_in, $computer_make, $computer_model, $technician, $status, $exrdate, $exrtime, $exstdate, $exstime, $deltype, $comments, $job_cost, $part_cost, $profit, NULL, $id, $send_sms); $stmt->close(); } // show an error if the query has an error else { echo "Error: could not prepare SQL statement"; } } // if the 'id' value is not valid, redirect the user back to the view.php page else { header("Location: view-all-repairs-tracking.php"); } } } /* NEW RECORD */ // if the 'id' variable is not set in the URL, we must be creating a new record else { // if the form's submit button is clicked, we need to process the form if (isset($_POST['submit'])) { $country_code = '44'; // get the form data $customer_name = htmlentities($_POST['customer_name'], ENT_QUOTES); $customer_email = htmlentities($_POST['customer_email'], ENT_QUOTES); $customer_phone = htmlentities($_POST['customer_phone'], ENT_QUOTES); $items=NULL; foreach($_POST['items_booked_in'] as $k){ $items[]=htmlentities($k, ENT_QUOTES); } $items=implode(',',$items); $computer_make = htmlentities($_POST['computer_make'], ENT_QUOTES); $computer_model = htmlentities($_POST['computer_model'], ENT_QUOTES); $technician = htmlentities($_POST['technician'], ENT_QUOTES); $status = htmlentities($_POST['status'], ENT_QUOTES); $exrdate = htmlentities($_POST['exrdate'], ENT_QUOTES); $exrtime = htmlentities($_POST['exrtime'], ENT_QUOTES); $exstdate = htmlentities($_POST['exstdate'], ENT_QUOTES); $exstime = htmlentities($_POST['exstime'], ENT_QUOTES); $deltype = htmlentities($_POST['deltype'], ENT_QUOTES); $comments = htmlentities($_POST['comments'], ENT_QUOTES); $job_cost = htmlentities($_POST['job_cost'], ENT_QUOTES); $part_cost = htmlentities($_POST['part_cost'], ENT_QUOTES); $profit = htmlentities($_POST['profit'], ENT_QUOTES); $username = htmlentities($_POST['user_name'], ENT_QUOTES); $password = htmlentities($_POST['user_pass'], ENT_QUOTES); // check that firstname and lastname are both not empty if ($customer_name == '' || $computer_make == '' || $computer_model == '' || $comments == '' ) { // if they are empty, show an error message and display the form $error = 'ERROR: Please fill in all required fields!'; renderForm($customer_name, $computer_make, $computer_model, $comments, $username, $password, $error); } else { // insert the new record into the database //hash the password $hashed_password = password_hash($password, PASSWORD_DEFAULT); if ($stmt = $mysqli->prepare("INSERT repairs (customer_name, customer_email, customer_phone, items_booked_in, computer_make, computer_model, technician, status, exrdate, exrtime, exstdate, exstime, deltype, comments, job_cost, part_cost, profit, user_name, user_pass) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) { $stmt->bind_param("sssssssssssssssssss", $customer_name, $customer_email, $customer_phone, $items_booked_in, $computer_make, $computer_model, $technician, $status, $exrdate, $exrtime, $exstdate, $exstime, $deltype, $comments, $job_cost, $part_cost, $profit, $username, $password); $stmt->execute(); $repair_id = $mysqli->insert_id; //check for existing user $check_user = $mysqli->prepare("SELECT customer_email,customer_phone from users where customer_email=?"); $check_user->bind_param("s", $customer_email); $check_user->execute(); $check_user->bind_result($customer_email, $customer_phone); if(!$check_user->fetch()){ if ($stmt = $mysqli->prepare("INSERT users (user_name, user_pass, customer_name, customer_email, customer_phone) VALUES (?, ?, ?, ?, ?)")) { $stmt->bind_param("sssss", $username, $hashed_password, $customer_name, $customer_email, $customer_phone); $stmt->execute(); $userid=$stmt->insert_id; $stmt->close(); $stmt = $mysqli->prepare("UPDATE repairs SET userid = $userid WHERE id=$repair_id"); $stmt->execute(); $stmt->close(); } // show an error if the query has an error else { echo "ERROR: Could not prepare SQL statement."; } } if ($stmt = $mysqli->prepare("UPDATE repairs SET send_sms = 1 WHERE id=$repair_id")) { $stmt->execute(); $stmt->close(); } // show an error message if the query has an error else { echo "ERROR: could not prepare SQL statement."; } endif; } // redirec the user header("Location: view-all-repairs-tracking.php"); } } // if the form hasn't been submitted yet, show the form else { renderForm(); } } // close the mysqli connection $mysqli->close(); ?> Thank you in advance
  3. I need bit of help with this script if possible. I am trying to add multiple checkbox values into one database table column separated by commas but I can't seem to get it adding to the DB, I have added php error reporting on the site but is not showing any errors after clicking the submit button. My coding is below <?php /* Allows the user to both create new records and edit existing records */ // creates the new/edit record form // since this form is used multiple times in this file, I have made it a function that is easily reusable function renderForm($customer_name = '', $customer_email = '', $customer_phone = '', $items_booked_in = '', $computer_make = '', $computer_model = '', $technician = '', $status = '', $exrdate = '', $exrtime = '', $exstdate = '', $exstime = '', $deltype = '', $comments = '', $job_cost = '', $part_cost = '', $profit = '', $error = '', $id = '', $send_sms = '', $username = '', $password = '') { ?> <!-- Page wrapper --> <div class="page-wrapper"> <!-- Bread crumb --> <div class="row page-titles"> <div class="col-md-5 align-self-center"> <h3 class="text-primary">Add/Edit Repair</h3> </div> <div class="col-md-7 align-self-center"> <ol class="breadcrumb"> <li class="breadcrumb-item"><a href="../dashboard.php">Dashboard</a></li> <li class="breadcrumb-item active">Add/Edit Repair</li> </ol> </div> </div> <!-- End Bread crumb --> <!-- Container fluid --> <div class="container-fluid"> <!-- Start Page Content --> <div class="row"> <div class="col-12"> <div class="card"> <div class="card-body"> <h1><?php if ($id != '') { echo "Edit Repair"; } else { echo "New Repair"; } ?></h1> <?php if ($error != '') { echo "<div style='padding:4px; border:1px solid red; color:red'>" . $error . "</div>"; } ?> <form action="" method="post" class="form-valide"> <div class="form-group row"> <label class="col-lg-4 col-form-label">Items Booked In</label> <div class="col-lg-6"> <label>Laptop<input type="checkbox" class="form-control" name="items_booked_in[]" value="Laptop"/></label> <label>Charger<input type="checkbox" class="form-control" name="items_booked_in[]" value="Charger"/></label> <label>Laptop Bag<input type="checkbox" class="form-control" name="items_booked_in[]" value="Laptop Bag"/></label> </div> </div> <?php } /* EDIT RECORD */ // if the 'id' variable is set in the URL, we know that we need to edit a record if (isset($_GET['id'])) { // if the form's submit button is clicked, we need to process the form if (isset($_POST['submit'])) { // make sure the 'id' in the URL is valid if (is_numeric($_POST['id'])) { // get variables from the URL/form $id = $_POST['id']; $customer_name = htmlentities($_POST['customer_name'], ENT_QUOTES); $customer_email = htmlentities($_POST['customer_email'], ENT_QUOTES); $customer_phone = htmlentities($_POST['customer_phone'], ENT_QUOTES); $items_booked_in = htmlentities($_POST['items_booked_in'], ENT_QUOTES); $computer_make = htmlentities($_POST['computer_make'], ENT_QUOTES); $computer_model = htmlentities($_POST['computer_model'], ENT_QUOTES); $technician = htmlentities($_POST['technician'], ENT_QUOTES); $status = htmlentities($_POST['status'], ENT_QUOTES); $exrdate = htmlentities($_POST['exrdate'], ENT_QUOTES); $exrtime = htmlentities($_POST['exrtime'], ENT_QUOTES); $exstdate = htmlentities($_POST['exstdate'], ENT_QUOTES); $exstime = htmlentities($_POST['exstime'], ENT_QUOTES); $deltype = htmlentities($_POST['deltype'], ENT_QUOTES); $comments = htmlentities($_POST['comments'], ENT_QUOTES); $job_cost = htmlentities($_POST['job_cost'], ENT_QUOTES); $part_cost = htmlentities($_POST['part_cost'], ENT_QUOTES); $profit = htmlentities($_POST['profit'], ENT_QUOTES); // check that firstname and lastname are both not empty if ($customer_name == '' || $customer_phone == '' || $computer_make == '' || $computer_model == '' || $comments == '') { // if they are empty, show an error message and display the form $error = 'ERROR: Please fill in all required fields!'; renderForm($customer_name, $customer_phone, $computer_make, $computer_model, $comments, $error, $id); } else { // if everything is fine, update the record in the database if ($stmt = $mysqli->prepare("UPDATE repairs SET customer_name = ?, customer_email = ?, customer_phone = ?, items_booked_in = ?, computer_make = ?, computer_model = ?, technician = ?, status = ?, exrdate = ?, exrtime = ?, exstdate = ?, exstime = ?, deltype = ?, comments = ?, job_cost = ?, part_cost = ?, profit = ? WHERE id=?")) { $stmt->bind_param("sssssssssssssssssi", $customer_name, $customer_email, $customer_phone, $items_booked_in, $computer_make, $computer_model, $technician, $status, $exrdate, $exrtime, $exstdate, $exstime, $deltype, $comments, $job_cost, $part_cost, $profit, $id); $stmt->execute(); $stmt->close(); } // show an error message if the query has an error else { echo "ERROR: could not prepare SQL statement."; } // redirect the user once the form is updated header("Location: view-all-repairs-tracking.php"); } } // if the 'id' variable is not valid, show an error message else { echo "Error!"; } } // if the form hasn't been submitted yet, get the info from the database and show the form else { // make sure the 'id' value is valid if (is_numeric($_GET['id']) && $_GET['id'] > 0) { // get 'id' from URL $id = $_GET['id']; // get the recod from the database if($stmt = $mysqli->prepare("SELECT id, customer_name, customer_email, customer_phone, items_booked_in, computer_make, computer_model, technician, status, exrdate, exrtime, exstdate, exstime, deltype, comments, job_cost, part_cost, profit, send_sms FROM repairs WHERE id=?")) { $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($id, $customer_name, $customer_email, $customer_phone, $items_booked_in, $computer_make, $computer_model, $technician, $status, $exrdate, $exrtime, $exstdate, $exstime, $deltype, $comments, $job_cost, $part_cost, $profit, $send_sms); $stmt->fetch(); // show the form renderForm($customer_name, $customer_email, $customer_phone, $items_booked_in, $computer_make, $computer_model, $technician, $status, $exrdate, $exrtime, $exstdate, $exstime, $deltype, $comments, $job_cost, $part_cost, $profit, NULL, $id, $send_sms); $stmt->close(); } // show an error if the query has an error else { echo "Error: could not prepare SQL statement"; } } // if the 'id' value is not valid, redirect the user back to the view.php page else { header("Location: view-all-repairs-tracking.php"); } } } /* NEW RECORD */ // if the 'id' variable is not set in the URL, we must be creating a new record else { // if the form's submit button is clicked, we need to process the form if (isset($_POST['submit'])) { $country_code = '44'; // get the form data $customer_name = htmlentities($_POST['customer_name'], ENT_QUOTES); $customer_email = htmlentities($_POST['customer_email'], ENT_QUOTES); $customer_phone = htmlentities($_POST['customer_phone'], ENT_QUOTES); $items_booked_in = htmlentities($_POST['items_booked_in'], ENT_QUOTES); $computer_make = htmlentities($_POST['computer_make'], ENT_QUOTES); $computer_model = htmlentities($_POST['computer_model'], ENT_QUOTES); $technician = htmlentities($_POST['technician'], ENT_QUOTES); $status = htmlentities($_POST['status'], ENT_QUOTES); $exrdate = htmlentities($_POST['exrdate'], ENT_QUOTES); $exrtime = htmlentities($_POST['exrtime'], ENT_QUOTES); $exstdate = htmlentities($_POST['exstdate'], ENT_QUOTES); $exstime = htmlentities($_POST['exstime'], ENT_QUOTES); $deltype = htmlentities($_POST['deltype'], ENT_QUOTES); $comments = htmlentities($_POST['comments'], ENT_QUOTES); $job_cost = htmlentities($_POST['job_cost'], ENT_QUOTES); $part_cost = htmlentities($_POST['part_cost'], ENT_QUOTES); $profit = htmlentities($_POST['profit'], ENT_QUOTES); $username = htmlentities($_POST['user_name'], ENT_QUOTES); $password = htmlentities($_POST['user_pass'], ENT_QUOTES); // check that firstname and lastname are both not empty if ($customer_name == '' || $computer_make == '' || $computer_model == '' || $comments == '' ) { // if they are empty, show an error message and display the form $error = 'ERROR: Please fill in all required fields!'; renderForm($customer_name, $computer_make, $computer_model, $comments, $username, $password, $error); } else { // insert the new record into the database //hash the password $hashed_password = password_hash($password, PASSWORD_DEFAULT); if ($stmt = $mysqli->prepare("INSERT repairs (customer_name, customer_email, customer_phone, items_booked_in, computer_make, computer_model, technician, status, exrdate, exrtime, exstdate, exstime, deltype, comments, job_cost, part_cost, profit, user_name, user_pass) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) { $stmt->bind_param("sssssssssssssssssss", $customer_name, $customer_email, $customer_phone, $items_booked_in, $computer_make, $computer_model, $technician, $status, $exrdate, $exrtime, $exstdate, $exstime, $deltype, $comments, $job_cost, $part_cost, $profit, $username, $password); $stmt->execute(); $repair_id = $mysqli->insert_id; //check for existing user $check_user = $mysqli->prepare("SELECT customer_email,customer_phone from users where customer_email=?"); $check_user->bind_param("s", $customer_email); $check_user->execute(); $check_user->bind_result($customer_email, $customer_phone); if(!$check_user->fetch()){ if ($stmt = $mysqli->prepare("INSERT users (user_name, user_pass, customer_name, customer_email, customer_phone) VALUES (?, ?, ?, ?, ?)")) { $stmt->bind_param("sssss", $username, $hashed_password, $customer_name, $customer_email, $customer_phone); $stmt->execute(); $userid=$stmt->insert_id; $stmt->close(); $stmt = $mysqli->prepare("UPDATE repairs SET userid = $userid WHERE id=$repair_id"); $stmt->execute(); $stmt->close(); } // show an error if the query has an error else { echo "ERROR: Could not prepare SQL statement."; } } { $stmt->execute(); $stmt->close(); } // show an error message if the query has an error else { echo "ERROR: could not prepare SQL statement."; } endif; } // redirec the user header("Location: view-all-repairs-tracking.php"); } } // if the form hasn't been submitted yet, show the form else { renderForm(); } } // close the mysqli connection $mysqli->close(); ?> Thank you in advance
  4. Hi I need some help or advice, I want to upload and download a file along with adding other data like name and email using the form but am not sure how to do it if someone can help me please Thank you in advance Ian
  5. Hi, I need some help with this and creating a search form that allows me to filter dates so I can see data between two dates but I keep getting no results to display even though I should have 1 set displayed based on the dates I am entering, below is my code search-data.php <form method="post" action="data-results.php"> <label>From Date : </label><input type="text" name="exrdate" id="fromdate" /> <br/><br/> <label>To Date : </label><input type="text" name="exrdate" id="todate" /> <br/><br/> <input type="submit" name="submit" value="Submit" /> </form> data-results.php <?php ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); ?> <?php // connect to the database include('connect-db.php'); $per_page=5; if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; } // Page will start from 0 and Multiple by Per Page $start_from = ($page-1) * $per_page; // if the form's submit button is clicked, we need to process the form if (isset($_POST['submit'])) { $fromdate = mysqli_real_escape_string($mysqli, $_POST['exrdate']); $todate = mysqli_real_escape_string($mysqli, $_POST['exrdate']); // get the records from the database if ($result = $mysqli->query("SELECT id, customer_name, customer_email, customer_phone, computer_make, computer_model, technician, status, DATE_FORMAT(exrdate,'%d/%m/%Y') AS exrdate, exrtime, DATE_FORMAT(exstdate,'%d/%m/%Y') AS exstdate, exstime, deltype, comments, job_cost, part_cost, profit FROM repairs WHERE exrdate between '$fromdate' and '$todate' ORDER BY id LIMIT $start_from, $per_page")) { // display records if there are records to display if ($result->num_rows > 0) { // display records in a table echo "<table class='view-repairs'>"; // set table headers echo "<tr><th>Repair ID</th> <th>Customer Name</th> <th>Customer Email</th> <th>Customer Phone</th> <th>Computer Make</th> <th>Computer Model</th> <th>Technician</th> <th>Status</th> <th>Expected Start Date</th> <th>Expected Start Time</th> <th>Expected Repair Date</th> <th>Expected Repair Time</th> <th>Delivery Type</th> <th>Comments</th> <th>Job Repair Cost</th> <th>Part(s) Cost</th> <th>Profit</th> <th colspan='2'>Actions</th> </tr>"; while ($row = $result->fetch_object()) { // set up a row for each record echo "<tr>"; echo "<td><a href='view-specific-repair.php?id=" . $row->id . "'>".$row->id . "</a></td>"; echo "<td>" . $row->customer_name . "</td>"; echo "<td>" . $row->customer_email . "</td>"; echo "<td>" . $row->customer_phone . "</td>"; echo "<td>" . $row->computer_make . "</td>"; echo "<td>" . $row->computer_model . "</td>"; echo "<td>" . $row->technician . "</td>"; echo "<td>" . $row->status . "</td>"; echo "<td>" . $row->exstdate . "</td>"; echo "<td>" . $row->exstime . "</td>"; echo "<td>" . $row->exrdate . "</td>"; echo "<td>" . $row->exrtime . "</td>"; echo "<td>" . $row->deltype . "</td>"; echo "<td>" . substr($row->comments, 0, 25) . "</td>"; echo "<td>" . '£' . $row->job_cost . "</td>"; echo "<td>" . '£' . $row->part_cost . "</td>"; echo "<td>" . '£' . $row->profit . "</td>"; echo "<td><a href='repairs-tracking.php?id=" . $row->id . "'>Edit</a></td>"; echo "<td><a href='delete-repair.php?id=" . $row->id . "'>Delete</a></td>"; echo "</tr>"; } echo "</table>"; } // if there are no records in the database, display an alert message else { echo "No results to display!"; } } // show an error if there is an issue with the database query else { echo "Error: " . $mysqli->error; } $query = "select * from repairs"; $result = mysqli_query($mysqli, $query); // Count the total records $total_records = mysqli_num_rows($result); //Using ceil function to divide the total records on per page $total_pages = ceil($total_records / $per_page); //Going to first page echo "<center><a href='view-repairs-tracking.php?page=1'>".'First Page'."</a> "; for ($i=1; $i<=$total_pages; $i++) { echo "<a href='view-repairs-tracking.php?page=".$i."'>".$i."</a> "; }; // Going to last page echo "<a href='view-repairs-tracking.php?page=$total_pages'>".'Last Page'."</a></center> "; // close database connection $mysqli->close(); } ?> Thank you in advance Ian
  6. Hi Stef Oh right ok cool I need bit of help with a update issue, I am using this script and for some reason, the data is not being updated. I only want to be able to update three columns within the database table but don't seem to be doing it I have put the coding in a pastebin link below http://pastebin.com/mK9eAHQ9
  7. Hi Is this forum still active as have a quick question about this script
  8. I know it is the datepicker confusing the mysql as the standard format is YYYY-MM-DD but datepicker is changing it to DD/MM/YY so just not sure how to have it as DD/MM/YY but make it still add into the database as YYYY/MM/DD or convert to DD/MM/YYYY in the database Hope that makes sense
  9. Hi I am having a couple more issues with the script I have added in some extra fields and all works apart from two of the extra fields, I have made them date input fields and the mysql data type is date and am using datepicker but for some reason, the date is being added into the mysql table as 00/00/0000 Can't work out why, the coding is below <?php ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); ?> <?php /* Allows the user to both create new records and edit existing records */ // connect to the database include("connect-db.php"); // creates the new/edit record form // since this form is used multiple times in this file, I have made it a function that is easily reusable function renderForm($customer_name = '', $customer_email ='', $customer_phone ='', $computer_make ='', $computer_model ='', $technician ='', $status ='', $exrdate ='', $exrtime ='', $exstdate ='', $exstime ='', $deltype ='', $comments ='', $error = '', $id = '') { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title> <?php if ($id != '') { echo "Edit Repair Tracking"; } else { echo "New Repair Tracking"; } ?> </title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="stylesheet"href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/blitzer/jquery-ui.css"/> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script> <link rel="stylesheet" type="text/css" media="screen" href="css/styles.css" /> <script src="js/jquery.ui.timepicker.js"></script> <link rel="stylesheet" type="text/css" media="screen" href="css/jquery.ui.timepicker.css" /> <script> $(function() { $( "#exrdate" ).datepicker({ showButtonPanel: true, dateFormat: "dd/mm/yy", showOn:"both" }); }); $(function() { $( "#exstdate" ).datepicker({ showButtonPanel: true, dateFormat: "dd/mm/yy", showOn:"both" }); }); </script> <script> $(document).ready(function() { $('#exrtime').timepicker({ defaultTime: '12:00', showLeadingZero: true, showNowButton: true, showCloseButton: true, showDeselectButton: true, showOn: 'both', }); $('#exstime').timepicker({ defaultTime: '12:00', showLeadingZero: true, showNowButton: true, showCloseButton: true, showDeselectButton: true, showOn: 'both', }); }); </script> </head> <body> <div id="logo"> <img src="images/logo/it-done-right.jpg" alt="" title=""> </div> <? session_start(); if($_SESSION['user']==''){ header("Location:../index.php"); }else{ include("../config.php"); $sql=$dbh->prepare("SELECT * FROM users WHERE id=?"); $sql->execute(array($_SESSION['user'])); while($r=$sql->fetch()){ echo "<div class='home-content'>"; echo "<center><h2>Hello, ".$r['username']."</h2>"; echo "<a href='../logout.php'>Log Out</a> <br><br> <a href='../index.php'>Home</a></center>"; echo "</div>"; } } ?> <h1><?php if ($id != '') { echo "Edit Record"; } else { echo "New Record"; } ?></h1> <?php if ($error != '') { echo "<div style='padding:4px; border:1px solid red; color:red'>" . $error . "</div>"; } ?> <form action="" method="post" class="basic-grey"> <div> <?php if ($id != '') { ?> <input type="hidden" name="id" value="<?php echo $id; ?>" /> <p>Repair ID: <?php echo $id; ?></p> <?php } ?> <br> <strong>Customer Name:</strong> <input type="text" name="customer_name" value="<?php echo $customer_name; ?>"/> <br/> <strong>Customer Email:</strong> <input type="text" name="customer_email" value="<?php echo $customer_email; ?>"/> <br> <strong>Customer Phone:</strong> <input type="text" name="customer_phone" value="<?php echo $customer_phone; ?>"/> <br> <strong>Computer Make:</strong> <input type="text" name="computer_make" value="<?php echo $computer_make; ?>"/> <br> <strong>Computer Model:</strong> <input type="text" name="computer_model" value="<?php echo $computer_model; ?>"/> <br> <strong>Assigned to Technician:</strong> <select name="technician"> <option value="Phil Roskams">Phil Roskams</option> <option value="Ian Haney">Ian Haney</option> </select> <br> <strong>Repair Status:</strong> <select name="status"> <option value="In Queue">In Queue</option> <option value="Working on">Working on</option> <option value="Awaiting Parts">Awaiting Parts</option> <option value="Ready for Collection/Delivery">Ready for Collection/Delivery</option> </select> <br> <strong>Expected Repair Date:</strong> <input type="date" name="exrdate" value="<?php echo $exrdate; ?>" id="exrdate"/> <br><br> <strong>Expected Repair Time:</strong> <input type="time" name="exrtime" value="<?php echo $exrtime; ?>" id="exrtime"/> <br><br> <strong>Expected Start Date:</strong> <input type="date" name="exstdate" value="<?php echo $exstdate; ?>" id="exstdate" /> <br><br> <strong>Expected Start Time:</strong> <input type="time" name="exstime" value="<?php echo $exstime; ?>" id="exstime"/> <br><br> <strong>Delivery Type:</strong> <select name="deltype"> <option value="Customer Pickup">Customer Pickup</option> <option value="Delivery">Delivery</option> </select> <br> <strong>Comments: <br> <textarea name="comments"> <?php echo $comments; ?> </textarea> <br> <input type="submit" name="submit" value="Add/Update Repair Tracking" /> </div> </form> </body> </html> <?php } /* EDIT RECORD */ // if the 'id' variable is set in the URL, we know that we need to edit a record if (isset($_GET['id'])) { // if the form's submit button is clicked, we need to process the form if (isset($_POST['submit'])) { // make sure the 'id' in the URL is valid if (is_numeric($_POST['id'])) { // get variables from the URL/form $id = $_POST['id']; $customer_name = htmlentities($_POST['customer_name'], ENT_QUOTES); $customer_email = htmlentities($_POST['customer_email'], ENT_QUOTES); $customer_phone = htmlentities($_POST['customer_phone'], ENT_QUOTES); $computer_make = htmlentities($_POST['computer_make'], ENT_QUOTES); $computer_model = htmlentities($_POST['computer_model'], ENT_QUOTES); $technician = htmlentities($_POST['technician'], ENT_QUOTES); $status = htmlentities($_POST['status'], ENT_QUOTES); $exrdate = htmlentities($_POST['exrdate'], ENT_QUOTES); $exrtime = htmlentities($_POST['exrtime'], ENT_QUOTES); $exstdate = htmlentities($_POST['exstdate'], ENT_QUOTES); $exstime = htmlentities($_POST['exstime'], ENT_QUOTES); $deltype = htmlentities($_POST['deltype'], ENT_QUOTES); $comments = htmlentities($_POST['comments'], ENT_QUOTES); // check that firstname and lastname are both not empty if ($customer_name == '' || $customer_phone == '' || $computer_make == '' || $computer_model == '' || $comments == '') { // if they are empty, show an error message and display the form $error = 'ERROR: Please fill in all required fields!'; renderForm($customer_name, $customer_phone, $computer_make, $computer_model, $comments, $error, $id); } else { // if everything is fine, update the record in the database if ($stmt = $mysqli->prepare("UPDATE repairs SET customer_name = ?, customer_email = ?, customer_phone = ?, computer_make = ?, computer_model = ?, technician = ?, status = ?, exrdate = ?, exrtime = ?, exstdate = ?, exstime = ?, deltype = ?, comments = ? WHERE id=?")) { $stmt->bind_param("sssssssssssssi", $customer_name, $customer_email, $customer_phone, $computer_make, $computer_model, $technician, $status, $exrdate, $exrtime, $exstdate, $exstime, $deltype, $comments, $id); $stmt->execute(); $stmt->close(); } // show an error message if the query has an error else { echo "ERROR: could not prepare SQL statement."; } // redirect the user once the form is updated header("Location: view-repairs-tracking.php"); } } // if the 'id' variable is not valid, show an error message else { echo "Error!"; } } // if the form hasn't been submitted yet, get the info from the database and show the form else { // make sure the 'id' value is valid if (is_numeric($_GET['id']) && $_GET['id'] > 0) { // get 'id' from URL $id = $_GET['id']; // get the recod from the database if($stmt = $mysqli->prepare("SELECT id, customer_name, customer_email, customer_phone, computer_make, computer_model, technician, status, exrdate, exrtime, exstdate, exstime, deltype, comments FROM repairs WHERE id=?")) { $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($id, $customer_name, $customer_email, $customer_phone, $computer_make, $computer_model, $technician, $status, $exrdate, $exrtime, $exstdate, $exstime, $deltype, $comments); $stmt->fetch(); // show the form renderForm($customer_name, $customer_email, $customer_phone, $computer_make, $computer_model, $technician, $status, $exrdate, $exrtime, $exstdate, $exstime, $deltype, $comments, NULL, $id); $stmt->close(); } // show an error if the query has an error else { echo "Error: could not prepare SQL statement"; } } // if the 'id' value is not valid, redirect the user back to the view.php page else { header("Location: view-repairs-tracking.php"); } } } /* NEW RECORD */ // if the 'id' variable is not set in the URL, we must be creating a new record else { // if the form's submit button is clicked, we need to process the form if (isset($_POST['submit'])) { // get the form data $customer_name = htmlentities($_POST['customer_name'], ENT_QUOTES); $customer_email = htmlentities($_POST['customer_email'], ENT_QUOTES); $customer_phone = htmlentities($_POST['customer_phone'], ENT_QUOTES); $computer_make = htmlentities($_POST['computer_make'], ENT_QUOTES); $computer_model = htmlentities($_POST['computer_model'], ENT_QUOTES); $technician = htmlentities($_POST['technician'], ENT_QUOTES); $status = htmlentities($_POST['status'], ENT_QUOTES); $exrdate = htmlentities($_POST['exrdate'], ENT_QUOTES); $exrtime = htmlentities($_POST['exrtime'], ENT_QUOTES); $exstdate = htmlentities($_POST['exstdate'], ENT_QUOTES); $exstime = htmlentities($_POST['exstime'], ENT_QUOTES); $deltype = htmlentities($_POST['deltype'], ENT_QUOTES); $comments = htmlentities($_POST['comments'], ENT_QUOTES); // check that firstname and lastname are both not empty if ($customer_name == '' || $customer_phone == '' || $computer_make == '' || $computer_model == '' || $comments == '') { // if they are empty, show an error message and display the form $error = 'ERROR: Please fill in all required fields!'; renderForm($customer_name, $customer_phone, $computer_make, $computer_model, $comments, $error); } else { // insert the new record into the database if ($stmt = $mysqli->prepare("INSERT repairs (customer_name, customer_email, customer_phone, computer_make, computer_model, technician, status, exrdate, exrtime, exstdate, exstime, deltype, comments) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) { $stmt->bind_param("sssssssssssss", $customer_name, $customer_email, $customer_phone, $computer_make, $computer_model, $technician, $status, $exrdate, $exrtime, $exstdate, $exstime, $deltype, $comments); $stmt->execute(); $stmt->close(); } // show an error if the query has an error else { echo "ERROR: Could not prepare SQL statement."; } // redirec the user header("Location: view-repairs-tracking.php"); } } // if the form hasn't been submitted yet, show the form else { renderForm(); } } // close the mysqli connection $mysqli->close(); ?> Hope someone can help me please
  10. Sorry got it sorted, I forgot to add the id to the form tag
  11. Hi I need bit of help if ok with this script I have put all the coding in and seems to be all ok but on the records.php file, I want to add in a select menu and then show extra text input fields based on what the user selects in the select menu but the extra fields don't show when I select a option value below is my coding for the records.php file with the select menu part and it's javascript <form action="" method="post" class="basic-grey"> <div> <?php if ($id != '') { ?> <input type="hidden" name="id" value="<?php echo $id; ?>" /> <p>ID: <?php echo $id; ?></p> <?php } ?> <strong>Plan Name: *</strong> <select name="support_plans" id="plan"> <option>Select the support plan</option> <option value="Domestic">Domestic</option> <option value="Domestic+">Domestic+</option> <option value="Domestic Gold">Domestic Gold</option> <option value="Domestic+ Gold">Domestic+ Gold</option> <option value="Commercial">Commercial</option> </select> <br/> <div id="extra" style="display:none"> <strong>PC/Laptop 1: *</strong> <input type="text" name="machine1" value="<?php echo $machine1; ?>"/> <br> <strong>PC/Laptop 2: *</strong> <input type="text" name="machine2" value="<?php echo $machine2; ?>"/> <br> <strong>PC/Laptop 3: *</strong> <input type="text" name="machine3" value="<?php echo $machine3; ?>"/> <br> <strong>PC/Laptop 4: *</strong> <input type="text" name="machine4" value="<?php echo $machine4; ?>"/> <br> <strong>PC/Laptop 5: *</strong> <input type="text" name="machine5" value="<?php echo $machine5; ?>"/> </div> <br> <strong>Customer Name: *</strong> <input type="text" name="customer_name" value="<?php echo $customer_name; ?>"/> <br> <strong>Customer Email: *</strong> <input type="text" name="customer_email" value="<?php echo $customer_email; ?>"/> <br> <strong>Customer Phone: *</strong> <input type="text" name="customer_phone" value="<?php echo $customer_phone; ?>"/> <br> <strong>Date Plan Purchased: *</strong> <input type="text" name="date_plan_purchased" value="<?php echo $date_plan_purchased; ?>"/> <br> <p>* required</p> <input type="submit" name="submit" value="Submit" /> </div> </form> <script> $(document).ready(function () { $('#support select[name="support_plans"]').change(function () { val = $('#support select[name="support_plans"] option:selected').val(); if (val == 'Domestic+' || val == 'Domestic+ Gold' || val == 'Commercial') { $('#extra').css('display', 'inline'); } else { $('#extra').css('display', 'none'); } }); }); </script> Can someone help me please as can't work it out and I have also added in the jquery 1.10.1 from googleapi Thank you in advance Ian
  12. Hi I need bit of help on the edit.php page I got the following errors come up and was just seeing if anyone could help with where I am going wrong please if ok Warning: Missing argument 13 for renderForm(), called in /home/sites/broadwaymediadesigns.co.uk/public_html/sites/micromend/admin/edit.php on line 163 and defined in /home/sites/broadwaymediadesigns.co.uk/public_html/sites/micromend/admin/edit.php on line 26 Notice: Undefined variable: error in /home/sites/broadwaymediadesigns.co.uk/public_html/sites/micromend/admin/edit.php on line 41 Below is the coding from the edit.php page <?php error_reporting(-1); ini_set('display_errors', 'On'); ?> <?php session_start(); if(empty($_SESSION['loggedin'])) { header('Location: http://' . $_SERVER['HTTP_HOST'] . '/admin/login.php'); exit; } echo 'You will only see this if you are logged in.'; ?> <?php /* EDIT.PHP Allows user to edit specific entry in database */ // creates the edit record form // since this form is used multiple times in this file, I have made it a function that is easily reusable function renderForm($visitor_id, $visitor_name, $visitor_name, $visitor_email, $visitor_firstline, $visitor_secondline, $visitor_town, $visitor_county, $visitor_postcode, $visitor_tel, $visitor_mobile, $visitor_newsletter, $error) { ?> <?php include ( 'includes/header.php' ); ?> <title>Admin edit customers data</title> </head> <body> <div id='column-whole-inner'> <?php // if there are any errors, display them if ($error != '') { echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>'; } ?> <form action="" method="post"> <input type="hidden" name="id" value="<?php echo $visitor_id; ?>"/> <div> <p><strong>Visitor ID:</strong> <?php echo $visitor_id; ?></p> <strong>Name: *</strong> <input type="text" name="visitor_name" value="<?php echo $visitor_name; ?>"/> <br/><br> <strong>Email: *</strong> <input type="text" name="visitor_email" value="<?php echo $visitor_email; ?>"/> <br/><br> <strong>Address Line 1: *</strong> <input type="text" name="visitor_firstline" value="<?php echo $visitor_firstline;?>"/> <br><br> <strong>Address Line 2: *</strong> <input type="text" name="visitor_secondline" value="<?php echo $visitor_secondline;?>"/> <br><br> <strong>Town: *</strong> <input type="text" name="visitor_town" value="<?php echo $visitor_town; ?>"/> <br><br> <strong>County: *</strong> <textarea name="visitor_county" rows="8" cols="30"><?php echo $visitor_county; ?></textarea> <br><br> <strong>Postcode: *</strong> <input type="text" name="visitor_postcode" value="<?php echo $visitor_postcode; ?>"/> <br><br> <strong>Telephone Number: *</strong> <input type="text" name="visitor_tel" value="<?php echo $visitor_tel; ?>"/> <br><br> <strong>Mobile Number: *</strong> <input type="text" name="visitor_mobile" value="<?php echo $visitor_mobile; ?>"/> <br> <label style="color: #FFFFFF;"><input type="radio" name="visitor_newsletter" value="Yes" <?php if($visitor_newsletter == Yes) echo 'checked="checked"'; ?> > Yes</label> <br> <label style="color: #FFFFFF;"><input type="radio" name="visitor_newsletter" value="No"<?php if($visitor_newsletter == No) echo 'checked="checked"'; ?> > No</label> <p>* Required</p> <input type="submit" name="submit" value="Submit"> </div> </form> </div> </body> </html> <?php } // connect to the database include('config.php'); // check if the form has been submitted. If it has, process the form and save it to the database if (isset($_POST['submit'])) { // confirm that the 'id' value is a valid integer before getting the form data if (is_numeric($_POST['visitor_id'])) { // get form data, making sure it is valid $visitor_id = $_POST['visitor_id']; $visitor_name = mysql_real_escape_string(htmlspecialchars($_POST['visitor_name'])); $visitor_email = mysql_real_escape_string(htmlspecialchars($_POST['visitor_email'])); $visitor_firstline = mysql_real_escape_string(htmlspecialchars($_POST['visitor_firstline'])); $visitor_secondline = mysql_real_escape_string(htmlspecialchars($_POST['visitor_secondline'])); $visitor_town = mysql_real_escape_string(htmlspecialchars($_POST['visitor_town'])); $visitor_county = mysql_real_escape_string(htmlspecialchars($_POST['visitor_county'])); $visitor_postcode = mysql_real_escape_string(htmlspecialchars($_POST['visitor_postcode'])); $visitor_tel = mysql_real_escape_string(htmlspecialchars($_POST['visitor_tel'])); $visitor_mobile = mysql_real_escape_string(htmlspecialchars($_POST['visitor_mobile'])); $visitor_newsletter = $_POST['visitor_newsletter']; // check that all fields are both filled in if ($visitor_name == '' || $visitor_email == '' || $visitor_firstline == '' || $visitor_secondline == '' || $visitor_town == '' || $visitor_county == '' || $visitor_postcode == '' || $visitor_tel == '' || $visitor_mobile == '') { // generate error message $error = 'ERROR: Please fill in all required fields!'; //error, display form renderForm($visitor_id, $visitor_name, $visitor_email, $visitor_firstline, $visitor_secondline, $visitor_town, $visitor_county, $visitor_postcode, $visitor_tel, $visitor_mobile, $visitor_newsletter, $error); } else { // save the data to the database mysql_query("UPDATE visitors SET visitor_name='$visitor_name', visitor_email='$visitor_email', visitor_firstline='$visitor_firstline', visitor_secondline='$secondline', visitor_town='$town', visitor_county='$visitor_county', visitor_postcode='$visitor_postcode', visitor_tel='$visitor_tel', visitor_mobile='$visitor_mobile', visitor_newsletter='$visitor_newsletter' WHERE visitor_id='$visitor_id'") or die(mysql_error()); // once saved, redirect back to the view page header("Location: index.php"); } } else { // if the 'id' isn't valid, display an error echo 'Error!'; } } else // if the form hasn't been submitted, get the data from the db and display the form { // get the 'id' value from the URL (if it exists), making sure that it is valid (checing that it is numeric/larger than 0) if (isset($_GET['visitor_id']) && is_numeric($_GET['visitor_id']) && $_GET['visitor_id'] > 0) { // query db $visitor_id = $_GET['visitor_id']; $result = mysql_query("SELECT * FROM visitors WHERE visitor_id=$visitor_id") or die(mysql_error()); $row = mysql_fetch_array($result); // check that the 'id' matches up with a row in the databse if($row) { // get data from db $visitor_id = $row['visitor_id']; $visitor_name = $row['visitor_name']; $visitor_email = $row['visitor_email']; $visitor_firstline = $row['visitor_firstline']; $visitor_secondline = $row['visitor_secondline']; $visitor_town = $row['visitor_town']; $visitor_county = $row['visitor_county']; $visitor_postcode = $row['visitor_postcode']; $visitor_tel = $row['visitor_tel']; $visitor_mobile = $row['visitor_mobile']; $visitor_newsletter = $row['visitor_newsletter']; // show form renderForm($visitor_id, $visitor_name, $visitor_email, $visitor_firstline, $visitor_secondline, $visitor_town, $visitor_county, $visitor_postcode, $visitor_tel, $visitor_mobile, $visitor_newsletter, ''); } else // if no match, display result { echo "No results!"; } } else // if the 'id' in the URL isn't valid, or if there is no 'id' value, display an error { echo 'Error!'; } } ?>
  13. Hi I think I have found a new way of doing the booking system using opencart I am trying to integrate the jQuery Event Calendar Plugin – english version into a opencart website, I found a extension that someone has done it but to be honest would like to know how to do it myself rather than getting the extension that is the same jquery calendar etc I have got the calendar displaying on the website but struggling to do the backend for it and integrating it into the admin side of opencart The jQuery Event Calendar Plugin – english version url is below http://www.vissit.com/jquery-event-calendar-plugin-english-version/ The link to the site I am integrating it into is below http://upyerpole.co.uk/bookingoc/index.php?route=classes/classes The extension I found is below http://www.opencart.com/index.php?route=extension/extension/info&extension_id=16530&filter_search=event%20calendar Looks exactly the same as the one I found and trying to integrate so can be done but is just finding out how to integrate it into the back end of opencart so admin can add events to it Could you please help and point me in the right direction on how to integrate it into the admin side of opencart Thank you in advance Ian
  14. ianhaney

    Booking System

    Hi I need some help or pointing in the right direction please I am using a booking script that I got off Google and works perfect but the client want's users to be able to book multiple classes at a time and then pay via PayPal in one go The current booking system I am using does not do that and just seeing if anyone could help me with it please I suppose in a way it will be bit like a shopping cart system where can add multiple products to the cart and then checkout up to now I have changed the form action to a continue page so they book a class and land on the continue page that has continue to book more classes and next to that a pay via PayPal button What I am struggling with is getting the multiple classes data stored and display all the classes selected on the continue page so they can see what classes they have selected so far and then have the option to book more or checkout and pay, in a way the continue page will be bit like a shopping cart page where it shows all the products that have been added to cart Below is the coding from the php file that allows users to choose the class time and fill out their info and book <?php session_start(); ?> <?php include "includes/dbconnect.php"; include "includes/config.php"; bw_do_action("bw_load"); $name = (!empty($_REQUEST["name"]))?strip_tags(str_replace("'","`",$_REQUEST["name"])):''; $phone = (!empty($_REQUEST["phone"]))?strip_tags(str_replace("'","`",$_REQUEST["phone"])):''; $email = (!empty($_REQUEST["email"]))?strip_tags(str_replace("'","`",$_REQUEST["email"])):''; $comments = (!empty($_REQUEST["comments"]))?strip_tags(str_replace("'","`",$_REQUEST["comments"])):''; $date = (!empty($_REQUEST["date"]))?strip_tags(str_replace("'","`",$_REQUEST["date"])):''; $captcha_sum = (!empty($_POST["captcha_sum"]))?strip_tags(str_replace("'","`",$_POST["captcha_sum"])):''; $captcha = (!empty($_POST["captcha"]))?strip_tags(str_replace("'","`",$_POST["captcha"])):''; $msg2 = (!empty($_REQUEST["msg2"]))?strip_tags(str_replace("'","`",$_REQUEST["msg2"])):''; $serviceID = (!empty($_REQUEST["serviceID"]))?strip_tags(str_replace("'","`",$_REQUEST["serviceID"])): getDefaultService(); $time = (!empty($_GET["time"]))?$_GET["time"]:''; $qty = (!empty($_REQUEST["qty"]))?strip_tags(str_replace("'","`",$_REQUEST["qty"])):1; $lb1 = (!empty($_REQUEST["lb1"]))?strip_tags(str_replace("'","`",$_REQUEST["lb1"])):''; $couponCode = (!empty($_GET["couponCode"]))?strip_tags(str_replace("'","`",$_GET["couponCode"])):''; $referrer = (!empty($_REQUEST["referrer"]))?strip_tags(str_replace("'","`",$_REQUEST["referrer"])):''; //print_r($time); $availability = getAvailableBookingsTable($date,$serviceID,$time,$qty,$couponCode); $int = getInterval($serviceID); //interval in minutes. ########################################################################################################################## # GET MAXIMUM AND MINIMUM INTERVALS FOR BOOKING AND JS VALIDATION $maximumBookings = getMaxBooking($serviceID); $minimumBookings = getMinBooking($serviceID); $bookingTexts = getBookingText($serviceID); $availebleSpaces = getServiceSettings($serviceID,'spaces_available'); $fee = getServiceSettings($serviceID,'spot_price'); ########################################################################################################################## if(!empty($lb1) && $lb1=="yes"){ $msg = "<div class='error_msg'> ".CAPTCHA_ERROR."; </div>"; } header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"'); ?> <?php include "includes/header.php";?> <?php include "includes/javascript.validation.php";?> <?php echo $msg; ?> <div class="internal_booking_form" id="resize"> <form name="ff1" enctype="multipart/form-data" method="post" action="booking.continue.php" onsubmit="return checkForm();"> <input type="hidden" value="<?php echo $date?>" name="date"> <input type="hidden" name="interval" value="<?php echo $int;?>" /> <input type="hidden" name="serviceID" value="<?php echo $serviceID;?>" /> <input type="hidden" name="discount" value="1" /> <input type="hidden" name="referrer" value="<?php echo $referrer;?>" /> <h2><?php echo _getDate(date(getOption("date_mode"),strtotime($date)))?> <?php echo AVAIL; ?></h2> <p class="desireTime"><?php echo SEL_TIME. " ". $bookingTexts[0]?> <?php echo $bookingTexts[1]?></p> <?php echo $availability?> <?php $num1 = rand(1,9); $num2 = rand(1,9); $sum = $num1 + $num2; ?> <div class="tab"><?php echo BOOKING_FORM;?></div> <div class="book_form"> <table width="650" class="booking_form"> <tr> <td align="left"> <span><?php echo YNAME;?>*: </span> <input type="text" name="name" id="name" value="<?php echo $name?>" onchange="checkFieldBack(this)"/> <span><?php echo BOOKING_FRM_PHONE;?>*: </span> <input type="text" name="phone" id="phone" value="<?php echo $phone?>" onchange="checkFieldBack(this)" onkeyup="noAlpha(this)"/> <span><?php echo BOOKING_FRM_EMAIL;?>*: </span> <input type="text" name="email" id="email" value="<?php echo $email?>" onchange="checkFieldBack(this);"/> </td> <td align="left" style="padding-left:10px"> <span><?php echo BOOKING_FRM_COMMENTS;?>: </span> <textarea name="comments" id="comments" cols="15" rows="5" onchange="checkFieldBack(this)"><?php echo $comments?></textarea> <div class="captchaCont"> <span><?php echo $num1." + ".$num2." = "?></span> <input type="text" name="captcha" id="captcha" value="" onchange="checkFieldBack(this);"/> </div><input type="image" src="images/reserve_btn.jpg" style="margin-top: 28px;" /> <input type="hidden" name="captcha_sum" value="<?php echo md5($sum);?>" /> <input type="text" name="email1" value="" class="hi"> </td> </tr> </table> </div> </form> <script> jQuery(function(){ jQuery("#qty").spinner({min:1,max:<?php echo ($availebleSpaces)?>}); }) </script> <?php include "includes/footer.php";?> Below is the coding on the continue page where they can either choose to book more classes or checkout and pay for the classes booked - this is the page I am struggling with as each time I book a second class, the first one selected gets overwritten, think someone said its cause the date is the same name and they said to try arrays but not 100% on that to be honest <?php ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); ?> <?php session_start(); require_once("includes/config.php"); //Load the configurations bw_do_action("bw_load"); ################################################################################## # 1. GET ALL VARIABLES $name = (!empty($_POST["name"])) ? strip_tags(str_replace("'", "`", $_POST["name"])) : ''; $phone = (!empty($_POST["phone"])) ? strip_tags(str_replace("'", "`", $_POST["phone"])) : ''; $email = (!empty($_POST["email"])) ? strip_tags(str_replace("'", "`", $_POST["email"])) : ''; $email1 = (!empty($_POST["email1"])) ? strip_tags(str_replace("'", "`", $_POST["email1"])) : ''; $comments = (!empty($_POST["comments"])) ? strip_tags(str_replace("'", "`", $_POST["comments"])) : ''; $date = (!empty($_POST["date"])) ? strip_tags(str_replace("'", "`", $_POST["date"])) : ''; $interval = (!empty($_POST["interval"])) ? strip_tags(str_replace("'", "`", $_POST["interval"])) : ''; $time = (!empty($_POST["time"])) ? $_POST["time"] : ''; $captcha_sum = (!empty($_POST["captcha_sum"])) ? strip_tags(str_replace("'", "`", $_POST["captcha_sum"])) : ''; $captcha = (!empty($_POST["captcha"])) ? strip_tags(str_replace("'", "`", $_POST["captcha"])) : ''; $serviceID = (!empty($_REQUEST["serviceID"])) ? strip_tags(str_replace("'", "`", $_REQUEST["serviceID"])) : getDefaultService();; $qty = (!empty($_REQUEST["qty"])) ? intval($_REQUEST["qty"]) : 1; $couponCode = (!empty($_POST["couponCode"])) ? strip_tags(str_replace("'", "`", $_POST["couponCode"])) : ''; $referrer = (!empty($_REQUEST["referrer"]))?strip_tags(str_replace("'","`",$_REQUEST["referrer"])):''; // captcha check if (empty($captcha_sum) || empty($captcha) || md5($captcha) != $captcha_sum || !empty($email1)) { $queryString = array( "date" => $date, "lb1" => "yes", "serviceID" => $serviceID, "name" => $name, "phone" => $phone, "email" => $email, "comments" => $comments, "time" => $time, "qty" => $qty, "couponCode" => $couponCode, "referrer"=>$referrer ); $timeURL = http_build_query($time); if (getOption('use_popup') && $referrer!='calendar') { header("Location: index.php?" . http_build_query($queryString)); } else { header("Location: booking.php?" . http_build_query($queryString)); } exit(); } ## Check Qty allowed $error = checkQtyForTimeBooking($serviceID, $time, $date, $interval, $qty); if (!$error) { if (!empty($name) && !empty($phone) && !empty($email)) { if (!preg_match("(^[-\w\.]+@([-a-z0-9]+\.)+[a-z]{2,4}$)i", $email)) { $msg = "<div class='error_msg'>" . BEP_10 . "</div>"; } else { if (!empty($couponCode)) { $couponData = checkCoupon($couponCode, $serviceID); if ($couponData['responce']) { $couponValue = $couponData['value']; $couponType = $couponData['type']; } else { $msg = "<div class='error_msg'>" . $couponData['message'] . "</div>"; $couponCode = ''; } } ################################################################################## # 3. PREPARE BOOKING DATE/TIME # CREATE ORDER $price_per_spot = getPricePerSpot($serviceID); $status = getServiceSettings($serviceID, 'payment_method') == 'invoice' ? 1 : 2; $orderID = mysql_insert_id(); $serviceName = getService($serviceID, 'name'); if (!empty($orderID)) { $tempVar = ""; $bookingData = array(); $spots = 0; foreach ($time as $k => $v) { $dateFrom = date("Y-m-d H:i:s", strtotime($date . " +" . $v . " minutes")); $dateTo = date("Y-m-d H:i:s", strtotime($dateFrom . " +" . $interval . " minutes")); $res = mysql_query($q) or die("error! 002"); //needed for message $tempVar .= "<tr><td>" . getDateFormat($date) . "</td><td>" . date((getTimeMode()) ? "g:i a" : "H:i", strtotime($dateFrom)) . "</td><td>" . date((getTimeMode()) ? "g:i a" : "H:i", strtotime($dateTo)) . "</td><td>" . $qty . "</td></tr>"; $bookingData[] = array( 'date' => getDateFormat($date), 'timeFrom' => date((getTimeMode()) ? "g:i a" : "H:i", strtotime($dateFrom)), 'timeTo' => date((getTimeMode()) ? "g:i a" : "H:i", strtotime($dateTo)), 'qty' => $qty, 'dateFrom'=>$dateFrom, 'dateTo'=>$dateTo ); $spots++; } $paymentBookingIngo = get_payment_info($orderID); if ($price_per_spot == 0 || $paymentBookingIngo['amount']==0) { $infoForBooking = BEP_11; $subject = BEP_161 . " (#" . $orderID . ")!"; } else { $subject = BEP_16 . " (#" . $orderID . ")!"; $infoForBooking = do_payment($orderID, getServiceSettings($serviceID, "payment_method"),null,$referrer); } } } } } ?> <?php include "includes/header.php"?> <div id="index"> <h1><?php echo BEP_20;?></h1> <?php echo $msg;?> <?php echo !$error?getOrderSummery($orderID):"";?> <?php echo $infoForBooking?> <?php echo "<div class='more-button'>"; echo "<a href=\"http://". MAIN_URL."index.php?serviceID={$serviceID}\">".BEP_21."</a>"; echo "</div>"; ?> <?php include "includes/footer.php"?> Thank you in advance, would really appreciate any help or point me in the right direction, I know most of the coding on the continue page can come off as I copied the booking processing php coding Ian
  15. Hi I have got it sort of working, it is saving the values in the database but is not editing them when I change it from yes to no, is it ok if my code is checked over by someone please as can't see the issue, my code for the edit-customer.php is below, I think it is to do with the line below but not 100% $introemail = (int)$_POST['introemail']; <?php ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); ?> <?php /* Allows the user to both create new records and edit existing records */ // connect to the database include("connect-db.php"); ?> <?php $title = "Edit Customer"; include ( 'includes/header.php' ); ?> <?php // creates the new/edit record form // since this form is used multiple times in this file, I have made it a function that is easily reusable function renderForm($name = '', $company = '', $officenumber = '', $mobilenumber = '', $website = '', $email = '', $addressline1 = '', $addressline2 = '', $town = '', $county = '', $postcode = '', $notes = '', $customertype = '', $businesscategory = '', $introemail = '', $error = '', $id = '') { ?> <body> <h1>Edit Customer</h1> <?php if ($error != '') { echo "<div style='padding:4px; border:1px solid red; color:red'>" . $error . "</div>"; } ?> <form action="" method="post"> <div class="left-side"> <?php if ($id != '') { ?> <input type="hidden" name="id" value="<?php echo $id; ?>" /> <p>ID: <?php echo $id; ?></p> <?php } ?> <strong>Name: *</strong> <input type="text" name="name" value="<?php echo $name; ?>"/> <br/> <strong>Company: *</strong> <input type="text" name="company" value="<?php echo $company; ?>"/> <br> <strong>Office Number: *</strong> <input type="text" name="officenumber" value="<?php echo $officenumber; ?>"/> <br> <strong>Mobile Number:</strong> <input type="text" name="mobilenumber" value="<?php echo $mobilenumber; ?>"/> <br> <strong>Website: *</strong> <input type="text" name="website" value="<?php echo $website; ?>"/> <br> <strong>Email: *</strong> <input type="text" name="email" value="<?php echo $email; ?>"/> </div> <div class="right-side"> <strong>Address Line 1: *</strong> <input type="text" name="addressline1" value="<?php echo $addressline1; ?>"/> <br> <strong>Address Line 2:</strong> <input type="text" name="addressline2" value="<?php echo $addressline2; ?>"/> <br> <strong>Town: *</strong> <input type="text" name="town" value="<?php echo $town; ?>"/> <br> <strong>County: *</strong> <input type="text" name="county" value="<?php echo $county; ?>"/> <br> <strong>Postcode: *</strong> <input type="text" name="postcode" value="<?php echo $postcode; ?>"/> <br> <strong>Notes:</strong> <br> <textarea type="text" name="notes" value="<?php echo $notes; ?>"/><?php echo $notes; ?></textarea> </div> <div class="far-right-side"> <strong>Customer Type: *</strong> <input type="text" name="customertype" value="<?php echo $customertype; ?>"/> <br> <strong>Business Category:</strong> <input type="text" name="businesscategory" value="<?php echo $businesscategory; ?>"/> <br> <strong>Intro Email Sent:</strong> <label style="color: #000000;">Yes<input type="radio" name="introemail" value="1" <?php if($introemail == 1) echo 'checked="checked"'; ?> ></label> <br> <label style="color: #000000;">No<input type="radio" name="introemail" value="0"<?php if($introemail == 0) echo 'checked="checked"'; ?> ></label> <p>* required</p> <input type="submit" name="submit" value="Save Changes" /> </div> </form> <?php include( 'includes/footer.php' ); ?> <?php } /* EDIT RECORD */ // if the 'id' variable is set in the URL, we know that we need to edit a record if (isset($_GET['id'])) { // if the form's submit button is clicked, we need to process the form if (isset($_POST['submit'])) { // make sure the 'id' in the URL is valid if (is_numeric($_POST['id'])) { // get variables from the URL/form $id = $_POST['id']; $name = htmlentities($_POST['name'], ENT_QUOTES); $company = htmlentities($_POST['company'], ENT_QUOTES); $officenumber = htmlentities($_POST['officenumber'], ENT_QUOTES); $mobilenumber = htmlentities($_POST['mobilenumber'], ENT_QUOTES); $website = htmlentities($_POST['website'], ENT_QUOTES); $email = htmlentities($_POST['email'], ENT_QUOTES); $addressline1 = htmlentities($_POST['addressline1'], ENT_QUOTES); $addressline2 = htmlentities($_POST['addressline2'], ENT_QUOTES); $town = htmlentities($_POST['town'], ENT_QUOTES); $county = htmlentities($_POST['county'], ENT_QUOTES); $postcode = htmlentities($_POST['postcode'], ENT_QUOTES); $notes = htmlentities($_POST['notes'], ENT_QUOTES); $customertype = htmlentities($_POST['customertype'], ENT_QUOTES); $businesscategory = htmlentities($_POST['businesscategory'], ENT_QUOTES); $introemail = (int)$_POST['introemail']; // check that firstname and lastname are both not empty if ($name == '' || $company == '' || $officenumber == '' || $website == '' || $email == '' || $addressline1 == '' || $town == '' || $county == '' || $postcode == '' || $notes == '' || $customertype == '') { // if they are empty, show an error message and display the form $error = 'ERROR: Please fill in all required fields!'; renderForm($name, $company, $officenumber, $mobilenumber, $website, $email, $addressline1, $addressline2, $town, $county, $postcode, $notes, $customertype, $businesscategory, $introemail, $error, $id); } else { // if everything is fine, update the record in the database if ($stmt = $mysqli->prepare("UPDATE customers SET name = ?, company = ?, officenumber = ?, mobilenumber = ?, website = ?, email = ?, addressline1 = ?, addressline2 = ?, town = ?, county = ?, postcode = ?, notes = ?, customertype = ?, businesscategory = ? introemail = ? WHERE id=?")) { $stmt->bind_param("sssssssssssssssi", $name, $company, $officenumber, $mobilenumber, $website, $email, $addressline1, $addressline2, $town, $county, $postcode, $notes, $customertype, $businesscategory, $introemail, $id); $stmt->execute(); $stmt->close(); } // show an error message if the query has an error else { echo "ERROR: could not prepare SQL statement."; } // redirect the user once the form is updated header("Location: view-paginated.php"); } } // if the 'id' variable is not valid, show an error message else { echo "Error!"; } } // if the form hasn't been submitted yet, get the info from the database and show the form else { // make sure the 'id' value is valid if (is_numeric($_GET['id']) && $_GET['id'] > 0) { // get 'id' from URL $id = $_GET['id']; // get the recod from the database if($stmt = $mysqli->prepare("SELECT * FROM customers WHERE id=?")) { $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($id, $name, $company, $officenumber, $mobilenumber, $website, $email, $addressline1, $addressline2, $town, $county, $postcode, $notes, $customertype, $businesscategory, $introemail); $stmt->fetch(); // show the form renderForm($name, $company, $officenumber, $mobilenumber, $website, $email, $addressline1, $addressline2, $town, $county, $postcode, $notes, $customertype, $businesscategory, $introemail, NULL, $id); $stmt->close(); } // show an error if the query has an error else { echo "Error: could not prepare SQL statement"; } } // if the 'id' value is not valid, redirect the user back to the view.php page else { header("Location: view-paginated.php"); } } } // if the form hasn't been submitted yet, show the form else { renderForm(); } // close the mysqli connection $mysqli->close(); ?>
  16. Hi I was just wondering how would I make two radio buttons in the add record form, one will be yes and the other will be no and need when either one clicked to save in the database, was just wondering how to set up the database to store the radio button values and what the PHP would look like I did similar for another site but was in MySQL not MySQLi Thank you in advance Ian
  17. ianhaney

    Php Link

    Hi Ben Thank you for the reply Yeah I soon thought after of doing it the way you mentioned echo '<td><a href="' . $row[5] . '" target="_blank">' . $row[5] . '</a></td>';
  18. ianhaney

    Php Link

    Hi I am making a script using the following http://www.killersites.com/community/index.php?/topic/3064-basic-php-system-view-edit-add-delete-records-with-mysqli/ all works perfect, just got one little issue, on the view-paginated.php page I am trying to make a website a link that opens in a new tab The line of code is below echo '<td>' . $row[5] . '</a></td>'; How would I make that a link as tried a few things and don't seem to work
  19. Hi] Is this still active as got the following error on my records.php page Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in /home/sites/irhwebsites.com/public_html/irhwebsites-crm/records.php on line 129 I have seen others had it and have corrected the coding but still got the error on line 129 is the following $stmt->bind_result($id, $firstname, $lastname, $company); I got the correct number of strings in the following coding $stmt->bind_param("sssi", $firstname, $lastname, $company, $id); and for the insert part of the coding $stmt->bind_param("sss", $firstname, $lastname, $company); Would it help if I posted all the records.php code Any help would be great as can't work it out, it works if it is just firstname and lastname but trying to add a new one at a time Thank you in advance
  20. Hi I am using a add/view/edit and delete tutorial on here and for some reason the new.php does not add all the data to the mysql database It only adds the ref and role fields data and nothing else would any one know or shall I paste the coding in pastebin and put the link here to have a look at as can't work it out Thank you in advance Ian
  21. Hi I am using this coding in one of my sites and was working and has not stopped working Im getting the following errors on the new.php page Warning: Missing argument 4 for renderForm(), called in /home/sites/irhwebsites.com/public_html/sites/sgr/admin/new.php on line 101 and defined in /home/sites/irhwebsites.com/public_html/sites/sgr/admin/new.php on line 14 Warning: Missing argument 5 for renderForm(), called in /home/sites/irhwebsites.com/public_html/sites/sgr/admin/new.php on line 101 and defined in /home/sites/irhwebsites.com/public_html/sites/sgr/admin/new.php on line 14 Warning: Missing argument 6 for renderForm(), called in /home/sites/irhwebsites.com/public_html/sites/sgr/admin/new.php on line 101 and defined in /home/sites/irhwebsites.com/public_html/sites/sgr/admin/new.php on line 14 Warning: Missing argument 7 for renderForm(), called in /home/sites/irhwebsites.com/public_html/sites/sgr/admin/new.php on line 101 and defined in /home/sites/irhwebsites.com/public_html/sites/sgr/admin/new.php on line 14 Warning: Missing argument 8 for renderForm(), called in /home/sites/irhwebsites.com/public_html/sites/sgr/admin/new.php on line 101 and defined in /home/sites/irhwebsites.com/public_html/sites/sgr/admin/new.php on line 14 Warning: Missing argument 9 for renderForm(), called in /home/sites/irhwebsites.com/public_html/sites/sgr/admin/new.php on line 101 and defined in /home/sites/irhwebsites.com/public_html/sites/sgr/admin/new.php on line 14 Notice: Undefined variable: error in /home/sites/irhwebsites.com/public_html/sites/sgr/admin/new.php on line 29 The view.php page is not reading any of the records for some reason apart from the headings The new.php is not inserting any data apart from the id, ref and role data and nothing else Please help Ian
×
×
  • Create New...