Jump to content

SF23103

Members
  • Posts

    100
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

SF23103's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

2

Community Answers

  1. 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.
  2. 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
  3. 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!
  4. 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; } }
  5. 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; } } }
  6. 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.
  7. 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.
  8. 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.
  9. 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"; }
  10. Thank you. Just did some reading on the differences between single, double, and triple ='s. Thanks!
  11. I'm trying to GET from a URL, and IF index.php?preselect=testing THEN $preselect_command = 'this is a command...' Why, no matter what I put in the index.php?preselect='WHATEVER' I always get "this is a command..." to echo? I know I'm missing something! if (isset($_GET['preselect'])) { // Check to see if preselect is set in the url. $preselect = $_GET['preselect']; // if preselect is set, put it to my variable } else { $preselect = NULL; // Fallback to null if it's not set } if ($preselect = 'testing') { // if $preselect equals "testing" then, $preselect_command = some text 'this is a command...'. $preselect_command = 'this is a command...'; } else { echo "something else..."; } echo $preselect_command;
  12. Yes, that's what I'm going for, but on mine for some reason it's doing the border around the text "option 1" and not the entire option1 div.
  13. That puts a border around all three selections. If you check out the JsFiddle, I'm looking to move the dynamic box from around the words to around the whole option box.
  14. Hello, I am having difficulty with this one. I am trying to change the border around the entire div (e.g. #option1) instead of just the text. As you can see, when you click each radio button it changes the border around the option text, but not the entire div. Any suggestions? JSFIDDLE: https://jsfiddle.net/1hdv2n3h/1/ HTML <div id="wine_club_selection"> <div id="option1"> <p><input type="radio" name="club_type" checked="checked" value="option 1"><br/> <span class="bold_text">Option 1</span><br/> 3 Bottles<br/> 15% Discount<br/></p></div> <div id="option2"> <p><input type="radio" name="club_type" value="option 2" ><br /> <span class="bold_text">Option 2</span><br /> 6 Bottles<br /> 20% Discount<br/> </p></div> <div id="option3"> <p><input type="radio" name="club_type" value="option 3"><br> <span class="bold_text">Option 3</span><br /> 12 Bottles<br /> 25% Discount<br /> </p></div> </div> CSS #wine_club_selection { height:200px; width:800px; } #option1 { float:left; width:266px; } #option1 p { text-align:center; } #option2 { float:left; width:266px; } #option2 p { text-align:center; } #option3 { float:right; width:266px; text-align: center; } #option3 p { text-align:center; } .bold_text { font-weight:800; } #option1 input[type="radio"]:checked ~ *{ border: thin solid #F00;!important; } #option2 input[type="radio"]:checked ~ *{ border: thin solid #F00;!important; } #option3 input[type="radio"]:checked ~ *{ border: thin solid #F00;!important; }
  15. Thank you. Sorry, I stopped following the last thread after it was solved. Your explanation as to not maintaining a total in the database makes sense. Unfortunately, I am trying to add a small functionality to a much larger already-designed database. At some point I will have to re-design it if I am going to add any more functionality. I also see where it's running the query twice. Thank you!
×
×
  • 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.