Location: PHPKode > projects > Radio404 > radio404/htdocs/newuser.php
<?php
/********************************************************************
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General
Public License along with this program; if not, write to
the Free Software Foundation, Inc.,
 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
********************************************************************/

/**
 * Page for new users of the system to get a PIN
 * E-mail address is collected is solely for purpose of 
 * getting a user back their pin number if they should
 * forget it
 **/

include("../sql.inc");

if(isset($_GET['p']))
{

	while(!$pin)
	{
		$rand = mt_rand(1000, 9999);
	
		$sql = "SELECT NULL FROM users WHERE id='" . $rand . "'";
		$num = count(sql_query($sql));		
	
		if($num > 0)
		{
			//nothing
		}
		else
		{
			$sql = "INSERT INTO users VALUES ('". $rand . "', '" . safe_sql($_POST['email']) . "', '')";
			sql_query($sql);

			$pin = $rand;
		}
	}

	echo "Your PIN number is: " . $pin;
}
else
{
	echo "<form action='newuser.php?p=new' method='post'>E-Mail Address: <input type='text' name='email' /> (used if you forget your PIN #)<br /><input type='submit' value='Submit' />";	
}

?>
Return current item: Radio404