Jump to content

Recommended Posts

Hello Everyone

 

Im just new to PHP Script  I encounter problem when I run my xampp here is the 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

<?phpfunction 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
 
<?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álido. Solo letras, se permiten nú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ña no válida. Solo letras, se permiten nú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álida. Debe ser un número de 7 dì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ñ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ónico no vá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álida.. Solo letras y nú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ú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ìs no vá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..
 
Edited by Ch0cu3r
Wrapped code in code tags
Link to comment
https://forums.phpfreaks.com/topic/287896-problem-with-my-registry-script/
Share on other sites

the first error means you have included conec.php more than one time, thereby redefining the Connect() function. you would need to determine where in your code you are including it and make sure you only include it once. you either have multiple include statements or an include statement inside of a loop.

 

the next two errors are because you have used a column name (spelling or capitalization) that doesn't exit. you would need to identify which query in your code is on line 161 (we cannot because the posted code doesn't match the line numbers) and determine which column name doesn't match your table definition.

 

the last error message is self explanatory, did you read it at all and try determine what about your query is causing it?

Edited by mac_gyver
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.