Jump to content

Abel1216

Members
  • Posts

    21
  • Joined

  • Last visited

Recent Profile Visitors

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

Abel1216's Achievements

Member

Member (2/5)

0

Reputation

  1. So what is the best comparison to use @mac_gyver. Thanks. Am a learner. Don't mind my question
  2. Notice: Trying to access array offset on value of type null in ***/cpanel/t10.php on line 81
  3. I am trying to get a user details from the database and compare it with the posted value. Now I get Trying to access array offset on value of type null in. The column name user_number exists in the database. This is my code below.. Thanks!!! <?php mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); error_reporting(E_ALL | E_WARNING | E_NOTICE); ini_set('display_errors', TRUE); if (session_status() == PHP_SESSION_NONE) { session_start(); } if(!isset($_SESSION['login'])) { echo ("<script>location.href='../clogin/'</script>"); die(); } if (isset($_POST['submit'])) { include_once('db.php'); //get post details from user $UserNumber = $_POST['uNumber']; $sql = "SELECT * FROM customer WHERE user_number=?"; $stmt = $connection->prepare($sql); $stmt->bind_param('i', $UserNumber); $stmt->execute(); $result = $stmt->get_result(); $count = $result->num_rows; if($count == 1) { while($row = $result->fetch_assoc()); { $db_Uno = $row['user_number']; if($userNumber !== $db_Uno) { echo'<script>swal.fire("FAILED!!", "<strong>No Customer with the user number you entered.</strong><hr><br/><i> Check well and try Again.</i>", "error");window.setTimeout(function(){ window.location.href = "home.php"; }, 2000);</script>'; exit(); } else { } }//while loop } //end of if rslt }// end submit for transfer post ?>
  4. Thanks. I have fixed it since... @mac_gyver
  5. I wrote a code to echo "limit reached" if A is greater than B. But if A is 400030 and B is 400000 it shows no output. If A is further greater than that, let say 400060 or any number higher than that, it shows the output.. Please how do I explain that? The code snippet to demonstrate what I mean is.... <?php include_once('db.php'); error_reporting(E_ALL | E_WARNING | E_NOTICE); ini_set('display_errors', TRUE); if (session_status() == PHP_SESSION_NONE) { session_start(); } if(!isset($_SESSION['login'])) { echo ("<script>location.href='../clogin/'</script>"); die(); } if(isset($_POST['transfer'])) { $username = $_SESSION['login']; $transAmount = $_POST['transAmount']; $totalTrans = $transAmount + 30; $sql = "SELECT * FROM customer WHERE username = ?"; $stmt = $connection->prepare($sql); $stmt->bind_param('s', $username); $stmt->execute(); $result = $stmt->get_result(); if(!$result) { die('ERROR:' . mysqli_error($connection)); } $count = $result->num_rows; if($count == 1) { while ($row = $result->fetch_assoc()) { $accTrans = $totalTrans + $row['dailyTrans']; $sql2 = "UPDATE customer set dailyTrans=? WHERE username=?"; $stmt = $connection->prepare($sql2); $stmt->bind_param('is', $accTrans,$username); $stmt->execute(); if(!$stmt) { die('network problem'); } if($row['dailyTrans'] >= $row['dailyLimit']) { echo '<script>swal.fire("FAILED!!", "<strong>You have reached the total amount you can send per day.</strong><hr><br/><i>Visit your bank to increase transfer limit.</i>", "error"); window.setTimeout(function(){ window.location.href = "transfer1.php";} , 1700); </script>'; //exit(); } else { echo""; } }//while loop }//count }//submit ?> My question Summary Again The value for $row['dailyTrans'] is 400030 and the value of $row['dailyLimit'] is 400000 This is suppose to echo out the error but fails... if $row['dailyTrans'] is greater than 400030, it echoes out. What is the logic behind that?. Please be nice with your comments as usual. Thanks . Both Value are integers!! . The code works well just that at 400030 it doesn't output that its greater than 400000
  6. I have found the issue. Thanks. Even if i had no answers. Much love😉
  7. Am trying to get user input then compare it with the value in database then return an output in form of echo. It shows a blank page of whick i cant figure out the error. This is what i have tried so far. This is a file called t12.php <?php include 'db.php'; error_reporting(E_ALL | E_WARNING | E_NOTICE); ini_set('display_errors', TRUE); if (session_status() == PHP_SESSION_NONE) { session_start(); } if(!isset($_SESSION['login'])) { echo (" <script>location.href='../clogin/'</script>"); die(); if(isset($_POST['transfer'])) { $username = $_SESSION['login']; $transAmount = $_POST['transAmount']; $totalTrans = $transAmount + 30; $sql = "SELECT * FROM customer WHERE username = ?"; $stmt = $connection->prepare($sql); $stmt->bind_param('s', $username); $stmt->execute(); $result = $stmt->get_result(); $count = $result->num_rows; if($count == 1) { while ($row = $result->fetch_assoc()) { if($totalTrans > $row['transLimit']) { echo 'you have exceeded limit'; exit(); } else { echo"limit passed"; } }//while loop }//count }//submit }//session ?> The html form is this... <form action="t12.php" method="post"> <input type="number" name="transAmount" placeholder="Enter Amount"> </input><br> <button type="submit" name="transfer">Proceed</button></form> Have tried lot of stuffs but doesnt work out. I would appreciate if you can take your time to check for me and point out the errors. Also please be nice with your comments. Thanks in advance
  8. Based on the comments on my previous question, took some tutorials on how to avoid injections on query. Does the code below prevents against it in any way.? Secondly, can you recommend a good article that writes well in how to secure input data by users. Please be kind with your comments.😉😉. Thankks in advance. The code works fine. <?php include 'db.php'; error_reporting(E_ALL | E_WARNING | E_NOTICE); ini_set('display_errors', TRUE); if(isset($_POST['submit'])) { $username = $_POST['username']; $password = ($_POST['password']); $sql = "SELECT * FROM customer WHERE username = ?"; $stmt = $connection->prepare($sql); $stmt->bind_param('s', $username); $stmt->execute(); $result = $stmt->get_result(); $count = $result->num_rows; if($count == 1) { while ($row = $result->fetch_assoc()) { if ($row['status'] == 'blocked') { echo'your account is suspended' session_destroy(); exit(); } else if($row['status'] == 'active') { if($username !== $row['username']) { echo '<script>swal.fire("ERROR!!", " Username is not correct. Check Again", "error");</script>'; } if($password !== $row['password']) { echo'<script>swal.fire("ERROR!!!", "Your Password is Incorrect. Check Again.", "error");</script>'; } if($username == $row['username'] && $password == $row['password']) { header('Location:cpanel/'); else { } }//if count }//while loop }//submit ?>
  9. Tanks so much i have realised the error. Was so stubborn to use it even before i requested for help. It now works fine. One more question.. I made an html form to input a details of which a token input is among. So u need to generate a token which will be sent to email of the user then you input to the token field before submission. Now i used an ajax code to load the token generation code ansynchronously which works fine. But on submission of the form, the token page still loads again, thereby generating a new token.. The html form is below and the ajax code which is in the head section. Id of the send token button is box <script> $(document).ready(function(){ $("button").click(function(){ $("#box").load("token.php"); }); }); </script> <form action="" method=post"> <label>Firstname</label> <input type="text" class="form-control" id="firstname" name="firstname" placeholder="Enter destination surname" required> </div> <div class="form-group"> <label>Lastname</label> <input type="text" class="form-control" id="lastname" name="lastname" placeholder="Enter destination last name" required> </div> <div class="form-group"> <label>Middlename</label> <input type="text" class="form-control" id="middlename" name="middlename" placeholder="Enter destination Middlename" required> </div> <div class="form-group"> <label>Description</label> <input type="text" class="form-control" id="description" name="description" placeholder="Enter transfer description" required> </div> <button type="button" id ="box" class="btn btn-primary w-md waves-effect waves-light">SEND TOKEN</button> <div class="form-group"> <label>ENTER OTP<label> <input type="number" class="form-control" name="otp" placeholder="TOKEN" pattern="[0-9]{4}" title="Only Digits (4 digit required)" required> </div> <div class="form-group row"> <div class="col-12 text-right"> <button class="btn btn-primary w-md waves-effect waves-light" type="submit" name="transfer">Proceed</button> </div> </div> <div class="form-group mt-2 mb-0 row"> <div class="col-12 mt-4"> <p class="mb-0">CANCEL<a href="dash.php" class="text-primary"> Go</a></p> </div> </div> </form> Thanks for your usual help!!!
×
×
  • 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.