basic register

Didn't test it, should work.

Code:
<?php

$sqlhost = 'localhost';
$sqlun = '';
$sqlpw = '';
$sqldb = '';
$atable = '';//Account table
$afield = '';//Account field



$sqllink = mysql_connect($sqlhost, $sqlun, $sqlpw);
if (!$sqllink) { echo 'Unable to establish mySQL connection'; die(); }
if (!mysql_select_db($sqldb, $sqllink)) { echo 'Unable to select DB'; die(); }

if (isset($_POST['accname']))
{
    $res = mysql_query("SELECT * FROM $atable WHERE $afield='{$_POST['account']}'");
    if (mysql_num_rows($res))
    {
        echo "Account already exists.<br><a href=\"javascript:history.back();\">Click here</a> to go back.";
        die();
    }
    mysql_query("INSERT INTO $atable (`$afield`) VALUES ('{$_POST['accname']}')");
    if (mysql_affected_rows())
    {
        echo "Account created successfully.";
        die();
    }
    else
    {
        echo "Account not created.";
        die();
    }
}
else
{
    echo '<form action="'.substr(strrchr($PHP_SELF,'/'),1).'" method="POST" name="signup">';
    echo '<table width="500">';
    echo '<tr><td class="cacc" COLSPAN=2>Create Account</td></tr>';
    echo '<tr><td class="cacc"><div align=right>Account Name:</div>            </td><td class="cacc"><input name="accname" maxlength="15" type="text" /></td></tr>';
    echo '<div align=right><input type="submit" name="submit" value="Submit"></div>';
    echo '</td></tr></table>';
    echo '</form>';

}


?>
 
Just noticed it borked the special letters. Attachment is it in txt. I threw it together in a few minutes so tell me if it works.
 

Attachments

Back