Jump to content

imgrooot

Members
  • Content Count

    243
  • Joined

  • Last visited

  • Days Won

    1

imgrooot last won the day on May 16 2018

imgrooot had the most liked content!

Community Reputation

1 Neutral

About imgrooot

  • Rank
    Advanced Member
  1. So in your opinion, which method is better to use? The $_COOKIE method I used above or a $_SESSION one?
  2. Because if I'm not mistaken, the SESSION only lasts until you close the browser. I want to use the COOKIES so that the referral name is saved for up to a year, unless someone deletes their browser cookies or uses a different referral link.
  3. Of course it was that simple. I should have thought of that. It works like a charm now. Thanks again.
  4. Not sure if I understand you correctly. But I have found a fix around. Instead of having the referral link go directly to the sign up page, I instead link it to the home page. Like this "www.mysite.com/?ref=johnsmith". This way when the user goes to the sign up page, the cookie will already be set. I tried it and it seems to work fine.
  5. I want to show a cookie of a referral's username on a sign up page. The link is like this, www.mysite.com/signup?ref=johnsmith. The cookie doesn't show if I go to that url page. But it does show up once I reload the page. So I'm wondering if it's possible to show the cookie the first time around, instead of reloading the page? Here is my code. // This is in the header $url_ref_name = (!empty($_GET['ref']) ? $_GET['ref'] : null); if(!empty($url_ref_name)) { $number_of_days = 365; $date_of_expiry = time() + 60 * 60 * 24 * $number_of_days; setcookie( "ref", $url_ref_name, $date_of_expiry,"/"); } else if(empty($url_ref_name)) { if(isset($_COOKIE['ref'])) { $user_cookie = $_COOKIE['ref']; } } else {} // This is for the sign up form if(isset($_COOKIE['ref'])) { $user_cookie = $_COOKIE['ref']; ?> <fieldset> <label>Referred By</label> <div id="ref-one"><span><?php if(!empty($user_cookie)){echo $user_cookie;} ?></span></div> <input type="hidden" name="ref" value="<?php if(!empty($user_cookie)){echo $user_cookie;} ?>" maxlength="20" placeholder="Referrer's username" readonly onfocus="this.removeAttribute('readonly');" /> </fieldset> <?php }
  6. I guess I really needed that sleep. I have found the solution. Apparently I didn't know how EasyApache 4 really worked. I had the package installed that contained the GMP extension. But The extension was not enabled. Once it was enabled, the package provision had to be reinstalled. That was it. Now it works.
  7. This is going to seem like a long shot. I've been trying to figure this out all night and still no luck. Perhaps someone more experienced can tell me why it's not working. I have a CloudNX server with fasthosts.co.uk. I have installed a GMP extension on the WHM panel using EasyApache 4. Now I even tried adding "extension=gmp.so" in the php.ini file of both WHM and the cPanel where the website is located. But no matter what, my site gives me an error like this. Fatal error: Uncaught exception 'Exception' with message 'GMP extension seems not to be installed' in I am using this API https://block.io/api/simple/php . It requires GMP extension. It works great on my local server. I have no issue with GMP extension there. So does anyone have a clue as to what I might be doing wrong and how I can fix this?
  8. Oh wow, that's a much more efficient way of doing it. My original query has more fields so i tried to simplify it for demonstration purposes. That's where I made the mistake of having :user_id when there shouldn't be. Just one question. Your example shows inserting two fields(id, name). If I wanted to insert four fields, would it look like this? $params[] = '(?,?,?,?)'; array_push($data, $id, $name, $field3, $field4);
  9. Do you mean like this? $entries = 10; $id = 55; $name = 'Smith'; $stmt = $db->prepare("INSERT INTO entries(id, name) VALUES(:id, :name)"); $stmt->bindParam(':id', $id); $stmt->bindParam(':user_id', $name); for($i = 1; $i <= $entries; $i++) { $result_insert = $stmt->execute(); if($result_insert == false) { $errors[] = 'There was a problem!'; } }
  10. I have my reason to use an empty form form to submit outside data. I was not asking advice on that. I simply wanted to know how to insert the same query multiple times. Below is the updated query that does not. It seems to work fine, unless you think other wise. $entries = 10; $id = 55; $name = 'Smith'; $stmt = $db->prepare("INSERT INTO entries(id, name) VALUES(:id, :name)"); for($i = 1; $i <= $entries; $i++) { $stmt->bindParam(':id', $id); $stmt->bindParam(':user_id', $name); $result_insert = $stmt->execute(); } if($result_insert == false) { $errors[] = 'There was a problem!'; }
  11. Say I have an "Entries" table. I want to submit same multiple entries using a form submission. And If I have other queries submitted in the same form, I want those quarries to be submitted only once. Is that possible to do? Here's my code. if(isset($_POST['submit'])) { $entries = 10; $id = 55; $name = 'Smith'; $insert = $db->prepare("INSERT INTO entries(id, name) VALUES(:id, :name)"); $insert->bindParam(':id', $id); $insert->bindParam(':name', $name); $result_insert = $insert->execute(); if($result_insert == false) { echo 'Fail'; } else { echo 'Success'; } } ?> <form action="" method="post"> <input type="submit" name="submit" value="SUBMIT" /> </form>
  12. Here's the code for the countdown timer. It works. At the end of the countdown, it's suppose to show the message "EXPIRED". But that message only shows once I reload the page. The countdown itself stops at 00:00:01. Is there a way to automatically show the message after that, instead of reloading the page to show it? <style> div#counter{ margin: 100px auto; width: 305px; padding:20px; border:1px solid #000000; } div#counter span{ background-color: #00CAF6; padding:5px; margin:1px; font-size:30px; } </style> <?php $target_date = '2019-01-12 05:40:00'; $timeLeft = (strtotime($target_date) - time()) * 1000; ?> <script src="javascripts/timer.js"></script> <script> $(document).ready(function(){ var timeLeft = <?php echo $timeLeft ; ?>; var timer = new Timer($('#counter'), timeLeft); if (timeLeft <= 0) { $('#counter').text('EXPIRED'); } }); </script> <div id="counter"> <span class="hour">00</span> <span class="min">00</span> <span class="sec">00</span> </div>
  13. Correct, the multiplication would do the reverse. Like this. function convertToSatoshi($value) { $SAT = $value * 100000000 ; return $SAT; } I was more worried about reversing the decimal part of the 2nd function, but I just realized that it's not needed to convert to Satoshie.
×

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.