Page 1 of 1

Serial Number Validation

Posted: Sun Dec 21, 2008 5:56 pm
by mhale
I found the serial number sample and I know how to make it work.

My question is though, how can I generate a serial using PHP on my server?

Posted: Sun Dec 21, 2008 6:17 pm
by CandiceJones
That's hardly an InstallAware question.

Posted: Wed Jan 21, 2009 5:57 pm
by tommykjensen
I have created a project that combines 2 of the samples provided with the product. The Serial Validation and the Online User Authentication.

I took the Serial Validation and modified it to include the online check. On my website I have a script like this that validates if the information sent is valid (you need to modify it to your own needs).

Hope this helps.

Code: Select all

<?

$sql_host =   '';  //add host information here (localhost, mysql.host.com, etc.)
$sql_un   =   '';  //add your user name here
$sql_pass =   '';  //add your password here
$sql_db   =   '';  //add your database name here

$link = mysql_connect($sql_host, $sql_un , $sql_pass);
if (!$link)
{
	die('Could not connect: ' . mysql_error());
}
else
{
	$db_selected = mysql_select_db($sql_db , $link);
	if (!$db_selected)
	{
  	die ('Can\\'t use foo : ' . mysql_error());
	}
	else
	{
		if(get_magic_quotes_gpc()) 
		{
			$parm = stripslashes($_GET['parm']);
		}
		else
		{
			$parm = stripslashes($_GET['parm']);
		}
		if (isset($parm) )
		{
			
			$query_string = sprintf("SELECT * FROM `table` WHERE parm='%s''",	mysql_real_escape_string($parm, $link));
			
			$result = mysql_query($query_string, $link);
			if (!$result)
			{
				die('Invalid query: ' . mysql_error());
			}
			else
			{
				$row = mysql_fetch_row($result);
				//print("<BR>".$result);
				if ($row)
				{
					print("OK\\n");
				}
				else
				{
					print("INVALID SERIAL 1");
				}
			}
		}
		else
		{
			print("INVALID SERIAL 2");
		}	
	}
}
?>

Posted: Wed Jan 21, 2009 6:57 pm
by CandiceJones
Thank you very much for sharing this with the InstallAware community!