Login   Register  
PHP Classes
elePHPant
Icontem

File: account-create.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Petter Kjelkenes  >  Runescape Tools  >  account-create.php  >  Download  
File: account-create.php
Role: Example script
Content type: text/plain
Description: Create account!
Class: Runescape Tools
Create accounts and retrieve Runescape game data
Author: By
Last change: Example update
Date: 2010-08-22 18:20
Size: 2,724 bytes
 

Contents

Class file image Download

<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(19601990),  // 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) > implode('<br />'$suggestions) : 'none'),".</font>";
        }
    }catch(
Exception $e){
        echo 
"ERROR: <font color='red'>",$e->getMessage(),"</font>";

    }

}


?>