Jump to content

Moorcam

Members
  • Posts

    189
  • Joined

  • Last visited

Everything posted by Moorcam

  1. Hi folks, Getting the following error in Console when submitting data to MySQL via Bootstrap Modal: VM6553:1 Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) at Object.success (tickets.php:391) at j (datatables.min.js:14) at Object.fireWith [as resolveWith] (datatables.min.js:14) at x (datatables.min.js:17) at XMLHttpRequest.b (datatables.min.js:17) Here is my JS <script> $(document).ready(function() { // add $(document).on("click", "#submit", function() { var title = $('#title').val(); var body = $('#body').val(); $.ajax({ url: "includes/add-ticket.php", type: "POST", catch: false, data: { added: 1, title: title, body: body }, success: function(dataResult) { var dataResult = JSON.parse(dataResult); if (dataResult.status == 1) { $('#add_ticket').modal().hide(); swal("Ticket Submitted", { icon: "success", }).then((result) => { location.reload(); }); } } }); }); }); </script> Data is being submitted but the modal doesn't close after submit and the above error shows in Console. Can anyone help with this? Google doesn't want to help. Cheers
  2. I have never tried it myself to be honest but here is a useful article that may help you: https://www.plus2net.com/php_tutorial/whois-online.php
  3. Have you tried with a Modal or JS alert? Probably use a Session or Cookie to determine who is online?
  4. I see. Oh well. Not a biggie. Just wanted it displayed in the booking table on the site so end user can see which tour was booked. Thanks as always for your help. Always appreciated.
  5. Working now. I am getting the ID now into the tour_id but also into the tour_name field. I need tour_name to go into tour_name. if(isset($_POST['new']) && $_POST['new']==1){ $tour_id = mysqli_real_escape_string($con, $_POST['tour_name']); $tour_name = mysqli_real_escape_string($con, $_POST['tour_name']); $customer_name = mysqli_real_escape_string($con, $_POST['customer_name']); $customer_address = mysqli_real_escape_string($con, $_POST['customer_address']); $customer_email = mysqli_real_escape_string($con, $_POST['customer_email']); $customer_phone = mysqli_real_escape_string($con, $_POST['customer_phone']); $total_pax = mysqli_real_escape_string($con, $_POST['total_pax']); $status = mysqli_real_escape_string($con, $_POST['status']); $order_at = mysqli_real_escape_string($con, date("Y-m-d H:i:s")); $total_amount = mysqli_real_escape_string($con, $_POST['total_amount']); $query="insert into bookings (`tour_id`, `tour_name`, `customer_name`, `customer_address`, `customer_email`, `customer_phone`, `total_pax`, `status`, `order_at`, `total_amount`)values ('$tour_id', '$tour_name', '$customer_name', '$customer_address', '$customer_email', '$customer_phone', '$total_pax', '$status', '$order_at', '$total_amount')"; mysqli_query($con,$query) or die(mysqli_error($con)); if(mysqli_affected_rows($con)== 1 ){ $message = '<p class="text-success"><i class="fa fa-check"></i> - Record Inserted Successfully</p>'; } }
  6. I call it Irish Brain Syndrome. Here is the fill add-booking.php <?php include_once('includes/header.php'); if(isset($_POST['new']) && $_POST['new']==1){ $sql = "SELECT id FROM jobs"; $result = $con->query($sql); while(list($id) = mysqli_fetch_row($result)){ } $tour_id = isset($_GET['id']) ? $_GET['id'] : ''; $tour_name = mysqli_real_escape_string($con, $_POST['tour_name']); $customer_name = mysqli_real_escape_string($con, $_POST['customer_name']); $customer_address = mysqli_real_escape_string($con, $_POST['customer_address']); $customer_email = mysqli_real_escape_string($con, $_POST['customer_email']); $customer_phone = mysqli_real_escape_string($con, $_POST['customer_phone']); $total_pax = mysqli_real_escape_string($con, $_POST['total_pax']); $status = mysqli_real_escape_string($con, $_POST['status']); $order_at = mysqli_real_escape_string($con, date("Y-m-d H:i:s")); $total_amount = mysqli_real_escape_string($con, $_POST['total_amount']); $query="insert into bookings (`tour_id`, `tour_name`, `customer_name`, `customer_address`, `customer_email`, `customer_phone`, `total_pax`, `status`, `order_at`, `total_amount`)values ('$tour_id', '$tour_name', '$customer_name', '$customer_address', '$customer_email', '$customer_phone', '$total_pax', '$status', '$order_at', '$total_amount')"; mysqli_query($con,$query) or die(mysqli_error($con)); if(mysqli_affected_rows($con)== 1 ){ $message = '<p class="text-success"><i class="fa fa-check"></i> - Record Inserted Successfully</p>'; } } ?> <!-- Header--> <div class="breadcrumbs"> <div class="col-sm-4"> <div class="page-header float-left"> <div class="page-title"> <h1>Bookings</h1> </div> </div> </div> <div class="col-sm-8"> </div> </div> <div class="content mt-3"> <div class="animated fadeIn"> <div class="row"> <div class="col-lg-12"> <div class="card"> <div class="card-header"><strong>Add </strong><small>Booking <?php if($message = isset($message) ? $message : ''){ printf($message); } ?></small></div> <div class="card-body card-block"> <form role="form" method="post" name="add_tour" id="add_tour" action"" > <input type="hidden" name="new" value="1" /> <div class="modal-body"> <div class="row form-group"> <div class="col-6"> <div class="form-group"><label for="customer_name" class=" form-control-label">Customer Name</label><input type="text" id="customer_name" name="customer_name" placeholder="Customer Name" class="form-control"> </div> </div> <div class="col-6"> <div class="form-group"><label for="customer_address" class=" form-control-label">Customer Address</label> <input type="text" class="form-control" id="customer_address" name="customer_address" placeholder="Customer's Address" > </div> </div> </div> <div class="row form-group"> <div class="col-6"> <div class="form-group"><label for="total_pax" class=" form-control-label">Pax</label> <input type="text" id="total_pax" name="total_pax" placeholder="How many passengers?" class="form-control"> </div> </div> <div class="col-6"> <div class="form-group"><label for="total_amount" class=" form-control-label">Price</label><input type="text" id="total_amount" name="total_amount" placeholder="0.00" class="form-control"> </div> </div> </div> <div class="row form-group"> <div class="col-6"> <div class="form-group origin" ><label for="customer_email" class=" form-control-label">Customer Email</label><input type="email" id="customer_email" name="customer_email" placeholder="Customer Email" class="form-control"></div> </div> <div class="col-6"> <div class="form-group"><label for="customer_phone" class=" form-control-label">Customer Phone</label><input type="phone" id="customer_phone" name="customer_phone" placeholder="Customer Phone" class="form-control"></div> </div> </div> <div class="row form-group"> <div class="col-6"> <div class="form-group origin" ><label for="status" class=" form-control-label">Payment Status</label> <select class="form-control" id="status" name="status"> <option value =""> == Choose One ==</option> <option value="PAID">PAID</option> <option value="UNPAID">UNPAID</option> </select> </div> </div> <div class="col-6"> <div class="form-group"><label for="tour_name" class=" form-control-label">Tour or Charter</label> <select class="form-control" id="tour_name" name="tour_name"> <option value="Select">== Select Tour or Charter ==</option> <?php $sql = "SELECT name, id FROM jobs"; $result = $con->query($sql); while(list($id, $name) = mysqli_fetch_row($result)){ ?> <option value="<?php echo $id ?>"><?php echo $name;?></option> <?php } ?> </select> </div> </div> </div> <div class="modal-footer"> <button type="reset" class="btn btn-warning">Clear Form</button> <button type="submit" name="submit" id="submit" class="btn btn-primary">Confirm</button> </div> </form> </div> </div> </div><!-- .animated --> </div><!-- .content --> </div><!-- /#right-panel --> <!-- Right Panel --> <script src="assets/js/vendor/jquery-2.1.4.min.js"></script> <script src="assets/js/popper.min.js"></script> <script src="assets/js/plugins.js"></script> <script src="assets/js/main.js"></script> <script src="assets/js/bing.js"></script> <script src="assets/js/lib/data-table/datatables.min.js"></script> <script src="assets/js/lib/data-table/dataTables.bootstrap.min.js"></script> <script src="assets/js/lib/data-table/dataTables.buttons.min.js"></script> <script src="assets/js/lib/data-table/buttons.bootstrap.min.js"></script> <script src="assets/js/lib/data-table/jszip.min.js"></script> <script src="assets/js/lib/data-table/pdfmake.min.js"></script> <script src="assets/js/lib/data-table/vfs_fonts.js"></script> <script src="assets/js/lib/data-table/buttons.html5.min.js"></script> <script src="assets/js/lib/data-table/buttons.print.min.js"></script> <script src="assets/js/lib/data-table/buttons.colVis.min.js"></script> <script src="assets/js/lib/data-table/datatables-init.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <script src="https://cdn.tiny.cloud/1/sw6bkvhzd3ev4xl3u9yx3tzrux4nthssiwgsog74altv1o65/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script> </body> </html>
  7. Ah I see. Tried that. Getting undefined variable id in the <option value part: <?php $sql = "SELECT id, name FROM jobs"; $result = $con->query($sql); while(list($name) = mysqli_fetch_row($result)){ ?> <option value="<?php echo $id ?>"><?php echo $name;?></option> <?php } ?> I appreciate your help.
  8. Hi mate That is fine but the issue is, if an end user, such as a non-techy type person, was to create a booking from the backend, selecting an ID will make no sense to them. They will need to see the name of the job they are booking onto.
  9. Hi guys, I am trying to get data from the table "jobs" and insert its id and name into table "bookings" I can get the job "name" from "jobs", which is fine, using the following: <select class="form-control" id="tour_name" name="tour_name"> <option value="Select">== Select Tour or Charter ==</option> <?php $sql = "SELECT name FROM jobs"; $result = $con->query($sql); while(list($name) = mysqli_fetch_row($result)){ ?> <option value="<?php echo $name ?>"><?php echo $name;?></option> <?php } ?> </select> However, when I click submit to insert into "bookings" everything goes in except "booking_id" which is "id" in "jobs". Hope this makes sense. I am using the following to insert: if(isset($_POST['new']) && $_POST['new']==1){ $sql = "SELECT id FROM jobs"; $result = $con->query($sql); while(list($id) = mysqli_fetch_row($result)){ } $tour_id = isset($_GET['id']) ? $_GET['id'] : ''; $tour_name = mysqli_real_escape_string($con, $_POST['tour_name']); $customer_name = mysqli_real_escape_string($con, $_POST['customer_name']); $customer_address = mysqli_real_escape_string($con, $_POST['customer_address']); $customer_email = mysqli_real_escape_string($con, $_POST['customer_email']); $customer_phone = mysqli_real_escape_string($con, $_POST['customer_phone']); $total_pax = mysqli_real_escape_string($con, $_POST['total_pax']); $status = mysqli_real_escape_string($con, $_POST['status']); $order_at = mysqli_real_escape_string($con, date("Y-m-d H:i:s")); $total_amount = mysqli_real_escape_string($con, $_POST['total_amount']); $query="insert into bookings (`tour_id`, `tour_name`, `customer_name`, `customer_address`, `customer_email`, `customer_phone`, `total_pax`, `status`, `order_at`, `total_amount`)values ('$tour_id', '$tour_name', '$customer_name', '$customer_address', '$customer_email', '$customer_phone', '$total_pax', '$status', '$order_at', '$total_amount')"; mysqli_query($con,$query) or die(mysqli_error($con)); if(mysqli_affected_rows($con)== 1 ){ $message = '<p class="text-success"><i class="fa fa-check"></i> - Record Inserted Successfully</p>'; } } Can anyone please lend a hand with this? 2 Days at it now and ready to hit the Guinness. Cheers, Dan
  10. Hey kicken, Thanks for the reply. I did that and now get this: PHP Parse error: syntax error, unexpected 'if' (T_IF), expecting function (T_FUNCTION) or const (T_CONST) Thanks for your help.
  11. Hi guys, I am trying to calculate hours a person works by calculating the values of text fields in a form. However, when I load the page I get "Class 'times_counter' not found. Here is the calculation code" if(isset($_POST['calculate']) != ""){ class times_counter { private $hou = 0; private $min = 0; private $sec = 0; private $totaltime = '00:00:00'; public function __construct($times){ if(is_array($times)){ $length = sizeof($times); for($x=0; $x <= $length; $x++){ $split = explode(":", @$times[$x]); $this->hou += @$split[0]; $this->min += @$split[1]; $this->sec += @$split[2]; } $seconds = $this->sec % 60; $minutes = $this->sec / 60; $minutes = (integer)$minutes; $minutes += $this->min; $hours = $minutes / 60; $minutes = $minutes % 60; $hours = (integer)$hours; $hours += $this->hou % 24; $this->totaltime = $hours.":".$minutes; } } public function get_total_time(){ return $this->totaltime; } } $times = array( $mondiff->format('%H:%I'), $tudiff->format('%H:%I'), $weddiff->format('%H:%I'), $thdiff->format('%H:%I'), $fridiff->format('%H:%I'), $satdiff->format('%H:%I'), $sundiff->format('%H:%I'), ); $counter = new times_counter($times); I had this on an old project, which I no longer have but it worked then. Any ideas?
  12. Got is working <?php require_once "config.php"; $json = array(); $sqlQuery = "SELECT id, name AS title, dep_date AS start, ret_date AS end FROM jobs ORDER BY id"; $result = mysqli_query($con, $sqlQuery); $eventArray = array(); while ($row = mysqli_fetch_assoc($result)) { array_push($eventArray, $row); } mysqli_free_result($result); mysqli_close($con); echo json_encode($eventArray); ?> Thank you both so much for your help. Love your work.
  13. Hi mate, Did a Var dump (I think) and this is what it showed: object(mysqli_result)#2 (5) { ["current_field"]=> int(0) ["field_count"]=> int(1) ["lengths"]=> array(1) { [0]=> int(1) } ["num_rows"]=> int(1) ["type"]=> int(0) }
  14. Hi mate, Nothing in console. Just a few things with datatables, which I am aware of. Is there an alternative calendar script that I can use that you would recommend? Thanks for your help.
  15. I have changed that now. All I want to do is display the name, start date and finish date in the calendar. $data = array(); $query = "SELECT * FROM tours ORDER BY id"; $statement = $con->prepare($query); $statement->execute(); $result = $statement->fetchAll(); foreach ($result as $row) { $data[] = array( 'id' => $row["id"], 'title' => $row["name"], 'start' => $row["dep_date"], 'end' => $row['ret_date'] ); } echo json_encode($data); I have never used calendars before and am clueless with Javascript etc so any help with this would be appreciated.
  16. Hi guys, I am trying to display tour information in fullcalendar but nothing is happening and no errors. Here is the php code from fetch-tours.php <?php require_once "config.php"; $json = array(); $sqlQuery = "SELECT * FROM jobs ORDER BY id"; $result = mysqli_query($con, $sqlQuery); $eventArray = array(); while ($row = mysqli_fetch_assoc($result)) { $title = isset($row['name']); $start = isset($row['dep_date']); $end = isset($row['ret_date']); $eventsArray['title'] = $title; $eventsArray['start'] = $start; $eventsArray['end'] = $end; array_push($eventArray, $row); } mysqli_free_result($result); mysqli_close($con); echo json_encode($eventArray); ?> And here is the Javascript that displays the calendar: <script type="text/javascript"> $(document).ready(function() { var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); $('#calendar').fullCalendar( { header: { left: 'prev,next today', center: 'title', right: 'month,basicWeek,basicDay' }, editable :true, events: "includes/fetch-tours.php", }); }) </script> The calendar displays fine but just no data. Any help is greatly appreciated. Cheers, Dan
  17. Hello guys, Been a while. Between travelling half the bloody country, being sick and travelling again (work), I finally got time to sit down and look into this issue. Got it to work by using the following array in my php code: $res[] = array("value"=>$row['location_phone'],"label"=>$row['location_name']); My next goal is to make you guys so proud. 😂 Yes, I am going to use my upcoming leave from work to change all my code to prepared. Thanks so much for all your help and advice thus far. I had to reread what you said about using the ajax plugin to set the phone number to a text box upon selection of location name. Thanks so much for this. Dan
  18. LOL I know right. I will, I promise. Some day you will be proud. lol I will look into the other stuff. Thanks mate.
  19. Hi guys, Back to annoy you again. Sorry I am getting information from the Database to textbox1 (location_name), which uses an autocomplete. This works lovely. Now, what I want to do is, in textbox2 (location_phone) is have the phone number associated with the value of textbox1 to show in textbox2 automagically. Here is the HTML of both fields: <div class="row form-group"> <div class="col-6"> <div class="form-group"><label for="location" class=" form-control-label">location</label> <input type="text" id="location" name="location" value="<?php echo $row['location']; ?>" class="form-control"> </div> </div> <div class="col-6"> <div class="form-group"><label for="price" class=" form-control-label">Location Phone</label><input type="text" id="location_phone" name="location_phone" value="<?php echo $row['location_phone']; ?>" class="form-control"></div> </div> </div> Here is the php in autocomplete.php: <?php include('config.php'); if (isset($_GET['term'])) { $query = "SELECT * FROM locations WHERE location_name LIKE '{$_GET['term']}%' LIMIT 25"; $result = mysqli_query($con, $query); if (mysqli_num_rows($result) > 0) { while ($row = mysqli_fetch_array($result)) { $res[] = $row['location_name']; } } else { $res = array(); } //return json res echo json_encode($res); } And, finally, the Austocomplete script, which helps to populate textbox1: $(function() { $( "#location" ).autocomplete({ source: 'includes/autocomplete.php', }); }); If anyone can help put this one to bed I would be so grateful and will buy you a Guinness sometime Cheers.
  20. <input type="text" class="searchTerm" placeholder="What are you looking for?"> <button type="submit" class="searchButton"> <i class="fa fa-search"></i> </button> You need Font Awesome. If you have it, try the above. https://fontawesome.com/icons?d=gallery&p=2
  21. Thanks mate. Still wasn't working for me. So, gave in and reverted back to good old text boxes.
  22. Cross-Origin Read Blocking (CORB), an algorithm by which dubious cross-origin resource loads may be identified and blocked by web browsers before they reach the web page..It is designed to prevent the browser from delivering certain cross-origin network responses to a web page.
  23. Hi requinix, Thanks for the reply. When I add location_id to the query I only get the id number in the dropdown. <?php $sql = "SELECT DISTINCT location_id, location_name, location_phone FROM locations"; $result = $con->query($sql); ?> <select name="location" id="location" onchange="myFunction()" class="form-control"> <?php while($r = mysqli_fetch_row($result)) { echo "<option data-location_name='$r[1]' data-location_phone='$r[2]' value='$r[0]' selected> $r[0] </option>"; } ?> Sorry mate. Struggling with this one.
×
×
  • 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.