Jump to content

SF23103

Members
  • Content count

    97
  • Joined

  • Last visited

Community Reputation

0 Neutral

About SF23103

  • Rank
    Regular Member

Profile Information

  • Gender
    Not Telling
  1. SF23103

    Add descriptor text to output in certain places

    Working great, thank you!!!
  2. Hello, I'm trying to deal with a not-so-friendly API. Instead of XML or JSON, it outputs content in html. Here is an example: ===================================================<br/> 10:05 some text here 1789210011<br/> ===================================================<br/> I have used str_replace to change the "======" line to a horizontal line, which worked great. What I would like to do is add "Time:" before the displayed time, "Description:" before the 'some text here', and "ID Number:" before the 10 digit number. Fortunately the output is formatted consistently, but is there a way to add what I want before and after all "##:##" and before the 10 digit number? Of course it would be so much easier if this was XML, but it's not, and I have no control over what's being pushed to me. grrrrrr
  3. SF23103

    XML Date Conversion

    Hello, I am getting some data from an XML source and it includes a date and time in the format: <DATE>2017-09-01T00:00:00-07:00</DATE> <TIME>00:19:43</TIME> My question is how to format that date style. Do I need to split it up somehow first in order to format it? The code I figured would work (but doesn't) was: date_format($inc->DATE, 'Y-m-d H:i:s'); Thanks for your help!
  4. SF23103

    Toggling three divs

    Got it figured out! https://jsfiddle.net/8u1wxw01/1/
  5. SF23103

    Toggling three divs

    What I'm doing: I have three DIVs, each of them acting as a button to swap one div with different content. [bOX_1] [bOX_2] [bOX_3] [--------BOX_4------------] For instance: If you click BOX_1, it swaps BOX_4 out with BOX_1_CONTENT & (Clicking BOX_1 again returns it to BOX_4) If you click BOX_2, it swaps BOX_4 out with BOX_2_CONTENT & (Clicking BOX_2 again returns it to BOX_4) If you click BOX_3, it swaps BOX_4 out with BOX_3_CONTENT & (Clicking BOX_3 again returns it to BOX_4) BOX_1_CONTENT, BOX_2_CONTENT, and BOX_3_CONTENT are all set to display:none; and appear after clicking. What Works: It works great if you are only toggling back and forth (i.e. toggling content by clicking the BOX_1 back and forth). My problem: I am having trouble dealing with Clicking BOX_1 and then before toggling back, clicking BOX_2 or BOX_3. It seems I need a way to deal with scenarios such as: Click BOX_1 (swapping BOX_4 with BOX_1_CONTENT) and then immediately clicking BOX_3 and having it swap BOX_1_CONTENT with with BOX_3_CONTENT. Any suggestions on a better way to do this? <script> $(document).ready(function(){ $(".BOX_1").click(function() { $('.BOX_4, .BOX_1_CONTENT').fadeToggle("slow"); }); $(".BOX_2").click(function() { $('.BOX_4, .BOX_2_CONTENT').fadeToggle("slow"); }); $(".BOX_3").click(function() { $('.BOX_4, .BOX_3_CONTENT').fadeToggle("slow"); }); }); </script>
  6. Thank you for your help, It is a little strange, I know. The client wants people to be able to reserve one of two times on one date. Instead of the obvious: having a max number of reservations for each of the two times, they want to max it out by number of the total reservations for that day. Doesn't make sense to me, but that's what they want. I guess what I should be doing, is querying the database for the dates, but ignoring the times? I also forgot to mention that the Reservations table has a column for the number of people in the party for that reservation. I like the idea of joining based on the date ID's, not the actual dates.. that may make it easier. I'll play around with that.
  7. I am looking for a little help on the direction to go with the logic for a MySQL query. I'm not looking for someone to program it, just point me in the right direction for the logic. 1) I have a table that contains available reservation dates. It is populated with several dates. There are two reservation times per day, 12:00 and 12:30. Dates are in date format and stored correctly, but listed below as text for example. See Table 1 below. 2) I have another table that contains reservations. This is populated when someone completes a form for the registration. Dates are stored in the same correct date format, but listed as text below. See Table 2 Below I would like to query the database and Loop through a list of all available dates/times. There are 80 reservations per day, and the times do not matter. For example, "The SUM of January 1, 2017 12:00 AND January 1, 2017 12:30 is less than or equal to 80" would echo both January 1, 2107 12:00 AND January 1, 2017 12:30. I am currently just looping through the list from the dates table based on another column that is "available" or "not available" but that requires someone to go in and modify it manually. I want it to remove the dates automatically when the number of reservations is greater than 80 for that day. -------------------------------------------------------------------------------------------------------------------------------------------------------- Table 1 - Dates (dates are in date format, but just written in text for this example) ID | DATE 1 | January 1, 2017 12:00 2 | Date 2: January 1, 2017 12:30 3 |January 2, 2017 12:00 4 |January 2, 2017 12:30 5 |January 3, 2017 12:00 6 |January 3, 2017 12:30 ... and so on. Table 2 - Reservations (Here, people have made reservations and their reservation is saved in this table). Reservation# | Date ABC123 | January 1, 2017 12:00 ABC456 | January 1, 2017 12:00 ABC667 | January 1, 2017 12:00 ABC777 | January 2, 2017 12:30 etc etc
  8. Thank you for the direction! I've totally scrapped that horrible idea haha. I am now following PRG after the mail is sent if it's successful. I've also combined the mail code in there instead of using an include. Thank you!
  9. I may be going about this all wrong, so hopefully someone can help me out! I have an order form that processes with Braintree. If the transaction is successful, it displays a success message with the order number, and calls a different php file that sends a confirmation email. If the transaction is not successful, it displays error messages. The issue I found was that if the transaction is successful, and the user reloaded the page, it would re-send the confirmation email. This could happen repeatedly. To prevent that, I thought I would add a $order_complete variable. In the original success check, I would check to see if order_complete was "1". If not, display the success text, send the email, and set order_complete to "1". If the page was reloaded and order_complete was "1" it would not re-display the success message and not send the email. Else, it would display the errors. Unfortunately this isn't working. It still sends an email every time! Any suggestions? if (($result->success) && $order_complete != "1") { $_POST['transaction_id'] = $result->transaction->id; echo "<p style=\"color:#000; background-color:#008000; padding:20px;width:70%;\">Your order was successful. Thank you for your support!<br/><br/>"; echo("Your transaction ID is: " . $result->transaction->id . "<br /><a href=\"index.php#go_to_form\"> Click here to order again!</a> </p>"); $order_complete = "1"; include ('/path/to/send_mail.php'); } else if (($result->success) && $order_complete == "1") { echo "Place an Order"; } else { foreach (($result->errors->deepAll()) as $error) { $braintreeError[] = $error->message; } }
  10. SF23103

    Preventing Duplicate Form Submissions

    I'm using Braintree, but I must be doing something wrong with the unique transaction ID/nonce. In looking at the code, it seems to post the transaction_id after success. if($_POST['month']) { $result = Braintree_Transaction::sale(array( "amount" => $fields[total_cost] . ".00", "creditCard" => array( "number" => $_POST["number"], "cvv" => $_POST["cvv"], "expirationMonth" => $_POST["month"], "expirationYear" => $_POST["year"], "cardholderName" => $_POST['first_name'] . " " . $_POST['last_name'], ), "customer" => array( "firstName" => $_POST['first_name'], "lastName" => $_POST['last_name'], "email" => $_POST["billing_email"], ), 'customFields' => array( "class_name" => $fields[class_drop_down], "token" => $fields[token], ), 'billing' => array( "postalCode" => $_POST["billing_zip"], ), )); if ($result->success) { $_POST['transaction_id'] = $result->transaction->id; $params = array( "submit_button" => "submit", "form_data" => $_POST, "no_sessions_url" => "registration.php", "next_page" => "registration-page4.php", "finalize" => true, ); ft_api_process_form($params); $passing_transaction_identification = ($result->transaction->id); } else { $declined_error = "TRUE"; foreach (($result->errors->deepAll()) as $error) { $braintreeError[] = $error->message; } } }
  11. SF23103

    Preventing Duplicate Form Submissions

    That makes sense, and I can see how that would prevent refresh and back button resubmission. Does that protect against multiple submit button presses while awaiting the success notification from the payment processor? I think people are pressing submit again during the lag that is occurring while the payment is being processed before they are sent to the thank-you page.
  12. Hello, I have a multi page form. On the third and final page, the user submits payment information. Upon form submission, it sends payment information to a payment processor. If it is successful, the form submits all of the form data to my database. It includes a payment successful field in my database, but of course no credit card information is stored - that's all handled on the payment processor site. If the payment is not successful, the page loads errors to the user and the form is not submitted to my database until the payment is successful. I am starting to see an issue where I am receiving duplicate payments. I am assuming that people are clicking the submit button multiple times while the payment is processing, and it's sending multiple authorization requests to the payment processor. The payment processor automatically catches some of these, but not all. My question is to what logic is most appropriate reduce duplicate payments. The solution that came to mind was disabling the submit button upon click, but then re-activating if the payment was declined, so the user could re-submit. Of course, I would rather solve this on the server side with php. Is this best handled with cookies? If so, can someone explain the basic logic on how that would work? Thanks for your help as always.
  13. SF23103

    Comparing Times

    Thank you both! Based on both of your suggestions, I went with DateTime objects, and it's working great. That's a good point about error handling.. so I'll work on that next. Also, I see that PHP even has a date_sunset that returns the time of sunset (also one for sunrise) for a given day and location. Pretty cool, maybe I'll play with that too.
  14. SF23103

    Comparing Times

    Hello, I am getting the sunset and sunrise time through an API that gives the time in these variables: $sunrise_hour , $sunrise_minute $sunset_hour , $sunset_minute I am putting them together to get the time of the sunset and sunrise: $sunset_time_formatted = "$sunset_hour:$sunset_minute PM"; Now, if I need to compare the sunset and sunrise time to the current time, ex: date("h:i A"); do I need to convert the $sunset_time_formatted to UNIX time first? The argument I came up with doesn't seem to work correctly. My guess is it needs to know how to read my sunrise and sunset formatted variables as a real time. if ($current_time > $sunrise_time_formatted && $current_time < $sunset_time_formatted) { echo "sun"; } else { echo "moon"; }
  15. Thank you. Just did some reading on the differences between single, double, and triple ='s. Thanks!
×

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.