<?php

include ("../inc/inc_connect.php");

if (!isset($oldname))
{
    print "<br><br><br><form method=\"post\" action=\"setup_old_users.php\">
    Old Forum User Table Name: <input type=\"text\" name=\"oldname\"><br><input type=\"submit\" value=\"Update my users!\"></form>";
    exit;
}


$result=mysql_query("SELECT * FROM $oldname ORDER BY intId");
$num_rows = mysql_num_rows( $result );
while ( $a_row = mysql_fetch_object( $result ) )
{
   $name = $a_row->strName;
    $resultb=mysql_query("SELECT * FROM $userstable where strName = '$name'");
    $num_rowsb = mysql_num_rows( $resultb );

    if ($num_rowsb == 0)
    {
        //no duplicate - continue
        $query = "INSERT INTO $userstable ( strName, strPassword, strEmail, strAvatar, strPhoto, strConnection, strForumComment, intPosts, intTopics, strHomePage, strIp, strUrl, strForename, strSurname, ynShowOnline, ynShowEmail, strIcqNumber, strMsnName, strYahooId, strLocation, intBirthday, intBirthMonth, datRegistrationDate, intEpochRegistration, ynBanIp ) values( '$a_row->strName', '$a_row->strPassword', '$a_row->strEmail', '$a_row->strAvatar', '$a_row->strPhoto', '$a_row->strConnection', '$a_row->strForumComment', '$a_row->intPosts', '$a_row->intTopics', '$a_row->strHomePage', '$a_row->strIp', '$a_row->strUrl', '$a_row->strForename', '$a_row->strSurname', '$a_row->ynShowOnline', '$a_row->ynShowEmail', '$a_row->strIcqNumber', '$a_row->strMsnName', '$a_row->strYahooId', '$a_row->strLocation', '$a_row->intBirthday', '$a_row->intBirthMonth', '$a_row->datRegistrationDate', '$a_row->intEpochRegistration', '$a_row->ynBanIp')";
        mysql_query( $query, $link ) or die ( "Error! : ".mysql_error() );

        print "$name successfully updated! <br>";
    }
}