<h2>Check if username is available. </h2>
 
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
 
<p>*Username: <input name="usercheck" type="text"  /></p>
 
<p><input value="Check username!" type="submit"  /></p>
 
</form>
 
 
<h2>Create user on runescape.com</h2>
 
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
 
<p>*Username: <input name="username" type="text"  /></p>
 
<p>*Password: <input name="password" type="text"  /></p>
 
<p>Email: (optional) <input name="email" type="text"  /></p>
 
<p><input value="CREATE ACCOUNT" type="submit"  /></p>
 
</form>
 
 
 
 
<?php
 
 
// Require class file....
 
require_once('runescape.class.php');
 
 
// Create the Runescape object.
 
$RS = new Runescape();
 
 
 
 
// Create account
 
 
if (isset($_POST['username'])){
 
 
    try{
 
        if (
 
            $RS->Account()->Create($_POST['username'], // The username you'd want to create.
 
                       $_POST['password'], // The password
 
                       
 
                       // THese are also required.
 
                       $RS->Account()->getCountryByName('Norway'), // Country ... You may also provide the "id" (int) of the country, see class for "ids". You can also use the helper method as it's done here.
 
                       rand(2,29), // Day
 
                       rand(0,11),  // Month 0 - 11
 
                       rand(1960, 1990),  // Year
 
                       
 
                       $_POST['email'], // Here you may set an email, its optional but you may set it if you'd want.
 
                       
 
                       '' // You may use a proxy like '23.23.123.23:8080' forexample, but you must know it works....
 
                             // Proxy does not allways work. So i suggest allways settings it to false.
 
                       )
 
        ){
 
 
            echo "SUCCESS: Account created! :) with username: ",$_POST['username'],"  and password: ",$_POST['password'],". You may now login at http://runescape.com.";
 
 
        }
 
    }catch(Exception $e){
 
        echo "ERROR: <font color='red'>",$e->getMessage(),"</font>";
 
 
    }
 
 
}
 
 
if (isset($_POST['usercheck'])){
 
 
    try{
 
        $suggestions = $RS->Account()->usernameAvailable($_POST['usercheck']);
 
        if (
 
            is_bool($suggestions)
 
        ){
 
 
            echo "The username ",$_POST['usercheck']," is available.";
 
 
        }else{
 
            echo "<font color='red'>The username is not available. Suggestions: </font><font color='green'>",(count($suggestions) > 0 ? implode('<br />', $suggestions) : 'none'),".</font>";
 
        }
 
    }catch(Exception $e){
 
        echo "ERROR: <font color='red'>",$e->getMessage(),"</font>";
 
 
    }
 
 
}
 
 
 
?>
 
 |