7 Online Writing Tips

1. KNOW YOUR AUDIENCE
Write and edit with online readers’ needs and habits in mind. Web usability studies show that readers tend to skim over sites rather than read them intently.
2. WRITE LIVELY AND TIGHT
Writing for the Web should be a cross between broadcast and print tighter and punchier than print, but more literate and detailed than broadcast writing. Write actively, not passively.
Good broadcast writing uses primarily tight, simple declarative sentences and sticks to one idea per sentence. It avoids the long clauses and passive writing of print. Every expressed idea flows logically into the next. Using these concepts in online writing makes the writing easier to understand and better holds readers’ attention.
3. EXPLAIN
Don’t let yourself get caught up in the 24/7 wire-service mentality and think all that matters is that you have the latest news as fast as possible. Speed is important online. But people want to know not just what happened, but why it matters. And with all the information sources out there now, in the end it will be the sites that explain the news the best that succeed. Write and edit all your stories with this in mind.
4. NEVER BURY THE LEAD
You can’t afford to bury the lead online because if you do, few readers will get to it. When writing online, it’s essential to tell the reader quickly what the story is about and why they should keep reading or else they won’t.

5. BREAK IT UP
Larger blocks of text make reading on screens difficult, and you’re more likely to lose readers. Using more subheads and bullets to separate text and ideas helps. Writing should be snappy and fast to read. Keep paragraphs and sentences short. You should be able to read an entire sentence without pausing for a breath.
6. ELIMINATE THE GUESSWORK
People often don’t know what they’re going to get when they click on stuff. And people are not going to click on something unless they know what they’re getting. When they click on something that’s not worth it, they lose trust in you as a source and are less likely to come back and click on things in the future. So make sure you tell people what they’re going to get.
7. DO NOT FEAR THE LINK
Don’t be afraid to link. Many sites have a paranoid fear that if they include links to other sites, readers will surf away and never return. Not true! People prefer to go to sites that do a good job of compiling click-worthy links’ witness Yahoo’s success. If people know they can trust your site, they will come back for more.

How to create Shipment and invoice by code in magento

For automization magento we required auto create a shipment and invoice
therefor i decide to write blog for create shipment and invoice by code so after placing an order it will auto generate invoice and shipment.
Following are the steps for create a shipment and invoice.
step 1: create invoice by code

order_id = "100000042";
//load order by increment id
$order = Mage::getModel("sales/order")->loadByIncrementId($order_id);
try {
	if($order->canInvoice()) {
		//Create invoice with pending status
		$invoiceId = Mage::getModel('sales/order_invoice_api')
			->create($order->getIncrementId(), array());

		$invoice = Mage::getModel('sales/order_invoice')
						->loadByIncrementId($invoiceId);

		//set invoice status "paid"
		$invoice->capture()->save();
	}
}catch (Mage_Core_Exception $e) {
// print_r($e);
}

Step 2: Create Shipment by code

order_id = "100000042";

//load order by increment id
$order = Mage::getModel("sales/order")->loadByIncrementId($order_id);
try {
	if($order->canShip()) {
		//Create shipment
		$shipmentid = Mage::getModel('sales/order_shipment_api')
						->create($order->getIncrementId(), array());
		//Add tracking information
		$ship = Mage::getModel('sales/order_shipment_api')
						->addTrack($order->getIncrementId(), array());		
	}
}catch (Mage_Core_Exception $e) {
// print_r($e);
}

Step3 : Create cron Or setup observer for create auto invoice and shipment

How to create csv (comma-separated values) file using php?

Once I had a requirement to create csv file using php.
For that I used following sample code.
It will create / overwrite test.csv file, write heading row and content rows in csv file.

<?php
// Create csv file and open it for write
	$fname = 'test.csv';
	$fp = fopen($fname, 'w');

// Write heading row in csv file
	$heading_row = array('No', 'Name', 'Address', 'Mobile No');
	fputcsv($fp, $heading_row);


// Make array for csv row content and write it in file
	$content_row1 = array('1', 'ABC', 'Ahmedabad, India.', '9574021650');
	$content_row2 = array('2', 'PQR', 'Anand, India.', '9911546874');
	$content_row3 = array('3', 'XYZ', 'Akola, India.', '9574043210');
	$content_row4 = array('4', 'EFG', 'Delhi, India.', '9574054789');
	$content_row5 = array('5', 'LMN', 'Mumbai, India.', '9685741236');
	
	fputcsv($fp, $content_row1);
	fputcsv($fp, $content_row2);
	fputcsv($fp, $content_row3);
	fputcsv($fp, $content_row4);
	fputcsv($fp, $content_row5);

// Close csv file pointer
	fclose($fp);
?>

Thanks
Hope this will help you….

remove a breadcrumb in cre loaded

for removing breadcrumb you have to find $breadcrumb->trail in catalog/template/your_template_name/main_page.tpl.php

comment out that line


<!--      <table border="0" width="100%" cellspacing="0" cellpadding="0">
        <tr class="headerNavigation">
            <td class="headerNavigation">&nbsp;&nbsp;<?php echo $breadcrumb->trail(' &raquo; '); ?></td> 
        </tr>
      </table>-->


i hope this will help you very much

thanks

How to make zip file using php?

Before some days I had a requirement to make zip file of different files.
To do so I found php “zipfile” class.

Now to use the “zipfile” class and make zip file, follow the under given steps.

Step : 1 : Make “zipfile.php” file and put under given code in it.

class zipfile
{
var $datasec = array();
var $ctrl_dir = array();
var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
var $old_offset = 0;

function add_dir($name) {
$name = str_replace("", "/", $name);

$fr = "\x50\x4b\x03\x04";
$fr .= "\x0a\x00";
$fr .= "\x00\x00";
$fr .= "\x00\x00";
$fr .= "\x00\x00\x00\x00";

$fr .= pack("V",0);
$fr .= pack("V",0);
$fr .= pack("V",0);
$fr .= pack("v", strlen($name) );
$fr .= pack("v", 0 );
$fr .= $name;
$fr .= pack("V", 0);
$fr .= pack("V", 0);
$fr .= pack("V", 0);

$this -> datasec[] = $fr;
$new_offset = strlen(implode("", $this->datasec));

$cdrec = "\x50\x4b\x01\x02";
$cdrec .="\x00\x00";
$cdrec .="\x0a\x00";
$cdrec .="\x00\x00";
$cdrec .="\x00\x00";
$cdrec .="\x00\x00\x00\x00";
$cdrec .= pack("V",0);
$cdrec .= pack("V",0);
$cdrec .= pack("V",0);
$cdrec .= pack("v", strlen($name) );
$cdrec .= pack("v", 0 );
$cdrec .= pack("v", 0 );
$cdrec .= pack("v", 0 );
$cdrec .= pack("v", 0 );
$ext = "\x00\x00\x10\x00";
$ext = "\xff\xff\xff\xff";
$cdrec .= pack("V", 16 );
$cdrec .= pack("V", $this -> old_offset );
$cdrec .= $name;

$this -> ctrl_dir[] = $cdrec;
$this -> old_offset = $new_offset;
return;
}

function add_file($data, $name) {
$fp = fopen($data,"r");
$data = fread($fp,filesize($data));
fclose($fp);
$name = str_replace("", "/", $name);
$unc_len = strlen($data);
$crc = crc32($data);
$zdata = gzcompress($data);
$zdata = substr ($zdata, 2, -4);
$c_len = strlen($zdata);
$fr = "\x50\x4b\x03\x04";
$fr .= "\x14\x00";
$fr .= "\x00\x00";
$fr .= "\x08\x00";
$fr .= "\x00\x00\x00\x00";
$fr .= pack("V",$crc);
$fr .= pack("V",$c_len);
$fr .= pack("V",$unc_len);
$fr .= pack("v", strlen($name) );
$fr .= pack("v", 0 );
$fr .= $name;
$fr .= $zdata;
$fr .= pack("V",$crc);
$fr .= pack("V",$c_len);
$fr .= pack("V",$unc_len);

$this -> datasec[] = $fr;
$new_offset = strlen(implode("", $this->datasec));

$cdrec = "\x50\x4b\x01\x02";
$cdrec .="\x00\x00";
$cdrec .="\x14\x00";
$cdrec .="\x00\x00";
$cdrec .="\x08\x00";
$cdrec .="\x00\x00\x00\x00";
$cdrec .= pack("V",$crc);
$cdrec .= pack("V",$c_len);
$cdrec .= pack("V",$unc_len);
$cdrec .= pack("v", strlen($name) );
$cdrec .= pack("v", 0 );
$cdrec .= pack("v", 0 );
$cdrec .= pack("v", 0 );
$cdrec .= pack("v", 0 );
$cdrec .= pack("V", 32 );
$cdrec .= pack("V", $this -> old_offset );

$this -> old_offset = $new_offset;

$cdrec .= $name;
$this -> ctrl_dir[] = $cdrec;
}

function file() {
$data = implode("", $this -> datasec);
$ctrldir = implode("", $this -> ctrl_dir);

return
$data .
$ctrldir .
$this -> eof_ctrl_dir .
pack("v", sizeof($this -> ctrl_dir)) .
pack("v", sizeof($this -> ctrl_dir)) .
pack("V", strlen($ctrldir)) .
pack("V", strlen($data)) .
"\x00\x00";
}
}

Step : 2 : Include “zipfile.php” file in the code where you want to make a zip file.
For e.g.

include(“zipfile.php”);

Step : 3 : Create an object of zipfile class.
For e.g.

$make_zip = new zipfile();

Step : 4 : Add files in the object for which you need to make a zip file.
For e.g.

$make_zip->add_file(“filepath/filename1”, “filename1”);
$make_zip->add_file(“filepath/filename2”, “filename2”);

Step : 5 : Make and write zip file.
For e.g.

$zipfilename = "zipfilepath/zipfilename.zip";  // Stores zip file path and name
$fp = fopen ($filename, "wb");  // Make zip file and open file pointer
$out = fwrite ($fp, $make_zip -> file());  // Write zip file with added files.
fclose ($fp);  // Close file pointer.

After following and executing above steps your zip file has been created at the given path with given name.
And it also includes your added files in it.

Hope this will help you….

Posted in PHP. 1 Comment »

Upload file on ftp server with cURL and php

cURL is a computer software project providing a library and command-line tool for transferring data using various protocols.
With a cURL we can upload and download file on FTP server.

Code snippet given here:
For upload a file

		const REMOTE_FTP = 'ftp:/somename.com/';//give your ftp url here
    	const REMOTE_USER = 'user';//give your username here
		const REMOTE_PASSWORD = 'pass'; //give your password here 
		
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL,REMOTE_FTP."/path/to/direcoty"); //give path if u want to access sub directory
		curl_setopt($ch, CURLOPT_USERPWD, REMOTE_USER.":".REMOTE_PASSWORD);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_FTPLISTONLY,true);
		$result = curl_exec ($ch);
		print_r($result);//display file list from directory
		
		foreach($result as $file){
			curl_setopt($ch, CURLOPT_URL,REMOTE_FTP."/path/to/direcoty/".$file);//access file on ftp with full file path
			curl_setopt($ch, CURLOPT_USERPWD, REMOTE_USER.":".REMOTE_PASSWORD);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
			$result = curl_exec ($ch);
			print_r($result);//display file result
			//if you want to write in local
			$fp = fopen("filename.txt", "w");
			fwrite($fp, $result);	
			fclose($fp);
		}
				
		if(!curl_errno($ch)){
			$info = curl_getinfo($ch);		
			print_r($info);
		} else {
			echo 'Curl error: ' . curl_error($ch);	
		}
		
Posted in PHP. 1 Comment »

How to put Javascript and php validation for Credit card?

Step 1: First create creditcard.php file and use the below code.

<?php
include("creditcard_valid.php");
if(isset($_POST['submit']))
{
  $credit_card_cc_owner = $_POST['credit_card_cc_owner'];
  $cardnumber = $_POST['credit_card_cc_number'];
  $cardname = $_POST['credit_card_type'];
  $cardcvv = $_POST['credit_card_cvv'];
  $card_cc_expires_month = $_POST['credit_card_cc_expires_month'];
  $card_cc_expires_year = $_POST['credit_card_cc_expires_year'];
  $error=false;
  if (strlen($credit_card_cc_owner) < 3)
  {
    $error = true;
    $Errormessage.="The Owner\'s name of the credit card must be at least 3 characters.
";
  }
  if (strlen($cardnumber) < 13)
  {
      $error = true;
      $Errormessage.="The Credit Card number must be at least 13 characters.
";
  }
  if (strlen($credit_card_cvv) < 3)   {       $error = true;       $Errormessage.="The Credit Card cvv number must be at least 3 characters. ";   }   if(!tep_validateCC($cardnumber,$cardname))   {       $error = true;       $Errormessage.="Please make sure that you entered a valid Credit Card Number. ";   }   if(!tep_CheckCVV($cardnumber,$cardcvv))   {       $error = true;       $Errormessage.="Please make sure that you entered valid CVV Number. ";  }  if(!tep_CheckCreditCardExpirationDate($card_cc_expires_month,$card_cc_expires_year))  {       $error = true;       $Errormessage.="Please Select Valid Date";  }  if($error==false)  	$Successmessage="Your Credit card is valid"; } ?>
Credit Card Validation Java+PHP Example
<script type="text/javascript" language="javascript" src="creditcard.js"></script></pre>
<form action="" method="post" name="creditcard" onsubmit="return check_form(creditcard);">
<table width="30%" border="0" cellspacing="0" cellpadding="2" align="center">
<tbody>
<tr>
<td colspan="2"><?php if($error==1) { echo '<span style="color: #ff0000;">'.$Errormessage.'</span>';
 } else { echo '<span style="color: #76c776;">'.$Successmessage.'</span>';} ?></td>
</tr>
<tr>
<td class="main" width="180">Credit Card Owner:</td>
<td class="main"><input type="text" name="credit_card_cc_owner" /></td>
</tr>
<tr>
<td class="main" width="180">Credit Card Type:</td>
<td class="main"><select name="credit_card_type"><option value="Amex">Amex</option><option value="Mastercard">Mastercard</option><option value="Visa">Visa</option></select></td>
</tr>
<tr>
<td class="main" width="180">Credit Card Number:</td>
<td class="main"><input type="text" name="credit_card_cc_number" /></td>
</tr>
<tr>
<td class="main" width="180">Credit Card Expiry Date:</td>
<td class="main"><select name="credit_card_cc_expires_month"><option value="01">January</option><option value="02">February</option><option value="03">March</option><option value="04">April</option><option value="05">May</option><option value="06">June</option><option value="07">July</option><option value="08">August</option><option value="09">September</option><option value="10">October</option><option value="11">November</option><option value="12">December</option></select> <select name="credit_card_cc_expires_year"><option value="2011">2011</option><option value="2012">2012</option><option value="2013">2013</option><option value="2014">2014</option><option value="2015">2015</option><option value="2016">2016</option><option value="2017">2017</option><option value="2018">2018</option><option value="2019">2019</option><option value="2020">2020</option></select></td>
</tr>
<tr>
<td class="main" width="180">CVV number</td>
<td class="main"><input type="text" name="credit_card_cvv" size="4," maxlength="4" /></td>
</tr>
<tr>
<td class="main" width="180"></td>
<td class="main"><input type="submit" name="submit" value="Submit" /></td>
</tr>
</tbody>
</table>
</form>
<pre>

Step 2: You can download creditcard_valid.php file:  creditcard_valid.php

Step 3: You can download creditcard.js file : creditcard.js

Step 4: Now run your creditcard.php file and you can enjoy the javascript and PHP Caredit card validation on your site.