Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

php and Excel

Featured Replies

Hi,

 

I am using paypal, and what I want to achieve is:

When an order is made I want the website to produce an excel file precisely (with the order details) and send it to an ftp server on order entry.

 

How can I achieve that I know it will be an easy process using php, but the problem I am new with php.

 

I will appreciate any help.

 

 

Youssef

  • Author

OK I got to a place where it create an excel file in a folder and then I am having trouble in sending that excel file into an email, here is the code:

 

 

<?php

// read the post from PayPal system and add 'cmd'

$req = 'cmd=_notify-validate';

foreach ($_POST as $key => $value) {

$value = urlencode(stripslashes($value));

$req .= "&$key=$value";

}

// post back to PayPal system to validate

$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";

$header .= "Content-Type: application/x-www-form-urlencoded\r\n";

$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";

 

// If testing on Sandbox use:

//$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);

 

// If testing on paypal use:

$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

 

 

// assign posted variables to local variables

$item_name = $_POST['item_name'];

$business = $_POST['business'];

$item_number = $_POST['item_number'];

$payment_status = $_POST['payment_status'];

$mc_gross = $_POST['mc_gross'];

$payment_currency = $_POST['mc_currency'];

$txn_id = $_POST['txn_id'];

$receiver_email = $_POST['receiver_email'];

$receiver_id = $_POST['receiver_id'];

$quantity = $_POST['quantity'];

$num_cart_items = $_POST['num_cart_items'];

$payment_date = $_POST['payment_date'];

$first_name = $_POST['first_name'];

$last_name = $_POST['last_name'];

$payment_type = $_POST['payment_type'];

$payment_gross = $_POST['payment_gross'];

$payment_fee = $_POST['payment_fee'];

$settle_amount = $_POST['settle_amount'];

$memo = $_POST['memo'];

$payer_email = $_POST['payer_email'];

$txn_type = $_POST['txn_type'];

$payer_status = $_POST['payer_status'];

$address_street = $_POST['address_street'];

$address_city = $_POST['address_city'];

$address_state = $_POST['address_state'];

$address_zip = $_POST['address_zip'];

$address_country = $_POST['address_country'];

$address_status = $_POST['address_status'];

$item_number = $_POST['item_number'];

$tax = $_POST['tax'];

$option_name1 = $_POST['option_name1'];

$option_selection1 = $_POST['option_selection1'];

$option_name2 = $_POST['option_name2'];

$option_selection2 = $_POST['option_selection2'];

$for_auction = $_POST['for_auction'];

$invoice = $_POST['invoice'];

$custom = $_POST['custom'];

$notify_version = $_POST['notify_version'];

$verify_sign = $_POST['verify_sign'];

$payer_business_name = $_POST['payer_business_name'];

$payer_id =$_POST['payer_id'];

$mc_currency = $_POST['mc_currency'];

$mc_fee = $_POST['mc_fee'];

$exchange_rate = $_POST['exchange_rate'];

$settle_currency = $_POST['settle_currency'];

$parent_txn_id = $_POST['parent_txn_id'];

$pending_reason = $_POST['pending_reason'];

$reason_code = $_POST['reason_code'];

 

 

// subscription specific vars

 

$subscr_id = $_POST['subscr_id'];

$subscr_date = $_POST['subscr_date'];

$subscr_effective = $_POST['subscr_effective'];

$period1 = $_POST['period1'];

$period2 = $_POST['period2'];

$period3 = $_POST['period3'];

$amount1 = $_POST['amount1'];

$amount2 = $_POST['amount2'];

$amount3 = $_POST['amount3'];

$mc_amount1 = $_POST['mc_amount1'];

$mc_amount2 = $_POST['mc_amount2'];

$mc_amount3 = $_POST['mcamount3'];

$recurring = $_POST['recurring'];

$reattempt = $_POST['reattempt'];

$retry_at = $_POST['retry_at'];

$recur_times = $_POST['recur_times'];

$username = $_POST['username'];

$password = $_POST['password'];

 

//auction specific vars

 

$for_auction = $_POST['for_auction'];

$auction_closing_date = $_POST['auction_closing_date'];

$auction_multi_item = $_POST['auction_multi_item'];

$auction_buyer_id = $_POST['auction_buyer_id'];

 

 

 

 

include("excelwriter.inc.php");

$fileName = "xsl/working.xls";

$excel = new ExcelWriter($fileName);

 

if($excel==false)

{

echo $excel->error;

die;

}

$myArr=array(

"<b>Item Name</b>",

"First Name",

"Last Name",

"ZIP"

);

 

$excel->writeLine($myArr, array('text-align'=>'center', 'color'=> 'red'));

 

$myArr=array( $item_name , $first_name ,"<span style='color:blue;'>" . $last_name . "</span>", $address_zip);

$excel->writeLine($myArr);

 

/* emailing the excel */

$file='xsl/working.xls';

$headers = "MIME-Version: 1.0\n";

$headers .= "Content-type: application/vnd.ms-excel; charset=iso-8859-1\n";

$headers .= "From: $business\n";

$header .= "Content-Disposition: attachment; filename=\"".$file."\"\r\n\r\n";

@mail("info@siblinis.com", 'AB-MXR', "hello is it working ", $headers);

 

/* emailing the excel end */

 

$excel->close();

/* @mail("siblini@hotmail.co.uk", 'AB-MXR', $email_message , $headers);*/

?>

 

 

Some thing is wrong in the attachment file, no idea what it is.

 

Youssef

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.