Jump to content

edgarasm

Members
  • Posts

    39
  • Joined

  • Last visited

edgarasm's Achievements

Member

Member (2/5)

0

Reputation

  1. Yes i didn't post the whole controller ,would you like me to do the whole one ? maybe it would of been better in the first place Because at the moment it works for transfers between people ,i need to make it so it displays the uploads and withdrawals work aswell <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Account extends Overview { public function __construct(){ parent::__construct(); !self::isLoggedin() ? redirect("/") : null; } public function index() { $this->data['site']['currentNav'] = "account"; $query = $this->db->query("SELECT C.card_number AS `card_number` FROM `cards` C WHERE C.accountID = '". $this->account_id ."' AND C.status = '1'"); $this->data['cards'] = $query->result(); $query = $this->db->query("SELECT B.account_number AS `account_number`, B.sortcode AS `sortcode` FROM `banks` B WHERE B.accountID = '". $this->account_id ."' AND B.status = '1'"); $this->data['banks'] = $query->result(); $query = $this->db->query("SELECT T.transaction AS `transactionID`, T.timestamp AS `date`, IF(T.to = '". $this->account_id ."', 'Received', 'Sent') AS `type`, CONCAT(A.firstname, ' ', A.lastname) AS `name`, T.amount AS `amount` FROM `transactions` T JOIN `accounts` A ON (A.id = T.from) WHERE (T.to = '". $this->account_id ."' || T.from = '". $this->account_id ."') ORDER BY T.id DESC LIMIT 10"); $this->data['transactions'] = $query->result(); $this->load->view('_template/header', $this->data); $this->load->view('account/index', $this->data); $this->load->view('_template/footer', $this->data); } public function transfer() { $this->data['site']['currentNav'] = "account"; $this->load->view('_template/header', $this->data); $this->load->view('account/transfer', $this->data); $this->load->view('_template/footer', $this->data); } public function transfer_process() { $submit = $this->input->post("submit"); if(empty($submit)) { redirect("/index.php/account/transfer"); } $this->load->library('form_validation'); $this->form_validation->set_rules('email', 'email', 'required'); $this->form_validation->set_rules('amount', 'amount', 'required'); $this->form_validation->set_rules('description', 'description', 'required'); $this->data['post']['email'] = $this->input->post("email"); $this->data['post']['amount'] = $this->input->post("amount"); $this->data['post']['description'] = $this->input->post("description"); if ($this->form_validation->run() == FALSE) { $this->data['post']['error_message'] = "<a href=\"#\" class=\"notification error\">". validation_errors() ."</a>"; self::transfer(); } else { $query = $this->db->query("SELECT A.`id` FROM `accounts` A WHERE A.email = '". $this->input->post("email") ."'"); $results = $query->row(); $transaction = $this->generateRandomString(32); $amount = $this->input->post("amount"); $accountType = $this->data['account']->accountType; $fees = $this->calculateFees('Transfer', $accountType, $amount); $fees = $fees->fees; $fees = ($amount * ($fees / 100)); $final = ($amount - $fees); if($final > $this->data['account']->amount){ $this->data['post']['error_message'] = "<a href=\"#\" class=\"notification error\">You do not have enough funds to complete this transaction.</a>"; self::transfer(); } elseif($query->num_rows() == 0) { $this->data['post']['error_message'] = "<a href=\"#\" class=\"notification error\">The email address does not exist. Please check before continuing.</a>"; self::transfer(); } else { $data = array( 'transaction' => "TP_" . $transaction, 'amount' => $amount, 'to' => $results->id, 'from' => $this->account_id, 'status' => 1 ); $this->db->insert('transactions', $data); $this->db->query("UPDATE accounts SET amount = (amount - ". $amount .") WHERE id = '". $this->account_id ."'"); $this->db->query("UPDATE accounts SET amount = (amount + ". $final .") WHERE id = '". $results->id ."'"); $this->data['post']['error_message'] = "<a href=\"#\" class=\"notification success\">You have successfully sent " . number_format($amount, 2) . "</b>)</a>"; $this->data['post']['email'] = ""; $this->data['post']['amount'] = ""; $this->data['post']['description'] = ""; self::transfer(); } } } public function transactions() { $this->data['site']['currentNav'] = "account"; $query = $this->db->query("SELECT T.transaction AS `transactionID`, T.timestamp AS `date`, IF(T.to = '". $this->account_id ."', 'Received', 'Sent') AS `type`, CONCAT(A.firstname, ' ', A.lastname) AS `name`, T.amount AS `amount` FROM `transactions` T JOIN `accounts` A ON (A.id = T.from) WHERE (T.to = '". $this->account_id ."' || T.from = '". $this->account_id ."') ORDER BY T.id DESC"); $this->data['transactions'] = $query->result(); $this->load->view('_template/header', $this->data); $this->load->view('account/transactions', $this->data); $this->load->view('_template/footer', $this->data); } public function withdrawal() { $submit = $this->input->post("submit"); $bank = $this->input->post("bank"); $amount = $this->input->post("amount"); $this->data['post']['bank'] = $bank; $this->data['post']['amount'] = $amount; if($submit) { if(empty($bank)) { $this->data['post']['error_message'] = "<a href=\"#\" class=\"notification error\">Please select a bank account.</a>"; } elseif(empty($amount)) { $this->data['post']['error_message'] = "<a href=\"#\" class=\"notification error\">Please enter an amount to withdraw.</a>"; } elseif($amount > $this->data['account']->amount) { $this->data['post']['error_message'] = "<a href=\"#\" class=\"notification error\">You do not have enough funds to complete this withdrawal.</a>"; } else { $accountType = $this->data['account']->accountType; $fees = $this->calculateFees('Withdrawal', $accountType, $amount); $fees = $fees->fees; $fees = ($amount * ($fees / 100)); $final = ($amount + $fees); $this->db->query("INSERT INTO withdrawal_transactions (accountID, amount, bankID, status) VALUES ('". $this->account_id ."', '". $amount ."', '". $bank ."', '1')"); $this->db->query("UPDATE accounts SET amount = (amount - ". $final .") WHERE id = '". $this->account_id ."'"); $this->data['post']['error_message'] = "<a href=\"#\" class=\"notification success\">Your (€". $amount ." + Fees: €". $fees .") withdrawal was successful.</a>"; $this->data['post']['bank'] = ''; $this->data['post']['amount'] = ''; } } $this->data['site']['currentNav'] = "account"; $query = $this->db->query("SELECT B.id AS `id`, B.account_number AS `account_number`, B.sortcode AS `sortcode` FROM `banks` B WHERE B.accountID = '". $this->account_id ."' AND B.status = '1'"); $this->data['banks'] = $query->result(); $this->load->view('_template/header', $this->data); $this->load->view('account/withdrawal', $this->data); $this->load->view('_template/footer', $this->data); } public function upload() { $submit = $this->input->post("submit"); $bank = $this->input->post("bank"); $card = $this->input->post("card"); $amount = $this->input->post("amount"); $this->data['post']['bank'] = $bank; $this->data['post']['card'] = $card; $this->data['post']['amount'] = $amount; if($submit) { if(empty($bank) && empty($card)) { $this->data['post']['error_message'] = "<a href=\"#\" class=\"notification error\">Please select either a bank account or debit/credit card.</a>"; } elseif(!empty($bank) && !empty($card)) { $this->data['post']['error_message'] = "<a href=\"#\" class=\"notification error\">Please only choose one upload method at a time.</a>"; } elseif(empty($amount)) { $this->data['post']['error_message'] = "<a href=\"#\" class=\"notification error\">Please enter an amount to withdraw.</a>"; } else { $accountType = $this->data['account']->accountType; $fees = $this->calculateFees('Withdrawal', $accountType, $amount); $fees = $fees->fees; $fees = ($amount * ($fees / 100)); $final = ($amount - $fees); $this->db->query("INSERT INTO upload_transactions (accountID, amount, bankID, cardID, status) VALUES ('". $this->account_id ."', '". $amount ."', '". $bank ."', '". $card ."', '1')"); $this->db->query("UPDATE accounts SET amount = (amount + ". $final .") WHERE id = '". $this->account_id ."'"); $this->data['post']['error_message'] = "<a href=\"#\" class=\"notification success\">Your (€". $amount ." + Fees: €". $fees .") upload was successful.</a>"; $this->data['post']['bank'] = ''; $this->data['post']['amount'] = ''; $this->data['post']['card'] = ''; } } $this->data['site']['currentNav'] = "account"; $query = $this->db->query("SELECT C.id, C.card_number AS `card_number` FROM `cards` C WHERE C.accountID = '". $this->account_id ."' AND C.status = '1'"); $this->data['cards'] = $query->result(); $query = $this->db->query("SELECT B.id, B.account_number AS `account_number`, B.sortcode AS `sortcode` FROM `banks` B WHERE B.accountID = '". $this->account_id ."' AND B.status = '1'"); $this->data['banks'] = $query->result(); $this->load->view('_template/header', $this->data); $this->load->view('account/upload', $this->data); $this->load->view('_template/footer', $this->data); } public function details() { $submit = $this->input->post("submit"); $this->data['post']['email'] = $this->data['account']->email; $this->data['post']['firstname'] = $this->data['account']->firstname; $this->data['post']['lastname'] = $this->data['account']->lastname; $this->data['post']['address_one'] = $this->data['account']->address_one; $this->data['post']['address_two'] = $this->data['account']->address_two; $this->data['post']['town_city'] = $this->data['account']->town; $this->data['post']['county_option'] = $this->data['account']->county; $this->data['post']['post_code'] = $this->data['account']->postcode; $this->data['post']['phone_number'] = $this->data['account']->phone_number; if($submit){ $this->load->library('form_validation'); $this->form_validation->set_rules('email', 'email', 'required'); $this->form_validation->set_rules('firstname', 'firstname', 'required'); $this->form_validation->set_rules('lastname', 'lastname', 'required'); $this->form_validation->set_rules('address_one', 'address_one', 'required'); $this->form_validation->set_rules('address_two', 'address_two', 'required'); $this->form_validation->set_rules('town_city', 'town', 'required'); $this->form_validation->set_rules('county_option', 'county', 'required'); $this->form_validation->set_rules('post_code', 'postcode', 'required'); $this->form_validation->set_rules('phone_number', 'phone number', 'required'); $this->data['post']['email'] = $this->input->post("email"); $this->data['post']['firstname'] = $this->input->post("firstname"); $this->data['post']['lastname'] = $this->input->post("lastname"); $this->data['post']['address_one'] = $this->input->post("address_one"); $this->data['post']['address_two'] = $this->input->post("address_two"); $this->data['post']['town_city'] = $this->input->post("town_city"); $this->data['post']['county_option'] = $this->input->post("county_option"); $this->data['post']['post_code'] = $this->input->post("post_code"); $this->data['post']['phone_number'] = $this->input->post("phone_number"); $this->data['post']['password'] = $this->input->post("password"); $this->data['post']['confirm'] = $this->input->post("confirm"); if ($this->form_validation->run() == FALSE) { $this->data['post']['error_message'] = "<a href=\"#\" class=\"notification error\">". validation_errors() ."</a>"; } else { if($this->data['post']['password'] != $this->data['post']['confirm']){ $this->data['post']['error_message'] = "<a href=\"#\" class=\"notification error\">Your newly entered passwords do not match.</a>"; } else { $update = array( 'email' => $this->data['post']['email'], 'firstname' => $this->data['post']['firstname'], 'lastname' => $this->data['post']['lastname'], 'address_one' => $this->data['post']['address_one'], 'address_two' => $this->data['post']['address_two'], 'town' => $this->data['post']['town_city'], 'county' => $this->data['post']['county_option'], 'postcode' => $this->data['post']['post_code'], 'phone_number' => $this->data['post']['phone_number'] ); $this->db->where('id', $this->account_id); $this->db->update('accounts', $update); $this->data['post']['error_message'] = "<a href=\"#\" class=\"notification success\">You have changed your details successfully.</a>"; } } } $this->data['site']['currentNav'] = "account"; $this->load->view('_template/header', $this->data); $this->load->view('account/details', $this->data); $this->load->view('_template/footer', $this->data); } public function addcard() { $submit = $this->input->post("submit"); if($submit){ $this->load->library('form_validation'); $this->form_validation->set_rules('card', 'card', 'required'); $this->form_validation->set_rules('expiry', 'expiry', 'required'); $this->form_validation->set_rules('security', 'security', 'required'); $this->data['post']['card'] = $this->input->post("card"); $this->data['post']['expiry'] = $this->input->post("expiry"); $this->data['post']['security'] = $this->input->post("security"); if ($this->form_validation->run() == FALSE) { $this->data['post']['error_message'] = "<a href=\"#\" class=\"notification error\">". validation_errors() ."</a>"; } else { $insert = array( 'accountID' => $this->account_id, 'card_number' => $this->data['post']['card'], 'expiry' => $this->data['post']['expiry'], 'security' => $this->data['post']['security'], 'status' => 1 ); $this->db->insert('cards', $insert); $this->data['post']['card'] = ""; $this->data['post']['expiry'] = ""; $this->data['post']['security'] = ""; $this->data['post']['error_message'] = "<a href=\"#\" class=\"notification success\">You have successfully added a new card.</a>"; } } $this->data['site']['currentNav'] = "account"; $this->load->view('_template/header', $this->data); $this->load->view('account/addcard', $this->data); $this->load->view('_template/footer', $this->data); } public function addbank() { $submit = $this->input->post("submit"); if($submit){ $this->load->library('form_validation'); $this->form_validation->set_rules('account_number', 'account_number', 'required'); $this->form_validation->set_rules('sortcode', 'sortcode', 'required'); $this->data['post']['account_number'] = $this->input->post("account_number"); $this->data['post']['sortcode'] = $this->input->post("sortcode"); if ($this->form_validation->run() == FALSE) { $this->data['post']['error_message'] = "<a href=\"#\" class=\"notification error\">". validation_errors() ."</a>"; } else { $insert = array( 'accountID' => $this->account_id, 'account_number' => $this->data['post']['account_number'], 'sortcode' => $this->data['post']['sortcode'], 'status' => 1 ); $this->db->insert('banks', $insert); $this->data['post']['account_number'] = ""; $this->data['post']['sortcode'] = ""; $this->data['post']['error_message'] = "<a href=\"#\" class=\"notification success\">You have successfully added a new bank account.</a>"; } } $this->data['site']['currentNav'] = "account"; $this->load->view('_template/header', $this->data); $this->load->view('account/addbank', $this->data); $this->load->view('_template/footer', $this->data); } public function paymentmethods() { $this->data['site']['currentNav'] = "account"; $query = $this->db->query("SELECT C.id AS `id`, C.card_number AS `card_number`, C.expiry AS `expiry` FROM `cards` C WHERE C.accountID = '". $this->account_id ."' AND C.status = '1'"); $this->data['cards'] = $query->result(); $query = $this->db->query("SELECT B.id AS `id`, B.account_number AS `account_number`, B.sortcode AS `sortcode` FROM `banks` B WHERE B.accountID = '". $this->account_id ."' AND B.status = '1'"); $this->data['banks'] = $query->result(); $this->load->view('_template/header', $this->data); $this->load->view('account/paymentmethods', $this->data); $this->load->view('_template/footer', $this->data); } public function delcard() { $card_id = $this->uri->segment(3, 0); $update = array( 'status' => 0 ); $this->db->where('id', $card_id); $this->db->update('cards', $update); redirect("/index.php/account/paymentmethods"); } public function delbank() { $card_id = $this->uri->segment(3, 0); $update = array( 'status' => 0 ); $this->db->where('id', $card_id); $this->db->update('banks', $update); redirect("/index.php/account/paymentmethods"); } }
  2. Hello PHP freaks Im trying to display table contents as Uploads or widrawals but would i have to create the functions inside the Widrawals and Uploads in order for it to be displayed in Overview table ? My code for overview table controller so far : By the way I'm using code igniter public function index() { $this->data['site']['currentNav'] = "account"; $query = $this->db->query("SELECT C.card_number AS `card_number` FROM `cards` C WHERE C.accountID = '". $this->account_id ."' AND C.status = '1'"); $this->data['cards'] = $query->result(); $query = $this->db->query("SELECT B.account_number AS `account_number`, B.sortcode AS `sortcode` FROM `banks` B WHERE B.accountID = '". $this->account_id ."' AND B.status = '1'"); $this->data['banks'] = $query->result(); $query = $this->db->query("SELECT T.transaction AS `transactionID`, T.timestamp AS `date`, IF(T.to = '". $this->account_id ."', 'Received', 'Sent') AS `type`, CONCAT(A.firstname, ' ', A.lastname) AS `name`, T.amount AS `amount` FROM `transactions` T JOIN `accounts` A ON (A.id = T.from) WHERE (T.to = '". $this->account_id ."' || T.from = '". $this->account_id ."') ORDER BY T.id DESC LIMIT 10"); $this->data['transactions'] = $query->result(); $this->load->view('_template/header', $this->data); $this->load->view('account/index', $this->data); $this->load->view('_template/footer', $this->data); }
  3. Thanks for your help
  4. Dear PHPFREAKS I was hoping maybe i would be able to get some help here Im thinking on calculating fees and certain percentage of transaction ? Which would be the best way to do so ? so after each withdrawal upload sending funds there would be a specific charge applied plus a percentage ,so lets say i would be sending $20 and the recipient would only receive 17.50 Im using code igniter framework . Any help would be appreciated Thanks
  5. ive removed it but the email doesnt get sent now
  6. So would i have to remove it ? Thanks
  7. Hey there Wanted to ask a question with my SMTP setting not authenticating I get an error like this : PHP Warning: mail(): SMTP server response: 530 SMTP authentication is required. in file.php on line 190 Even tho i provided all the details for the SMTP to authenticate . <?php include '../header.php'; include '../config2.php'; $thankYouPage = '/success.php'; $allowedFields = array( 'login_email', 'login_password', 'confirm', 'first_name', 'last_name', 'address_one', 'address_two', 'town_city', 'county_option', 'post_code', 'phone_number', 'agree', ); $requiredFields = array( 'login_email'=> '*Email address is required.', 'login_password'=> '*Password is required.', 'confirm'=> '*Please confirm your password(required).', 'first_name'=> '*Your First Name is required.', 'last_name'=> '*Your Last Name is required.', 'address_one'=> '*First Line of your address is required.', 'address_two'=> '*Second Line of your address is required.', 'town_city'=> '*Town/City is required.', 'county_option'=> '*County is required.', 'post_code'=> '*Post Code is required.', 'phone_number'=> '*Phone Number is required.', 'agree'=> '*You must agree with our Terms & Conditions .', ); $errors = array(); foreach($requiredFields as $fieldname => $errorMsg) { if(empty($_POST[$fieldname])) { $errors[] = $errorMsg; } } foreach($_POST AS $key => $value) { if(in_array($key, $allowedFields)) { ${$key} = $value; } } if(count($errors) > 0) { $errorString.= '<ul>'; foreach($errors as $error) { $errorString.= "<li>$error</li>"; } $errorString.= '</ul>'; ?> <html> <div id="title"> <div class="inner"> <h1>Account Registration</h1> </div> </div> <div id="content"> <div class="container inner"> </head> <body> <h1>Error Processing Form</h1> <br></br> <h3>Some Information was not Entered,please return to the form and fill it out </h3> <tr></tr> <?php echo $errorString; ?> <p></p> <p><a href="register.php" class="button">Go Back to the Form</a></p> </body> </div> </div> </html> <?php } else { $email = $_POST['login_email']; $pass = SHA1($_POST['login_password']); $confirm = SHA1($_POST['confirm']); $fname = $_POST['first_name']; $lname = $_POST['last_name']; $addressone = $_POST['address_one']; $addresstwo = $_POST['address_two']; $towncity = $_POST['town_city']; $countyoption = $_POST['county_option']; $postcode = $_POST['post_code']; $phone = $_POST['phone_number']; $Activation = md5(uniqid(rand())); $insert = 'INSERT into users( login_email, login_password, confirm, first_name, last_name, address_one, address_two, town_city, county_option, post_code, phone_number, Activation) VALUES("'.$email.'","'.$pass.'","'.$confirm.'","'.$fname.'","'.$lname.'","'.$addressone.'","'.$addresstwo.'","'.$towncity.'","'.$countyoption.'","'.$postcode.'","'.$phone.'","'.$Activation.'")'; $result2 = mysql_query($insert) or die("Failed Inserting your data"); if($result2) { require("class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->SMTPAuth = true; $mail->Host = "smtp.mysettings.com"; // SMTP server $mail->Username = "support@myhost"; // SMTP account username $mail->Password = "password"; // SMTP account password $mail->From = "myhost@myhost.com"; $mail->FromName = "Admin"; $mail->AddAddress($email,$fname." ".$lname); $mail->Subject = "First PHPMailer Message"; $mail->Body = "Hi! \n\n This is my first e-mail sent through PHPMailer."; $mail->WordWrap = 50; if(!$mail->Send()) { echo 'Message was not sent.'; echo 'Mailer error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent.'; } $to = $email; $subject = "Confirmation from Test to $username"; $header = "Test: Account Confirmation from Test"; $message = "Please click the link below to verify and activate your account."; $message .= "http://www.test.com/account/confirm.php?passkey=$activation"; $sentmail = mail($to,$subject,$message,$header); if($sentmail) { echo "Your Confirmation link Has Been Sent To Your Email Address."; } else { echo "Cannot send Confirmation link to your e-mail address"; } } } header( 'Location: /account/success.php' ) ; include '../footer.php'; ?>
  8. The details of credit card and the name but not the security number
  9. Hello I was wondering how could i autofill a form based on a drop down list using raw php and mysql . I know that the connection to database would have to be established but what next ? Any Pointers would be helpful Also check the attached photo to maybe understand more than I'm explaining
  10. My error codes are not working , i declared them as follow if(isset($_POST['login_submit'])){ $query = mysql_query("SELECT id FROM users WHERE login_email = '". $_POST['login_email'] ."'") or die(mysql_error()); $email_check = mysql_num_rows($query); $email_check_data = mysql_fetch_array($query); if(empty($_POST['login_email']) || empty($_POST['login_password'])){ echo "<div class=\"notification warning\"> Please fill in all the fields below </div>"; } elseif($email_check == 0) { echo "<div class=\"notification error\"> Email address or password . Please check your email! </div>"; is there anything wrong ? If the fields are empty or i input no email or password no erros displayed
  11. thanks guys helped me a lot all sorted now
  12. Been trying since yesterday and can't figure it out :/ Mostly i get the error i provided before
  13. The problem is that it always makes the balances different , if I have the top balance different the bottom ones will change as I'm grabbing the top value really frustrates me ugh:(
  14. I have added the code you gave still no luck now the page errors :/ PHP Warning: Invalid argument supplied for foreach() in C:\Inetpub\vhosts\tugapay.com\httpdocs\account\dashboard.php on line 93
  15. Hello I got a question , Im trying to add balance after each transaction ,what I tried to do is to echo $account Balance and then use function to deduct the row amount Im really confused and can't figure it out how i would i achieve such thing : The code I've used <td>£ <?php echo number_format ($account['balance'] + $row['amount'], 2); ?></td>
×
×
  • 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.