Jump to content

I-AM-OBODO

Members
  • Posts

    442
  • Joined

  • Last visited

Everything posted by I-AM-OBODO

  1. thanks and noted
  2. I have a unique id and a transaction reference which is also unique and auto generated. All is well on my database. all I want is to increment setup bill + one if It's a new provider and nothing if its the provider on the bill. It's sort of: if provider is new, rewards = + 1 else rewards =nothing or ignore.
  3. Had a great Sunday services, now programming my head out. Trying to solve a bug from my latest application. I know i'll get it done, WITH GOD ON MY SIDE THOUGH!!! HAPPY SUNDAY

    1. Show previous comments  1 more
    2. I-AM-OBODO

      I-AM-OBODO

      only if you know who God is

    3. Monkuar

      Monkuar

      I know who God is, but he won't stop you from an XSS injection. Been there, done that first hand bud.

    4. .josh

      .josh

      With God, all things are possible.

  4. Hi all. In my database, i have a table where a client chose a service providers to make payments and each bill setup counts as a reward point for the client. Each bill counts as a single point even if the bill is edited after a services might have expired or renewed it should not be counted again as point. to count the number of bill set up by a client i did $stmt = $pdo->prepare("UPDATE reward_points SET num_bill = num_bill + 1 WHERE username = '$username' AND acct_num = '$acct_num'"); $stmt->execute(); Its okay if it counts for new bills but i want it not to count for the same service provide and so i did $stmt=$pdo->query("SELECT company FROM payment WHERE username = '$username' AND trans_ref = '$trans_ref'"); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $coy = $row['company']; } //ps: note, $company is a variable from the form if(strcmp($coy, $company) == 0){ $stmt = $pdo->prepare("UPDATE reward_points SET num_bill = num_bill + 0 WHERE username = '$username' AND acct_num = '$acct_num'"); $stmt->execute(); }elseif(strcmp($coy, $company) != 0){ $stmt = $pdo->prepare("UPDATE reward_points SET num_bill = num_bill + 1 WHERE username = '$username' AND acct_num = '$acct_num'"); $stmt->execute(); } it just wont add up i also tried $coy1 = $coy; $coy2 = $company; $point = 0; if(strcmp($coy1, $coy2) == 0){ $add_point = $point + 0; }else{ $add_point = $point + 1; } $stmt = $pdo->prepare("UPDATE reward_points SET num_bill = $add_point WHERE username = '$username' AND acct_num = '$acct_num'"); $stmt->execute(); still wont work. any idea?
  5. It's all working now. Thanks @QuickOldCar and @Barand
  6. still wouldn't work. could it be cos the result value is not in the database? cos diff is d result of a datediff value. I.e $stmt=$pdo->query("select datediff(due, paid) as diff where name =:name"); $stmt->execute() while ($row = $stmt->fetch (PDO::FETCH_ASSOC)) { $diff=$row['diff'] ; } switch ($diff) { case 0: case 1: case 2: case 3: case 4: case 5: $point = 6; break; case 6: case 7: case 8: case 9: case 10: $point = 4; break; default: $point = 1; } echo $point; $total_points = 0; // DEFINE the variable begin loop $points = $point; // get points value $total_points += $points; // accumulate points total endloop echo $total_points; in the above code let's say I have 6 as $diff on the first row and on the second row I have $diff as 4, the $total_points ought be 10 but its giving me 6
  7. still wouldn't work. could it be cos the result value is not in the database? cos diff is d result of a datediff value. I.e $stmt=$pdo->query("select datediff(due, paid) as diff where name =:name"); $stmt->execute() while ($row = $stmt->fetch (PDO::FETCH_ASSOC)) { $diff=$row['diff'] ; } switch ($diff) { case 0: case 1: case 2: case 3: case 4: case 5: $point = 6; break; case 6: case 7: case 8: case 9: case 10: $point = 4; break; default: $point = 1; } echo $point; $total_points = 0; // DEFINE the variable begin loop $points = $point; // get points value $total_points += $points; // accumulate points total endloop echo $total_points; in the above code let's say I have 6 as $diff on the first row and on the second row I have $diff as 4, the $total_points ought be 10 but its giving me 6
  8. I did so but It's saying undefined variable: total_point and yet brings the result of only one row without adding the column
  9. but how can I sum all the values from $point?
  10. Thanks @all
  11. Hi, I have a point that is assigned to an individual based on their duration in the program. I used datediff to calculate the date difference and the result I assigned to a variable. Now I want to do this: if day = 0-5, point =6 what I did was if($diff == 0 OR 1 OR 2 OR 3 OR 4 OR 5){ $point =6; }elseif($diff == 6 OR 7 OR 8 OR 9 OR 10){ $point =4; } else $point =1; } echo $point;
  12. Wow! after much playing around. Got it <?php $stmt = $pdo->query("SELECT acct_num FROM table ORDER BY id DESC"); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $acct_num = $row['acct_num']; echo "<option> $acct_num </option>"; } ?> Thanks all
  13. Hi all. how can i make the values show like a list. I tried html line break "<br>" and php \n but all to no avail. It just show all the values in one straigth line. example of what i want is for the values to appear like this: 1234567890 0987654345 4567890675 instead of : 1234567890 0987654345 4567890675 Thanks <form data-abide method="post" action=""> <div> <select name=""> <option value="name"> <?php $stmt = $pdo->query("SELECT acct_num FROM table order by id desc"); while ( $row = $stmt->fetch(PDO::FETCH_ASSOC) ) { echo $row['acct_num']; } ?> </option> </select> </div> <div> <label>New Password <small>required</small></label> <input type="password" name="password" id="password" required> <small class="error">New password is required and must be a string.</small> </div> <div> <label>Confirm New Password <small>required</small></label> <input type="password" name="password2" id="password2" required> <small class="error">Password must match.</small> </div> <input name="submit" type="submit" class="button small" value="Change Password"> </form>
  14. I could do this with a while but was thinking It's bad practice that why I need to know. "select password from table where username = username and password = password"; while ($row = $stmt->fetch (PDO::FETCH_ASSOC)) { $hash =$row['password'] ; }
  15. I know that the password ought be stored in database and I also know that the verify is used to check if the password is ok. my question is how to retrieve the password and assign the value to $hash. I could do a while query to store result in $hash but I read somewhere that It's bad practice cos that would expose the hashed password thereby given the security a loophole.
  16. Hi. I've been trying to understand the concept of password_hash but so far it has eluded me! registration <?php if(isset($_POST['submit'])){ $name = $_POST['name']; $email = $_POST['email']; $password = $_POST['password']; //$pass_hash = PassHash::hash($_POST['password']); $hash = password_hash($password, PASSWORD_BCRYPT); $stmt = $pdo->prepare("INSERT INTO hash_test(name, email, password) VALUES(:name, :email, :password)"); $stmt->execute(array( ':name' => $name, ':email' => $email, ':password' => $hash )); if ($stmt->rowCount() ==1){ echo "Registration Successful"; }else{ echo "There was a problem taking your request"; } } ?> The registration is working fine and all fields are inserted. The problem is when loggin in, its giving me an error : unknown variable which is the $hash. The verify parameter is thus: password_verify($password, $hash) I believe the $password is the users password for login, now how/when/where do assign a value to $hash? since in my db i have email(username) password. Do i need to store the hash separately on the db? Can someone please enlighten me more my login code <?php if(isset($_POST['login'])){ $password = $_POST['password']; $stmt = $pdo->prepare("SELECT email, password FROM hash_test WHERE email=:email AND password=:password"); $stmt->execute(array( ':email' => $_POST['email'], ':password' =>$password )); //if ($stmt->rowCount() ==1){ if (password_verify($password, $hash)) { /* Valid */ echo "Right"; } else { /* Invalid */ echo "wrong"; } //} } ?> THANKS
  17. I wonder what's wrong with me. I've seen the problem. Thanks my head was beclouded thank you very much
  18. sorry if you dont get me right. i have a table that has a transaction date and expiry date. I want to create another column where i can see the intervals between the order date and expiry date. i want to see them without doing a where clause. example Name Date Paid Expiry Date Date Difference John 2014-11-07 2014-12-01 24 days Doe 2014-11-07 2014-11-10 3 days This is what i did $stmt = $pdo->query("SELECT DATEDIFF(date_paid, next_due) AS diffdate FROM ca_payment"); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo $row['diffdate']; } but its showing the total sum of date difference of all the column which is not what i want
  19. Hi all. How can i see all the difference between two dates in a column. I know to see a single date difference we can do: $stmt = $pdo->query("SELECT DATEDIFF(date_paid, next_due) AS diffdate FROM table_name"); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo $row['diffdate']; } but i want all the difference to show in a table along with other details. thanks
  20. Thanks all. Been out of town for a while that's the reason i'm reply now. I managed to get it to work. i changed a couple of things and i cannot really pin-point what made it work. I removed all the mysql_real_escape_string and changed the path. Thank you so very much. ps: still studying password_hash so that i can start implement.
  21. yes I think pdo is enabled cos I could log in at the admin end and It's using pdo
  22. thanks for yours above. the password hashing is same both on logging. I said I could login on my localhost but cant when live.
  23. Nope. jus t didn't include it here
  24. Oh I forgot to mention that even with path as is, it's logging into the intended area with mysql but when modified to pdo, it doesn't log in
×
×
  • 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.