Jump to content

Abel1216

New Members
  • Content Count

    7
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Abel1216

  • Rank
    Newbie

Recent Profile Visitors

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

  1. 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!!!
  2. Ok tanx. I will adjust all those. But then, is that a reason why the alert about invalid login doesnt pop out even though it fails to log the user in?? Thanks
  3. Please i need a code such that in a given html form, it loads another page without refreshing the current page and on submit of the form, action is nit taken on the button that is needed to load another page. Rough idea of what am saying is below. <form action "" method="post"> <label>Username</label> <input type="text" name="uname> <label>Number</label> <input type="text" name="no"><br/> <button type="submit">Generate Token</button> //when this generate button is clicked then it loads generate.php page whic generates token then send to user email <label>Token</label> <input type="number" name="uname> <button type="submit">PROCEED</button> //thid is the final process that occurs . Its just a rough idea to explain what i meant by the question i asked. For thhe generation of token, i dnt want the page to reload and for the proceed, i dnt want any action to be taken on the generate butron. I hope my question is clear. Thanks in advance
  4. Just an assignment but could be useful for me in the future so you can help me out with youe observations and coreections
  5. My boostrap alerts is not displaying. The codes works if the login details are correct and also works if login details are wrong but refuses to show the error login info. My codes are <?php include 'db.php'; error_reporting(E_ALL | E_WARNING | E_NOTICE); ini_set('display_errors', TRUE); if(isset($_POST['submit'])) { $msg2 ='<div class="bs-example"> <div class="alert alert-warning alert-dismissible fade show"> <strong>Error!</strong> Invalid. Login. <button type="button" class="close" data-dismiss="alert">×</button> </div>'; $username = $_POST['username']; $password = $_POST['password']; $username = mysqli_real_escape_string($connection, $username); $password = mysqli_real_escape_string($connection, $password); //query $query = "SELECT * FROM customer WHERE username = '{$username}'"; $select_user_query = mysqli_query($connection, $query); //select user if(!$select_user_query) { die("QUERY FAILED". mysqli_error($connection)); } else{ //bring in database values while($row = mysqli_fetch_array($select_user_query)) { $db_username = $row['username']; $db_password = $row['password']; $db_email = $row['email']; if($username !== $db_username && $password !== $db_password) { echo "$msg2"; } else if($username == $db_username && $password == $db_password) { date_default_timezone_set("Africa/Lagos"); $time = date('h:i:sa'); $date = date('d/m/Y'); $msg = " <!DOCTYPE html><body>Dear <h2> $db_username , </h2> <h3><font color='purple'>Your Mayor Microfinance Bank Online Bank Account was logged in today,<h2> $date at $time (GMT+1)!!</h2><b>. </font><br> <font color='red'>If You are not the one that Logged it in, Please Visit Your bank immediately or Call our contacts available on our home page</h3></font>.....<br></b><i><font color='blue'>MMFB</font></i> </body></html> $headers = ""; $headers .= "From: Mayor Microfinance Bank(MMFB)<admin@mmfb.com.ng> \r\n"; $headers .= "Reply-To:" . $db_email. "\r\n" ."X-Mailer: PHP/" . phpversion(); $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $send = mail("$db_email","LOGIN SUCCESFUL",$msg,$headers); $_SESSION['login'] = $username; $_SESSION['timestamp']=time(); echo ("<script>location.href='../cpanel'</script>"); } }//end while }//else end }//submit ?> The following code is under the head section of the html code in the same page as the code above <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Customer's Dashboard | Mayor Microfinance Bank</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta content="Online Banking For Microfinance bank Demo" name="description" /> <meta content="MayorTech" name="author" /> <!-- App favicon --> <link rel="shortcut icon" href="assets/images/favicon.ico"> <link href="assets/libs/chartist/chartist.min.css" rel="stylesheet"> <!-- Bootstrap Css --> <link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" /> <!-- Icons Css --> <link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" /> <!-- App Css--> <link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" /> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script> <style> .bs-example{ margin: 20px; } .footer { background-color:cornflowerblue; color:white; } </style> </head> The same issue occurs with sweet alert too. Am new to coding but i cant seem to figure out my errors . thanks in advance
  6. I am working on an e banking web app. So i was stuck on the transferring to the same bank page.. I have spent a lot of time to check where the errors are to no avail. The issue is the code doesnt work it gives a blank page... This is 12.php for the post action <?php session_start(); error_reporting(E_ALL); ini_set('display_errors', TRUE); if(!isset($_SESSION['login'])) { header('Location: ../clogin.php'); } f (isset($_POST['transfer'])) { $db['db_host'] = "localhost"; $db['db_user'] = "***""; $db['db_pass'] = "***"; $db['db_name'] = "***"; foreach($db as $key => $value){ define(strtoupper($key), $value); } $connection = mysqli_connect(DB_HOST, DB_USER,DB_PASS,DB_NAME); $query = "SET NAMES utf8"; mysqli_query($connection,$query); if(!$connection) { echo "database not connected"; } //get info / $sql = "select firstname,lastname, middlename,username,balance from customer where username = '".$_SESSION['login']."'"; send query /$sql2 = mysqli_query($connection, $sql); //check query if(!$sql2) { die('ERROR:' . mysqli_error($connection)); } //get trans details $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $middlename = $_POST['middlename']; $account_number = $_POST['accountNumber']; $transAmount = $_POST['transAmount']; $description = $_POST['description']; $otp =$_POST['otp']; $sql3 = "select firstname, lastname, middlename, account_number,balance,otp,otpTime,transLimit from customer where account_number = '$account_number' "; $result3 = mysqli_query($connection,$sql3); if(!$result3) { die('ERROR:' . mysqli_error($connection)); } while($row3 = mysqli_fetch_assoc($result3)) { $rfirstname = $row3['firstname']; $rlastname = $row3['lastname']; $rmiddlename = $row3['middlename']; $raccountNumber = $row3['account_number']; if($rfirstname !== $firstname && $rlastname !== $lastname && $rmiddlename !== $middlename && $raccountNumber !== $account_number) { echo'<script>swal.fire("FAILED!!", " The Account Number doesnt match the Account Name. Check Well", "error");</script>'; } else if($rfirstname == $firstname && $rlastname == $lastname && $rmiddlename == $middlename && $raccountNumber == $account_number) { $totalTrans = $transAmount + 30; $sql5 = "SELECT * FROM customer WHERE username = {$username}"; $result5 = mysqli_query($connection, $sql5); //check query if(!$result5) { die('ERROR:' . mysqli_error($connection)); } while($row5 = mysqli_fetch_assoc($result5)) { $balance = $row5['balance']; if($totalTrans > $row5['balance']) { echo'<script>swal.fire("FAILED!!", " Insufficient Funds", "error");</script>'; } }//while balance $sql6 = "SELECT * FROM customer WHERE username = {$username}"; $result6 = mysqli_query($connection, $sql6); //check query if(!$result6) { die('ERROR:' . mysqli_error($connection)); } while($row6 = mysqli_fetch_assoc($result6)) { $transLimit = $row6['transLimit']; $acctype = $row6['acctype']; if($transAmount > $row6['transLimit'] && $row6['acctype'] == 'savings') { echo'<script>swal.fire("FAILED!!", " You can Only transfer maximum of 500,000 naira per time", "error");</script>'; } if($transAmount > $row6['transLimit'] && $row6['acctype'] == 'current') { echo'<script>swal.fire("FAILED!!", " You can Only transfer maximum of 5,000,000 naira per time", "error");</script>'; } }// end of while transLimit $sqla = "SELECT * FROM customer WHERE username = '".$SESSION['login']."'"; $sqla = mysqli_query($connection, $sqla); if(!$sqla) { die('ERROR:' . mysqli_error($connection)); } while($rowa = mysqli_fetch_assoc($sqla)) { $otp = $rowa['otp']; $db_username = $rowa['username']; $db_email = $rowa['email']; $otpTime = $rowa['otpTime']; $time_now = strtotime($otpTime); if($otp !== $rowa['otp']) { echo'<script>swal.fire("FAILED!!", " OTP does not match", "error");</script>'; } if($otp == $rowa['otp'] && (time() - $time_now > 3 * 60)) { echo'<script>swal.fire("FAILED!!", " OTP expired. Press Resend", "error");</script>'; } $sqlb = "update accounts set otp = null where username = '".$_SESSION['login']."' "; $resultb = mysqli_query($connection, $sqlb); //check query if(!$resultb) { die('ERROR:' . mysqli_error($connection)); } }// while end $sqlc = "SELECT * FROM customer WHERE username = {$username}"; $resultc = mysqli_query($connection, $sqlc); //check query if(!$resultc) { die('ERROR:' . mysqli_error($connection)); } while($rowc = mysqli_fetch_assoc($result5)) { $transLimit = $rowc['transLimit']; $otp = $rowc['otp']; $balance = $rowc['balance']; $otpTime = $rowc['otpTime']; $time_now = strtotime($otpTime); $totalTrans = $transAmount + 30; if($rfirstname == $firstname && $rlastname == $lastname && $rmiddlename == $middlename && $raccountNumber == $account_number && $totalTrans < $transLimit && $totalTrans <= $row['balance'] && $otp == $row['otp'] && (time() - $time_now < 3 * 60)) { $sql9 = "update customer set balance = $balance - $totalTrans where username = '".$_SESSION['login']."'"; $result9 = mysqli_query($connection, $sql9); //check query if(!$result9) { die('ERROR:' . mysqli_error($connection)); } $sql10 = "update customer set balance = $balance + $transAmount where firstname = '$rfirstname' and lastname= '$rlastname' and account_number = '$raccountNumber' and middlename= '$rmiddlename' "; $result10 = mysqli_query($connection, $sql10); //check query if(!$result10) { die('ERROR:' . mysqli_error($connection)); } }//end of if }//end of while $sqlf = "SELECT * FROM customer WHERE username = {$username}"; $resultf = mysqli_query($connection, $sqlf); //check query if(!$resultf) { die('ERROR:' . mysqli_error($connection)); } while($rowf = mysqli_fetch_assoc($result5)) { $db_username = $rowf['username']; $db_email = $rowf['email']; $msg = " <!DOCTYPE html><body>Dear <h1> $db_username, </h1> <h2><font color='darkviolet'>You transferred $transAmount to $rfirstname $rlastname $rmiddlename with account Number $raccountNumber . Transaction statement/history is available on your portal for reference purposes.Thanks For banking with Us<b>. <br> If you didnt request for this transaction, contact your bank immediately!!!</font></h2>.....<br></b><i><font color='blue'>MMFB</font></i> </body></html> $headers = ""; $headers .= "From: Mayor Microfinance Bank(MMFB)<admin@mmfb.com.ng> \r\n"; $headers .= "Reply-To:" . $db_username. "\r\n" ."X-Mailer: PHP/" . phpversion(); $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $send = mail("$db_email","SUCCESFUL TRANSACTION",$msg,$headers); }//end of while $transid = substr(str_shuffle('abcdefghijklMnopqrstuvwxyz01234567890') , 0 , 10 ); $status1 = '<button class="button">CREDIT</button>'; $status2 = '<button class="button2">DEDIT</button>'; $sqlm = "SELECT * FROM customer WHERE username = {$username}"; $resultm = mysqli_query($connection, $sqlm); //check query if(!$resultm) { die('ERROR:' . mysqli_error($connection)); } while($rowm = mysqli_fetch_assoc($resultm)) { $sfirstname = $rowm['firstname']; $smiddlename = $rowm['middlename']; $slastname = $rowm['lastname']; $date = date("d/m/Y"); $sql11 = "insert into transactions where account_number = '$raccountNumber' (status,firstname,lastname,middlename,transAmount,date,account_number,description,transid,type) values ('credit transaction',$sfirstname', '$slastname', '$smiddlename', '$transAmount', '$date', '$raccountNumber', '$description', '$transid', '$status1')"; // $result11 = $connection->query($sql11); $result11 = mysqli_query($connection, $sql11); //check query if(!$result11) { die('ERROR:' . mysqli_error($connection)); } $sql12 = "insert into transactions where username = '$username' (status,firstname,lastname,middlename,transAmount,date,accountNumber,description,transid,type) values ('debit transaction','$firstname', '$lastname', '$middlename', '$transAmount', '$date', '$accountNumber', '$description', '$tranid', '$status2')"; $result12 = mysqli_query($connection, $sql12); //check query if(!$result12) { die('ERROR:' . mysqli_error($connection)); } }//end of ehile $sql15 = "SELECT * FROM customer WHERE username = {$username}"; $result15 = mysqli_query($connection, $sqlf); //check query if(!$result15) { die('ERROR:' . mysqli_error($connection)); } while($row15 = mysqli_fetch_assoc($result15)) { $firstname = $row15['firstname']; $lastname = $row15['lastname']; $db_email = $row15['email']; $sql16 = "SELECT * FROM customer WHERE account_numberr = $raccountNumber "; $result16 = mysqli_query($connection, $sql16); //check query if(!$result16) { die('ERROR:' . mysqli_error($connection)); } while($row16 = mysqli_fetch_assoc($result16)) { $remail = $row16['email']; $msg = " <!DOCTYPE html><body>Dear <h1> $rfirstname $rlastname $rmiddlename </h1> <h2><font color='darkviolet'>Your account $raccountNumber has been credited with $transAmount from $firstname $lastname . Transaction statement/history is available on your portal for reference purposes.Thanks For banking with Us<b>. <br> If you didnt request for this transaction, contact ur bank immediately!!!</font></h2>.....<br></b><i><font color='blue'>MMFB</font></i> </body></html> $headers = ""; $headers .= "From: Mayor Microfinance Bank(MMFB)<admin@mmfb.com.ng> \r\n"; $headers .= "Reply-To:" . $db_username. "\r\n" ."X-Mailer: PHP/" . phpversion(); $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $send = mail("$remail","SUCCESFUL TRANSACTION",$msg,$headers); }//end while 1 }//end while 2 } else { echo'<script>swal.fire("FAILED!!", " Something Went Wrong Try Again Later.", "error");</script>'; } }//while }//submit ?> Then my html form in transfer.php is <form method="POST" class="form-horizontal mt-4" action=""> <div class="form-group"> <label>Account Number</label> <input type="number" class="form-control" id="number" name="accountNumber" placeholder="Enter destination account No" required> </div> <div class="form-group"> <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> <div class="form-group"> <label>Amount</label> <input type="number" class="form-control" id="amount" name="transAmount" placeholder="Enter the amount to Send" required> </div> <div class="form-group"> <label>ENTER OTP<label> <input type="number" class="form-control" name="otp" placeholder="OTP" 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">Transfer</button> </div> </div> <div class="form-group mt-2 mb-0 row"> <div class="col-12 mt-4"> <p class="mb-0">You will be charged 30 Naira for Transfer fee.<a href="dash.php" class="text-primary"> No!! Cancel Transfer</a></p> </div> </div> </form> <!-- <button type="button" id ="box" class="btn btn-primary w-md waves-effect waves-light">SEND OTP</button> --> </div> </div> </div> I will be glad if u can help me. Thanks in advance
×
×
  • 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.