magento add product to cart

 
require_once 'app/Mage.php'; 
Mage::app("default"); 
Mage::getSingleton("core/session", array("name" => "frontend")); 
$session = Mage::getSingleton("customer/session"); 
$userData=Mage::helper('customer')->getCustomer()->getData();
$cart = Mage::getSingleton('checkout/cart'); 
$yourProId=7;
$qty=2; 
$params = array( 'product' => $yourProId, 'related_product' => null, 'qty' => $qty ); 
$product = new Mage_Catalog_Model_Product(); $product->load($yourProId); $cart->
addProduct($product, $params);
 $cart->save(); 
Mage::getSingleton('checkout/session')->setCartWasUpdated(true); 
$message = ('Your cart has been updated successfully.');
 Mage::getSingleton('checkout/session')->addSuccess($message);