Jump to content

Upload funds help


edgarasm

Recommended Posts

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'; ?>

Link to comment
Share on other sites

without a specific question (one at a time) or a statement of what sort of problem or error you are having with your code, it's not directly possible to help you.

 

just posting what you want to do and dumping 350+ lines of your code on a forum (that we cannot easily run because we don't have your tables or data) doesn't tell use where you are stuck at in doing this, so we have no clue what to help you with.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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