<?php
require_once ("/your/magento/app/Mage.php");umask(0);
?>
<?php
// Customer Information
$firstname = "John";
$lastname = "Smith";
$email = "johnsmith@localhost.local";
$password = "myverysecretpassword";
// Website and Store details
$websiteId = Mage::app()->getWebsite()->getId();
$store = Mage::app()->getStore();
$customer = Mage::getModel("customer/customer");
$customer->website_id = $websiteId;
$customer->setStore($store);
try {
// If new, save customer information
$customer->firstname = $firstname;
$customer->lastname = $lastname;
$customer->email = $email;
$customer->password_hash = md5($password);
if($customer->save()){
echo $customer->firstname." ".$customer->lastname." information is saved!";
}else{
echo "An error occured while saving customer";
}
}catch(Exception $e){
// If customer already exists, initiate login
if(preg_match('/Customer email already exists/', $e)){
$customer->loadByEmail($email);
$session = Mage::getSingleton('customer/session');
$session->login($email, $password);
echo $session->isLoggedIn() ? $session->getCustomer()->getName().' is online!' : 'not logged in';
}
}
?>