Monday, April 8, 2013

I have create a file index.php


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="jquery.js" type="text/javascript"></script>
<script src="ajaxupload.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
var thumb = $('#thumb');
new AjaxUpload('imageUpload', {
action: $('form#newHotnessForm').attr('action'),
name: 'image',
onSubmit: function(file, extension) {
$('div.preview').addClass('loading');
},
onComplete: function(file, response) {
thumb.load(function(){
$('div.preview').removeClass('loading');
thumb.unbind();
});

thumb.attr('src', response);
}
});
});
</script>
<style>
span.wrap { padding: 10px; }
span.wrap.hotness { margin-left: 30px; }
span.wrap.old-and-busted { width: 358px; }
span.wrap button { display: block; margin-top: 10px; }
span.wrap label { margin-bottom: 5px; }
div.preview { float: left; width: 100px; height: 100px; border: 2px dotted #CCCCCC; }
div.preview.loading { background: url(/playground/images/loading.gif) no-repeat 39px 40px; }
div.preview.loading img {display: none; }
div.highlight { margin-bottom: 20px; }
span.wrap form { margin: 0; }
</style>
</head>
<body>
<div class="seven columns">
<div class="preview"> <img width="100px" height="100px" src="" id="thumb"> </div>
<span class="wrap hotness">
<form action="save.php" id="newHotnessForm" enctype="multipart/form-data">
<label>Upload a Picture of Yourself</label>
<input type="file" size="20" id="imageUpload" class="">
<button class="button" type="submit">Save</button>
</form>
</span>
</div>

</body>
</html>

Now i have create save.php


if(isset($_FILES["image"]["name"]))
    move_uploaded_file($_FILES["image"]["tmp_name"],  $_FILES["image"]["name"]);
    echo $_FILES["image"]["name"];
?>

Monday, September 20, 2010

Paypal Intregration

Next we create the form. When I first made this form I used the Buy-It-Now button form generator on PayPal and then modified accordingly, but you can just use the code below and make the changes I’ve described further on:



<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="payPalForm">
<input type="hidden" name="item_number" value="01 - General Payment to FreelanceSwitch.com">

<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="no_note" value="1">

<input type="hidden" name="business" value="your@paypalaccount.com">

<input type="hidden" name="currency_code" value="USD">

<input type="hidden" name="return" value="http://freelanceswitch.com/payment-complete/">




Item Details:<input name="item_name" type="text" id="item_name" size="45">

Amount: <input name="amount" type="text" id="amount" size="45">


<input type="submit" name="Submit" value="Submit">
</form>



or




<form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="paypal">
<input type="hidden" name="business" value="engmp06@gmail.com"> --> site woner email address provided by client

<input type="hidden" name="cart_order_id" value="">

<input type="hidden" name="payer_email" value="">

<input type="hidden" name="item_name" value="Payment for Findachiro registration">

<input type="hidden" name="amount" value="1"> --> amount to be pay

<input type="hidden" name="payment_gross" value="">

<input type="hidden" name="custom" value="" />

<input type="hidden" name="cmd" value="_xclick">

<input type="hidden" name="first_name" value="">

<input type="hidden" name="address1" value="">

<input type="hidden" name="city" value="">

<input type="hidden" name="state" value="">

<input type="hidden" name="zip" value="">

<input type="hidden" name="currency_code" value="USD"> --> currency code

<input type="hidden" name="cn" value="How Did You Hear About Us?">

<input type="hidden" name="add" value="1">

<input type="hidden" name="upload" value="1" />

<input type="hidden" name="hear_abt" value="">

<input type="hidden" name="comments" value="">

<input type="hidden" name="return" value="http://<?=$_SERVER['HTTP_HOST']?><?php echo $this->webroot;?>businesses/paypal/success/<?=base64_encode($id)?>"> --> for returning success page after transaction

<input type="hidden" name="cancel_return" value="http://<?=$_SERVER['HTTP_HOST']?><?php echo $this->webroot;?>businesses/paypal/cancel/<?=base64_encode($id)?>"> --> for returning failure page after transaction

<input type="hidden" name="notify_url" value="http://<?=$_SERVER['HTTP_HOST']?><?php echo $this->webroot;?>businesses/paypal/ipn/<?=base64_encode($id)?>"> --> call paypal this path to update database

</form>

<script language="javascript">document.paypal.submit();</script>





The parts that need modification are as follows:


Item Number

The item number field is this one:


<input type="hidden" name="item_number" value="01 - General Payment to FreelanceSwitch.com">


The value you place in this field appears when the user goes to PayPal and clicks the down arrow for more details on their purchase (you can see it by entering some information in the test form below). I’ve used the value “01 – General Payment to FreelanceSwitch.com” and theoretically if I had some other forms for say donation I might write “02 – Donation” and so on.


Business

The business field is this one:


<input type="hidden" name="business" value="accounts@freelanceswitch.com">


This is the most important field to modify as it is the one that determines where your customer is paying to. You need to substitute in your PayPal email address. So for FreelanceSwitch, our PayPal address is accounts [@] freelanceswitch.com, but obviously you’ll want to change that (though please feel free to send payment our way if you want to!)


Currency Code

The currency code value in my example form is set to USD, you could change this to your own currency (Cyan and I used to use AUD for Australian Dollars). If you want a list of the different currencies available through PayPal you should log in to your account, click on Merchant Tools then click on Buy Now Buttons and in the form there is a drop down box which lists them.


Return URL


The return URL (or payment confirmation page) is set by this field:


<input type="hidden" name="return" value="http://freelanceswitch.com/payment-complete/">


Simply swap in the URL you created in Step 1.


Item Name

The item_name field is the one where your user describes what they are paying for. When billing clients I set up my form to have “Invoice Number” and in the invoices we sent out under “How to Pay” it explained that you had to get the invoice number from the top right of the bill and type it into the form. In my example form below, I’ve written simply Item Details, so theoretically you could write anything in there – e.g. “Payment for Providing Amazing Freelancing Website, Thanks” and that will appear in PayPal when you go to purchase.


Note that if this were a Buy-Now button form, then the item_name would be a Hidden field with a default


value, but we’ve changed it to a text field so the user can decide what they are paying for.


Amount

The amount field is pretty self explanatory. The only thing to note is that if the user types anything other than a number in here PayPal will return an error, so you might want to use some Javascript to do validation on this field and ensure it’s a number – though that’s not necessary. The main problem is your users might be tempted to write in a dollar sign – e.g. “$450? which results in an error. Another solution would be to write a $ sign before the form field.

Thursday, February 25, 2010