use below code to add product to cart
try
{
$cart = Mage::getSingleton('checkout/cart');
$cart->init();
$qty=1;
$productId='10'; //product id
$product = Mage::getModel('catalog/product')->load($productId);
$formKey = Mage::getSingleton('core/session')->getFormKey();
if($product->getSku()!='')
{
$paramater = array(
'product' => $productId,
'qty' => $qty,
'form_key' => $formKey
);
$cart->addProduct($product, $paramater);
$cart->save();
}
else
{
Mage::log('product not vailable');
}
$cart->save();
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
}catch (Exception $e)
{
Mage::log($e->getMessage());
}