Jump to content

edgarasm

Members
  • Posts

    39
  • Joined

  • Last visited

Posts posted by edgarasm

  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 :D

    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. 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 

  4. 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'; ?>
    
  5. 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 

     

  6. You need to do a running balance and keep track of the changes as you go. So you'd start with the initial balance and for each row, add the amount to the running balance and save the new running balance.

     

    <?php
    $runningBalance = 0;
    foreach ($transactions as $tran){
        $runningBalance += $tran['amount'];
        
        //Echo all your stuff, echo $runningBalance in the balance column.
    }
    

    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

  7. 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>
    

    dued.png

     

  8.  

     

    UPDATE table

    SET

      

    Col1 = 'val1'

    ,  Col2= 'val2'

    ,  etc

    WHERE ...

    LOL, I didn't even read the query. Shame on me.

    I have updated the query the format you provided me with and it still doesn't update ,starting to worder if the values are getting passed through Post or maybe the ID block doesn't know which id to update :/

  9.  

    Just a side comment. It will help you greatly if you write the code that creates the query in a readable format. The way you have it now makes it extremely difficult to 1) see the whole query and 2) confirm that the all the quote marks are correct since it keeps going in and out of the quoted text. Here is how I would write that in my code:

    $update = "UPDATE users SET
                   (login_email, login_password, confirm, first_name, last_name, address_one,
                    address_two, town_city, county_option, post_code, phone_number)
               VALUES
                   ('{$email}', '{$pass}', '{$confirm}', '{$fname}', '{$lname}', '{$addressone}',
                    '{$addresstwo}', '{$towncity}', '{$countyoption}', '{$postcode}', '{$phone}')
               WHERE id = '{$id}'";

    This fixed the error but the database doesn't update ?

     

    Any ideas?

     

    Thanks for the clear up by the way 

  10. Heres the error :/

     

    Failed Updating Your Data. The SQL was: UPDATE users SET( login_email, login_password, confirm, first_name, last_name, address_one, address_two, town_city, county_option, post_code, phone_number) VALUES("edgarasm@rocketmail.com","b5154b11aa74cf0bf13f957860d614b6","b5154b11aa74cf0bf13f957860d614b6","","Malov","Flat 2 35 Talbot Avenue","Charminster","Bournemouth","Dorset","BH3 7HS","447795192986")WHERE id="""

  11. Hi again ,

     

    Im trying to create  form which allows the users to edit their data , I've created the form ,added the sql i think is right but its not working and giving me sql erro that the data can't be inserted . this is my code for the form details.php :

    <?php include '../header.php'; 
    	  include '../config2.php';
    	
    	session_start();
    	
    	$id = $_POST['ID'];
    	
    	
    ?>
    	<script type="text/javascript" src="js/jquery.js"></script>
    	<script type="text/javascript" src="js/parsley.js"></script>
    	
    	<script>
    		$(document).ready(function() { 
    
        // submit data on click and check if valid 
        $('#sendData').click(function(e) { 
            //check if valid with parsley
            var valid = $('#detailform').parsley ( 'validate' );
            if ( valid === false )
            {
                e.preventDefault();
            }
            else 
            {
                $.post("updateprocess.php", $("#detailform").serialize());       
            }
        });
    }); 
    		</script>
    	<div id="title">
    		<div class="inner">
    			
    			<h1>Changing Your Account Details</h1>
    		</div>
    	</div>	
    	  
    	<div id="content" class="right-sidebar">
    	    
    		<div class="container inner">
    		<div id="main" role="main">
    		<div class="container">
    
    				<h3>Please Choose Which information Your would like to change</h3>
    				
    				<form data-validate="parsley" method="POST" action="updateprocess.php" id="detailform" >
    					<label>Email Address</label>
    					<input type="text" name="login_email" data-required="true" value="<?php echo $account['login_email']; ?>"/>
    					<label>Change a password</label>
    					<input type="password" name="login_password" data-notblank="true"/>
    					<label>Re-enter new password</label>
    					<input type="password" name="confirm" data-notblank="true"/>
    					<label>First Name</label>
    					<input type="text" name="first_name" data-required="true"   value="<?php echo $account['first_name']; ?>" disabled="disabled" />
    					<label>Last Name</label>
    					<input type="text" name="last_name" data-notblank="true" />
    					<label>Address line 1</label>
    					<input type="text" name="address_one" data-required="true" value="<?php echo $account['address_one']; ?>"/>
    					<label>Address line 2</label>
    					<input type="text" name="address_two" data-required="true" value="<?php echo $account['address_two']; ?>"/>
    					<label>Town/City</label>
    					<input type="text" name="town_city" data-required="true" value="<?php echo $account['town_city']; ?>" />
    					<label>County</label>
    					<input type="text" name="county_option" data-required="true" value="<?php echo $account['county_option']; ?>"/>
    					<label>Postcode</label>
    					<input type="text" name="post_code" data-required="true" value="<?php echo $account['post_code']; ?>"/>
    					<label>Phone number</label>
    					<input type="text" name="phone_number" data-required="true" value="<?php echo $account['phone_number']; ?>"/> 
    					<p></p>
    					<p></p>
    					<p></p>
    					<p></p>
    					<p></p>
    					
    					
    					<input type="checkbox" class="checkbox" id="agree" name="agree" /> I Agree With Terms & Conditions</p>
    					
    					<td> <input type="submit" name="submit" class="button" value= "Save"/></td>
    				</form>
    				</div>
    				<div class="space"></div>
    			</div>
    			<ul class="sidebar" role="complementary">
    				<li>
    					<h2>Navigation</h2>
    					<ul class="link-list">
    <li><a href="/account/dashboard.php">Dashboard</a></li>
    <li><a href="/account/transfer.php">Transfer Money</a></li>
    <li><a href="/account/transactions.php">Transactions</a></li>
    <li><a href="/account/withdrawal.php">Withdraw Funds</a></li>
    <li><a href="/account/upload.php">Upload Funds</a></li>
    <li><a href="/account/details.php">Change My details</a></li>
    					</ul>
    				</li>
    			</ul>
    		</div>
    	</div>
    <?php include '../footer.php'; ?>
    

    this is the update.php script

    <?php
    
    include "config2.php";
    
    $id = $_POST['ID'];
    
    $sql="SELECT * FROM users WHERE id='$id'";
    $result=mysql_query($sql);
    
    $id = $_POST['ID'];
    
    $rows=mysql_fetch_array($result);
    
    $email = $_POST['login_email'];
    $pass =  md5($_POST['login_password']);
    $confirm = md5($_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'];
    $update = 'UPDATE users SET( login_email, login_password, confirm, first_name, last_name, address_one, address_two, town_city, county_option, post_code, phone_number) VALUES("'.$email.'","'.$pass.'","'.$confirm.'","'.$fname.'","'.$lname.'","'.$addressone.'","'.$addresstwo.'","'.$towncity.'","'.$countyoption.'","'.$postcode.'","'.$phone.'")WHERE id="'.$id.'""';
    //$insert = 'UPDATE users SET login_email="'.$email.'", login_password="'.$pass.'", confirm="'.$confirm.'", first_name="'.$fname.'", last_name="'.$lname.'", address_one="'.$addressone.'", address_two="'.$addresstwo.'", town_city="'.$towncity.'", county_option="'.$countyoption.'", post_code="'.$postcode.'", phone_number="'.$phone.'" WHERE id="'.$id.'""'; 
    mysql_query($update) or die("Failed Updating Your Data,check SQL");
    
       header( 'Location: ../account/success.php' ) ;
    
    ?>
    
  12. How would i be able to upload the current balance using a upload funds form ,then it updates it to the database as a transaction ,displays it as recent transactions and updates the balance with the amount inputted 

     

    Thanks 

  13. Hi php freaks 

     

    another question I've got 

     

     

    Im trying to make a upload page ,so basically when for example the user inputs his credit card details and amount of funds they want to upload ,the current balance of theirs updates and it appears under their recent transactions details 

     

    My code for dashboard ,upload page and upload process below .Please help me out fellow friends or at least lead me into the right direction 

     

     

    Dashboard.php

    <?php include '../header.php'; ?>
    
    	<div id="title">
    		<div class="inner">
    			<ol class="breadcrumb">
    			</ol>
    			<h1>My Account - Dashboard</h1>
    		</div>
    	</div>
    
    	<div id="content" class="right-sidebar">
    		<div class="inner">
    			<div id="main" role="main">
    				
    				<div class="container">
    					<table class="table" style="width: 50%">
    						<tr>
    							<th>Account Name</th> 
    							<td><?php echo $account['first_name'] . " " . $account['last_name']; ?></td>
    						</tr>
    						<tr>
    							<th>Balance</th> 
    							<td>£ <?php echo number_format($account['balance'], 2); ?></td>
    							
    						</tr>
    						<tr>
    							<th>Account Type</th> 
    							<td>Verified <img src="/assets/images/right.jpg" alt="" /></td>
    							
    						</tr>
    						
    					</table>
    				</div>
    				
    				<div class="space"></div>
    				
    				<?php 
    				
    				$results = mysql_query("SELECT 
    											T.`date`, 
    											CONCAT(A.first_name, ' ', A.`last_name`) AS `from`, 
    											CONCAT(AA.first_name, ' ', AA.`last_name`) AS `to`, 
    											T.`amount`, 
    											T.`from_id`, 
    											T.`account_id` 
    										FROM `transactions` T 
    										JOIN `users` A ON (T.`from_id` = A.`id`) 
    										JOIN `users` AA ON (T.`account_id` = AA.`id`) 
    										
    										WHERE 
    											(T.`account_id` = '" . $_SESSION['account_id'] . "' || T.`from_id` = '" . $_SESSION['account_id'] . "') 
    											
    										ORDER BY T.`id` 
    										
    										DESC LIMIT 5") OR die(mysql_error());
    				
    				?>
    				
    				<div class="container">
    					<h2>Recent Transactions</h2>
    					<table class="table">
    						<tr>
    							<th>Type</th>
    							<th>Date</th>
    							<th>Name</th>
    							<th>Amount</th>
    							<th>Balance</th>
    						</tr>
    						<?php if(mysql_num_rows($results) == 0){ ?>
    							<tr>
    								<td colspan="4">No recent transactions</td>
    							</tr>
    						
    						<?php } else { ?>
    							
    							<?php while($row = mysql_fetch_array($results)){ ?>
    							<tr>
    								<td><?php echo ($row['from_id'] == $_SESSION['account_id'] ? "Sent" : "Received"); ?></td>
    								<td><?php echo $row['date']; ?></td>
    								<td><?php echo ($row['from_id'] == $_SESSION['account_id'] ? $row['to'] : $row['from']); ?></td>
    								<?php
    $amount = $row['amount'];
    
    if($row['from_id'] == $_SESSION['account_id']) {
        $amount = '<span style="color: red"> -' . $amount . '</span>';   //sent 
    } else {
        $amount = '<span style="color: green"> +' . $amount . '</span>'; // received
    }
    ?>
    <td>£ <?php echo $amount ?></td>
    								<td>£ <?php echo number_format ($account['balance'], 2); ?></td>
    							</tr>
    							<?php } ?>
    							
    						<?php } ?>
    					</table>
    					<?php if(mysql_num_rows($results) > 5){ ?>
    					<div style="margin-top: 10px;"><a href="/account/transactions.php">My Transactions</a></div>
    					<?php } ?>
    				</div>
    				
    				<div class="space"></div>
    			</div>
    			<ul class="sidebar" role="complementary">
    				<li>
    					<h2>Navigation</h2>
    					<ul class="link-list">
    						<li><a href="/account/dashboard.php">Dashboard</a></li>
    						<li><a href="/account/transfer.php">Transfer Money</a></li>
    						<li><a href="/account/transactions.php">Transactions</a></li>
    						<li><a href="/account/withdrawal.php">Withdraw Funds</a></li>
    						<li><a href="/account/upload.php">Upload Funds</a></li>
    						<li><a href="/account/details.php">Change My details</a></li>
    					</ul>
    				</li>
    			</ul>
    		</div>
    	</div>
    <?php include '../footer.php'; ?>
    

    upload .php

    <?php include '../header.php'; ?>
    <?php include '../config2.php'; ?>
    
    	<script type="text/javascript" src="js/jquery.js"></script>
    	<script type="text/javascript" src="js/parsley.js"></script>
    	<script>
    		$(document).ready(function() { 
    
        // submit data on click and check if valid 
        $('#sendData').click(function(e) { 
            //check if valid with parsley
            var valid = $('#registrationform').parsley ( 'validate' );
            if ( valid === false )
            {
                e.preventDefault();
            }
            else 
            {
                $.post("uploadprocess.php", $("#uploadform").serialize());       
            }
        });
    }); 
    		
    		
    		</script>
    	<div id="title">
    		<div class="inner">
    			
    			<h1>Upload Funds</h1>
    		</div>
    	</div>	
    	  
    	<div id="content" class="right-sidebar">
    	    <script type="text/javascript" src="js/jquery-1.5.2.min.js"></script>
    		<script type="text/javascript" src="js/jquery.validate.min.js"></script>
    		<script type="text/javascript" src="js/additional-methods.min.js"></script>
    	<div class="container inner">
    	<div id="main" role="main">
    		<div class="container">
    					<h3>Please enter your card details followed by amount you want to upload </h3>
    				
    				<form method="POST" action="uploadprocess.php" id="uploadform">
    					<label>Card Type</label>
    					<select>
      <option value="Select">Choose Card Type</option>
       <option value="VISA">Visa</option>
       <option value="VDEBIT">Visa Debit</option>
       <option value="CREVISA">Visa Credit </option>
       <option value="EVISA">Visa Electron</option>
       <option value="MASTERCARD">Mastercard</option>
       <option value="MAESTRO">Maestro</option>
       <option value="AMEX">American Express</option>
       
       
     </select> 
     
     <p></p>
    					<label>Cardholders Name</label>
    					<input type="text" name="card_holder" id="card_holder"  maxlength="30" data-required="true" placeholder="Cardholders Name"/>
    					<label>Card Number</label>
    					<input type="text" name="card_number" id="card_number" maxlength="16" data-required="true" placeholder="Card Number"/>
    					<label>Account Number </label>
    					<input type="text" name="account_number" id="account_number" maxlength="8" data-required="true" placeholder="Account Number" />
    					<label>Sort Code </label>
    					<input type="text" name="sort_code" id="sort_code" maxlength="8" data-required="true" placeholder="Sort Code"/>
    					<label>Valid From </label>
    					<input type="text" name="valid_from" id="valid_from" maxlength="7"data-required="true" data-type="dateIso" placeholder=" DD/YYYY"/>
    					<label>Expiry Date </label>
    					<input type="text" name="expiry_date" id="expiry_date" maxlength="7" data-required="true" data-type="dateIso" placeholder=" DD/YYYY"/>
    					<label>CV2 Number </label>
    					<input type="text" name="security_number" id="security_number" maxlength="3" CV2 Number placeholder=" 123"/>
    					<i class="icon-"></i>
    					<label>Amount </label>
    					<input type="text" name="upload_amount" id="upload_amount" data-required="true" placeholder="Amount"/>
    					<p></p>
    					
    				<td><input type="submit" name="submit" id="upload_submit" class="button" value= "Upload"/></td>
    				<?php
    				if(isset($_POST['upload_submit'])){
    				
    				mysql_query("UPDATE users SET balance = (balance + ". $_POST['upload_amount'] .") WHERE id = '". $_SESSION['account_id']){ ."'");
    				}
    				?>
    				</form>
    				</div>
    				<div class="space"></div>
    			</div>
    			<ul class="sidebar" role="complementary">
    				<li>
    					<h2>Navigation</h2>
    					<ul class="link-list">
    						<li><a href="/account/dashboard.php">Dashboard</a></li>
    						<li><a href="/account/transfer.php">Transfer Money</a></li>
    						<li><a href="/account/transactions.php">Transactions</a></li>
    						<li><a href="/account/withdrawal.php">Withdraw Funds</a></li>
    						<li><a href="/account/upload.php">Upload Funds</a></li>
    						<li><a href="/account/details.php">Change My details</a></li>
    					</ul>
    				</li>
    			</ul>
    		</div>
    	</div>
    <?php include '../footer.php'; ?>
    

    uploadprocess.php

    <?php
    	 include '../account/header.php';
    	 include '../account/config2.php';
    	 
    	 
    	 
    /*
     * BEGIN CONFIG
     */
     
    // The page you want the user to be redirected if there are no errors.
    $thankYouPage = '/success.php';
     
    // Define which values we are to accept from the form. If you add additional
    // fields to the form, make sure to add the form name values here.
    $allowedFields = array(
        'card_holder',
    	'card_number',
    	'account_number',
    	'sort_code',
        'valid_from',
    	'expiry_date',
    	'security_number',
    	'upload_amount',
    	
    );
     
    // Specify the required form fields. The key is the field name and the value
    // is the error message to display.
    $requiredFields = array(
      	'card_holder'=> '*Please Enter name Displayed On The Card .',
    	'card_number'=> '*Please Check Card Number.',
    	'account_number'=> '*Please Check Account Number.',
    	'sort_code'=> '*Please Check Sort Code.',
        'valid_from'=> '*Please Check Valid From Date.',
    	'expiry_date'=> '*Please Check Expiry Date.',
    	'security_number'=> '*Please Check Last 3 Digits On Reverse Side Of your Card .',
    	'upload_amount'=> '*Please Enter Upload Amount.',
    );
     
    // Note: Since we are requiring two topics to be checked if they want to receive
    // our newsletter, we need to implement custom code.
     
    /*
     * END CONFIG
     */
     
     
    /*
     * Since we are doing javascript error checking on the form before the form gets submitted,
     * the server side check is only a backup if the user has javascript disabled. Since this
     * is unlikely, we are displaying the server side errors on a separate page of the form.
     *
     * The more practical purpose of server side checking (in this case) is to prevent hackers from exploiting
     * your PHP processing code.
     */
     
     
    /*
     * BEGIN FORM VALIDATION
     */
     
    $errors = array();
     
    // We need to loop through the required variables to make sure they were posted with the form.
    foreach($requiredFields as $fieldname => $errorMsg)
    {
        if(empty($_POST[$fieldname]))
        {
            $errors[] = $errorMsg;
        }
    }
     
    // Loop through the $_POST array, to create the PHP variables from our form.
    foreach($_POST AS $key => $value)
    {
        // Is this an allowed field? This is a security measure.
        if(in_array($key, $allowedFields))
        {
            ${$key} = $value;
        }
    }
     
     
    /*
     * END FORM VALIDATION
     */
     
     
    // Were there any errors?
    if(count($errors) > 0)
    {
        $errorString.= '<ul>';
        foreach($errors as $error)
        {
            $errorString.= "<li>$error</li>";
        }
        $errorString.= '</ul>';
      
        // display the errors on the page
        ?>
        <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 Uplaod Request</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="upload.php" class="button">Go Back to the Form</a></p>
        </body>
    	</div>
    	</div>
        </html>
        <?php
    }
    else
    {
    $chold = $_POST['card_holder'];
    $cnumb =  md5($_POST['card_number']);
    $anumb = md5($_POST['account_number']);
    $scode = $_POST['sort_code'];
    $valfrom = $_POST['valid_from'];
    $valto = $_POST['expiry_date'];
    $upamount = $_POST['upload_amount'];
    $insert = 'INSERT into uploads( card_holder, card_number, account_number, sort_code, valid_from, expiry_date, upload_amount) VALUES("'.$chold.'","'.$cnumb.'","'.$anumb.'","'.$scode.'","'.$valfrom.'","'.$valto.'","'.$upamount.'")';
    $update = 'UPDATE users SET balance = (balance + ". $_POST['upload_amount'] .") WHERE id = '". $_SESSION['account_id']){ ."'")';
    
    mysql_query($insert) or die("Failed Inserting your data");
    				
    header( 'Location: ../account/uploadsuccess.php' ) ;
    }
    
    include '../footer.php'; ?>
    
    
×
×
  • 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.