Page 1 of 1

Problem with my Registry

Posted: Sun Apr 20, 2014 7:51 pm
by Gebbie
Hi everyone,

I have a problem with my registry when I run my xampp it I got an error message

Fatal error: Cannot redeclare Connect() (previously declared in C:\xampp\htdocs\includes\registro\conec.php:4) in C:\xampp\htdocs\includes\registro\conec.php on line 14

here is the conec.php

Code: Select all

<?php
function Connect()
{
global $link;
if (!($link=mssql_pconnect("T-REX\SQLEXPRESS","sa","123456")))
{
exit();
}
if (!mssql_select_db("UserLogin",$link))
{
exit();
}
return $link;
}
Connect();
?>
here is my register.php

Code: Select all

<?php
error_reporting(E_ALL | E_STRICT);
include('conec.php');
#include('auth.php');


$title = 'REGISTER';
if (isset($_POST['action']) && $_POST['action'] == 'submitted') {
    $accdir="C:\\Server\\DBSRV\\account";
    $initial="etc";
    $Email = $_POST['txtEmail'];
    $UserID = $_POST['txtUser'];
    $Password = $_POST['txtPass'];
    $CPassword = $_POST['txtPass2'];
    $UserKey = $_POST['txtKey'];
    $SecretQuestion = $_POST['txtQuest'];
    $Answer = $_POST['txtAnswer'];
    $FirstName = $_POST['txtName'];
    $MI = substr($UserID,0,1);
    $LastName = $_POST['txtLastName'];
    $Month = $_POST['txtMonth'];
    $Day = $_POST['txtDay'];
    $Year = $_POST['txtYear'];
    $Sex = $_POST['txtSex'];
    $Country = $_POST['txtCountry'];


    function is_email($email) {
        $x = '\d\w!\#\$%&\'*+\-/=?\^_`{|}~';    //just for clarity


        return count($email = explode('@', $email, 3)) == 2
                && strlen($email[0]) < 65
                && strlen($email[1]) < 256
                && preg_match("#^[$x]+(\.?([$x]+\.)*[$x]+)?$#", $email[0])
                && preg_match('#^(([a-z0-9]+-*)?[a-z0-9]+\.)+[a-z]{2,6}.?$#', $email[1]);
    }


    $error = "";
    function AllOK() {
        global $error,$Email,$UserID,$Password,$CPassword,$UserKey,$SecretQuestion,$Answer,$FirstName,$MI,$LastName,$Month,$Day,$Year,$Sex,$Country;


        if (strlen($UserID) < 6 || strlen($UserID) > 50 || !preg_match("/^[a-zA-Z0-9_-]+$/", $UserID)) {
            $error .= "<DIV ALIGN='CENTER'><br/><img src='imagenes/error_icon.jpg'> <br><br><FONT FACE='arial' SIZE=3 COLOR=red><b><i>'$UserID', Nombre de usuario no v&aacute;lido. Solo letras, se permiten n&uacute;meros en este campo. (longitud 6 ~ 50).</i></b></FONT><br/><br/><br/><br/><a href='javascript:history.go(-1)'> <img src='imagenes/atras.jpg' border='0'/></a></DIV><br/>";
            return false;
        }


        if (strlen($Password) < 6 || strlen($Password) > 30 || !preg_match("/^[a-zA-Z0-9_-]+$/", $Password)) {
            $error .= "<DIV ALIGN='CENTER'><br/><img src='imagenes/error_icon.jpg'> <br><br><FONT FACE='arial' SIZE=3 COLOR=red><b><i>Contrase&ntilde;a no v&aacute;lida. Solo letras, se permiten n&uacute;meros en este campo (longitud 6 ~ 30).</i></b></FONT><br/><br/><br/><br/><a href='javascript:history.go(-1)'> <img src='imagenes/atras.jpg' border='0'/></a></DIV><br/>";
            return false;
        }


        if (strlen($UserKey) != 7 || !preg_match("/^[0-9]/", $UserKey)) {
            $error .= "<DIV ALIGN='CENTER'><br/><img src='imagenes/error_icon.jpg'> <br><br><FONT FACE='arial' SIZE=3 COLOR=red><b><i>Llave secreta no v&aacute;lida. Debe ser un n&uacute;mero de 7 d&igrave;gitos.</i></b></FONT><br/><br/><br/><br/><br/><a href='javascript:history.go(-1)'> <img src='imagenes/atras.jpg' border='0'/></a></DIV><br/>";
            return false;
        }


        if ($Password != $CPassword) {
            $error .= "<DIV ALIGN='CENTER'><br/><img src='imagenes/error_icon.jpg'> <br><br><FONT FACE='arial' SIZE=3 COLOR=red><b><i>Las contrase&ntilde;as no coinciden...</i></b></FONT><br/><br/><br/><br/><br/><a href='javascript:history.go(-1)'> <img src='imagenes/atras.jpg' border='0'/></a></DIV><br/>";
            return false;
        }


        $SecretQuestion = str_replace("'", "''", $SecretQuestion);


        if (!is_email($Email)) {
            $error .= "<DIV ALIGN='CENTER'><br/><img src='imagenes/error_icon.jpg'> <br><br><FONT FACE='arial' SIZE=3 COLOR=red><b><i>Correo electr&oacute;nico no v&aacute;lido.</i></b></FONT><br/><FONT FACE='arial' SIZE=1 COLOR=gray>Un Email debe ser del tipo: minombre@midominio.com </FONT><br/><br/><br/><br/><a href='javascript:history.go(-1)'> <img src='imagenes/atras.jpg' border='0'/></a></DIV><br/><br/>";
            return false;
        }


        if (!preg_match("/^[a-zA-Z 0-9_-]+$/", $Answer) || strlen($Answer) == "0") {
            $error .= "<DIV ALIGN='CENTER'><br/><img src='imagenes/error_icon.jpg'> <br><br><FONT FACE='arial' SIZE=3 COLOR=red><b><i>Respuesta no v&aacute;lida.. Solo letras y n&uacute;meros estan permitidos. </i></b></FONT><br/><br/><br/><br/><br/><a href='javascript:history.go(-1)'> <img src='imagenes/atras.jpg' border='0'/></a></DIV><br/>";
            return false;
        }


/*        if (!preg_match("/^[a-zA-Z_-]+$/", $FirstName) || strlen($FirstName) == "0") {  //deshabilitado por ser mas amable con el usuario
            $error .= "Nombre no valido. Solo letras estan permitidas.<br/>";   //
            return false;
        }


        if (!preg_match("/^[a-zA-Z_-]+$/", $LastName) || strlen($LastName) == "0") {
            $error .= "Apellido no valido. Solo letras estan permitidas.<br/>";
            return false;
        }
*/
        if (strlen($MI) != 1 || !preg_match("/^[a-zA-Z_-]+$/", $MI)) {
            $error .= "<DIV ALIGN='CENTER'><br/><img src='imagenes/error_icon.jpg'> <br><br><FONT FACE='arial' SIZE=3 COLOR=red><b><i>No se permiten usuarios que comiencen con n&uacute;meros....</i></b></FONT><br/><FONT FACE='arial' SIZE=1 COLOR=gray>Pueden ser como el siguiente ejemplo: miusuario123, miusuario </FONT> <br/><br/><br/><br/><a href='javascript:history.go(-1)'> <img src='imagenes/atras.jpg' border='0'/></a></DIV><br/><br/>";
            return false;
        }


        if ($Month > 12 || $Month < 1 || !preg_match("/^[0-9]/", $Month) || strlen($Month) == "0") {
            $error .= "Mes de fecha de nacimiento no valido.<br/>";
            return false;
        }


        if ($Day > 31 || $Day < 1 || !preg_match("/^[0-9]/", $Day) || strlen($Day) == "0") {
            $error .= "Dia de fecha de nacimiento no valido.<br/>";
            return false;
        }


        if ($Year > 2007 || $Year < 1950 || !preg_match("/^[0-9]/", $Year) || strlen($Year) == "0") {
            $error .= "Año de fecha de nacimiento no valido.<br/>";
            return false;
        }


        if ($Sex != 1 && $Sex != 2) {
            $error .= "Genero no valido.<br/>";
            return false;
        }


     
        if (!preg_match("/^[a-zA-Z 0-9_-]+$/", $Country)) {
            $error .= " <DIV ALIGN='CENTER'><br/><img src='imagenes/error_icon.jpg'> <br><br><FONT FACE='arial' SIZE=3 COLOR=red><b><i>Pa&igrave;s no v&aacute;lido.</i></b></FONT><br/><a href='javascript:history.go(-1)'> <img src='imagenes/atras.jpg' border='0'/></a></DIV>";
            return false;
        }








             $wea = mssql_query("SELECT UserID FROM Account where UserID='$UserID'");
        $row = mssql_fetch_row($wea);


        if ($row[0] != "") {
            $error .= "<DIV ALIGN='CENTER'><br/><img src='imagenes/error_icon.jpg'> <br><br><FONT FACE='arial' SIZE=3 COLOR=red><b><i>Nombre de usuario en uso, Porfavor elije otro. </i></b></FONT><br/><br/><br/><br/><a href='javascript:history.go(-1)'> <img src='imagenes/atras.jpg' border='0'/></a></DIV>";
            return false;
        }


        $wea2 = mssql_query("SELECT Email FROM Account where Email='$Email'");
        $row2 = mssql_fetch_row($wea2);


        if ($row2[0] != "") {
            $error .= "  <DIV ALIGN='CENTER'><br/><img src='imagenes/error_icon.jpg'> <br><br><FONT FACE='arial' SIZE=3 COLOR=red><b><i> Email en uso, Porfavor ingresa otro.</i></b></FONT><br/><br/><br/><br/><br/><a href='javascript:history.go(-1)'> <img src='imagenes/atras.jpg' border='0'/></a></DIV><br/>";
            return false;
        }
        
        return true;
    }


    if (!AllOK()) {




        echo $error;
       
    }
    else {
        $password2=strtoupper(md5(trim($Password)));
        $initial=substr($UserID,0,1);
        $userlenght=strlen(trim($UserID));


        $result = "Cuenta registrada con exito!";
        $f=fopen("./inc/sample.tad", "r");
        $acc = fread($f,7124);
        $demoid=substr($acc,0,$userlenght);
        $demopass=substr($acc,52,32);
        $acc = str_replace($demoid,$UserID,$acc);
        $acc = str_replace($demopass,$password2,$acc);
//        echo $accdir."\\".$initial."\\".$UserID;
        $f2=fopen($accdir."\\".$initial."\\".$UserID.".tad", "a");
        fwrite($f2,$acc);
        fclose($f);
        echo "<div align='center'><img src='imagenes/tantralogo.png' border='0'/></div><br>
 <FONT FACE='tahoma' align='center' SIZE=2 COLOR=white>Cuenta registrada con exito!.</FONT>";
        
      
        mssql_query("INSERT INTO Account VALUES ('$Email', '$UserID', '$Password' , '$UserKey', '0', NULL, NULL, NULL, '$SecretQuestion', '$Answer', '$FirstName', '$MI', '$LastName', '$Month/$Day/$Year 00:00:00', '$Sex', 'NULL', NULL, NULL, '$Country', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '$_SERVER[REMOTE_ADDR]', newid(), GETDATE(), 1, NULL, 0, 0, 0, NULL, 0, 1, NULL, 0, 0, NULL, NULL, 0)");
        mssql_query("DECLARE @return_value int,
@NCashResult int,
@NCashMsg nvarchar(100)


EXEC @return_value = [dbo].[AccountInsertUserInBilling]
@Email = N'".$Email."',
@NCashResult = @NCashResult OUTPUT,
@NCashMsg = @NCashMsg OUTPUT");


    }


    # include('template/registrocompleto.php');


}
else {
    include('registro.php');
}


?>


Whenever also I run my register page I encounter this error

Warning: mssql_query() [function.mssql-query]: message: Column name or number of supplied values does not match table definition. (severity 16) in C:\xampp\htdocs\includes\registro\registro.php on line 161

Warning: mssql_query() [function.mssql-query]: Query failed in C:\xampp\htdocs\includes\registro\registro.php on line 161

Warning: mssql_query() [function.mssql-query]: message: Cannot insert the value NULL into column 'userId', table 'billcrux_phil.dbo.tblUser'; column does not allow nulls. INSERT fails. (severity 16) in C:\xampp\htdocs\includes\registro\registro.php on line 169

I hope you can help me with my problem..


Regards..

Re: Problem with my Registry

Posted: Mon Apr 21, 2014 7:52 am
by Christopher
The error is "Column name or number of supplied values does not match table definition. " Looking at the code, maybe UserID or Email? Are you sure the tables are identical on both systems? You call the file register.php, but in the error message it is registro.php?

Re: Problem with my Registry

Posted: Fri Apr 25, 2014 12:27 pm
by Gebbie
bummp to this I go with your idea but the problem persist. It its a registro.php I just say it in english so that everybody can understand.

Re: Problem with my Registry

Posted: Fri Apr 25, 2014 2:13 pm
by Christopher
The error message says the mysql_query() error is on line 161, but there is no query on that line in the code above. It is probably "SELECT UserID FROM Account where UserID='$UserID' or "SELECT Email FROM Account where Email='$Email'. Th column name error would be either UserID or Email.

The other error message is pretty clear that the column definition for userId needs to be changed: "Cannot insert the value NULL into column 'userId', table 'billcrux_phil.dbo.tblUser'; column does not allow nulls. INSERT fails."

Re: Problem with my Registry

Posted: Sat Apr 26, 2014 12:27 pm
by nite4000
I may not be seeing this right but I am seeing mssql and not MySQL that could be a issue as well

Code: Select all

if (!($link=mssql_pconnect("T-REX\SQLEXPRESS","sa","123456")))
to

Code: Select all

if (!($link=mysql_pconnect("T-REX\SQLEXPRESS","sa","123456")))
I could be wrong though if I am I apoligize