Register script doesn't work

01/28/2018 18:03 [ADM]_Dephisio#1
Hey Guys ! I spent almost many hours on this php script, I tried many things but nothing works. Could you help me ? I'm trying to make my register php script works, but It doesn't. I got no error in my php logs. And when I click to register, it redirect me to my home page but the account isn't created.

Here is the script:
PHP Code:
<h1><center>Registration</center></h1>

            <center><img src="img/line.png" /></center>

<br/>

<?php

$error 
0;

if (isset(
$_POST['accountname']) && isset($_POST['shoutname']) && isset($_POST['password']) && isset($_POST['rePassword'])){

    echo 
'<span style="font-size:15px;font-weight:bold;">Failure to create your account. Please read the information below fields.</span>';

    
//    enable cookies

    //    clear any previously defined IDs

        
if (isset($_SESSION['UserUID']))

            unset(
$_SESSION['UserUID']);

    

    
//    setup a query to get information on player account

        
$query $conn->prepare('SELECT UserUID FROM PS_UserData.dbo.Users_Master WHERE UserID=?');

        if (
$query === false)

            die(
FormatErrors($query->errorInfo()));

    
//    bind the parameter

        
$query->bindParam(1$_POST['accountname'], PDO::PARAM_STR);

    
//    execute the query

        
if ($query->execute() === false)

            die(
FormatErrors($query->errorInfo()));

    
//    get response (a single row is expected)

        
$row $query->fetch(PDO::FETCH_NUM);

        if (
$row != null){

        
//    UserID was valid ...

            
$error 1;

        } 

        elseif(
is_numeric($_POST['accountname'])){

        
//only numbers issue

            
$error 44;

        }

        else {

            echo(
"poire");

        
//    verify password, depending on actual DB you may have to verify a hash

            
if ($_POST['password'] != $_POST['rePassword']){

            
//    password was invalid

            
$error 2

            } else {

        
$query2 $conn->prepare('SELECT Email FROM PS_UserData.dbo.Users_Master WHERE Email= ?');

        
$query2->bindParam(1$_POST['emailAddress'], PDO::PARAM_STR);

        
$query2->execute();

        
$row2 $query2->fetch(PDO::FETCH_NUM);

                
$bday "20/02/1990";

            if(isset(
$_POST["bday"])){

                if(
$_POST["bday"] != ""){

                                    
$bday $_POST["bday"];



                }

            }

                if (
$_POST['emailAddress'] != $row2[0]){

                    
$userip $_SERVER['REMOTE_ADDR'];                            

                    
$query $conn->prepare("INSERT INTO PS_UserData.dbo.Users_Master (UserID, Pw, JoinDate, Admin, AdminLevel, UseQueue, Status, Leave, LeaveDate, UserType, Point, EnPassword, UserIp, Birth, IsNew, Shoutbox, Email, Skype, MainCharID, Sign)VALUES (?,?,GETDATE(),0,0,'False',0,0,GETDATE(),'N',0,'',?,?,1,?,?,'','','')");

                    
$query->bindParam(1$_POST['accountname'], PDO::PARAM_STR);

                    
$query->bindParam(2$_POST['password'], PDO::PARAM_STR);

                    
$query->bindParam(3$useripPDO::PARAM_STR);

                    
$query->bindParam(4$bday,PDO::PARAM_STR);

                    
$query->bindParam(5$_POST['shoutname'], PDO::PARAM_STR);

                    
$query->bindParam(6$_POST['emailAddress'], PDO::PARAM_STR);

                    
$query->execute();

                    
$row $query->fetch(PDO::FETCH_NUM);



                    
$query1 $conn->prepare('SELECT UserUID FROM PS_UserData.dbo.Users_Master WHERE UserID= ?');

                    
$query1->bindParam(1$_POST['accountname'], PDO::PARAM_STR);

                    
$query1->execute();

                    
$row1 $query1->fetch(PDO::FETCH_NUM);

                    
$uid $row1[0];

                    

                        
$_SESSION['UserUID'] = $uid;

                        
$_SESSION['Status'] = 0;

                    

                        if((
NEW_PLAYER_PM_TITLE != "") && (NEW_PLAYER_PM_MESSAGE != "")){

                            
send_pm($row1[0],NEW_PLAYER_PM_TITLENEW_PLAYER_PM_MESSAGE);

                        }

                        
header("Location: /Home");

                        
//    redirect to Char selection page

                        

                            

                
} else {

                    
$error 3;

                }

                

            }

        }

        
//    setup a query to get information on player account

        
$query4 $conn->prepare('SELECT UserUID FROM PS_UserData.dbo.Users_Master WHERE Shoutbox=?');

        if (
$query4 === false)

            die(
FormatErrors($query4->errorInfo()));

    
//    bind the parameter

        
$query4->bindParam(1$_POST['shoutname'], PDO::PARAM_STR);

    
//    execute the query

        
if ($query4->execute() === false)

            die(
FormatErrors($query4->errorInfo()));

    
//    get response (a single row is expected)

        
$row4 $query4->fetch(PDO::FETCH_NUM);

        if (
$row4 != null){

        
//    UserID was valid ...

            
$error 4;

        }

        if(
strlen($_POST['password']) < || strlen($_POST['password']) > 12) {

            
$error 5;

        }

        if(
strlen($_POST['accountname']) < || strlen($_POST['accountname']) > 12) {

            
$error 6;

        }

        

}

?>

<article>

        <section class="body">

        <form action="Register" class="page_form" method="post" accept-charset="utf-8">



        <table style="width:80%">

        <tr>

        <td><label for="Username">Username</label></td>

            <td>

                <input type="text" name="accountname" id="accountname" placeholder="Must contain between 4 and 12 characters." value=""/>

                <br>

                <?  if ($error == 1){

                 echo 
'<span style="color:red; id="username_error">Username already in use. Find another one.</span>';

                    }

                    if (
$error == 6){

                 echo 
'<span style="color:red; id="username_error">Username must contain between 4 and 12 characters.</span>';

                    }

                    if(
$error == 44){

                 echo 
'<span style="color:red; id="username_error">Username can not contain only numbers.</span>';

 

                    }
?>

            </td>

        </tr>

        <tr>

        <td><label for="ShoutName">ShoutName</label></td>

            <td>

                <input type="text" name="shoutname" id="shoutname" placeholder="This pseudo will be used for the ShoutBox." value=""/>

                <br>

                <? if ($error == 4){

                 echo 
'<span style="color:red; id="username_error">ShoutName already in use. Find another one.</span>';

                }

                 
?>

            </td>

        </tr>

        <tr>

        <td><label for="Email">Email Adress</label></td>

            <td>

                <input type="email" name="emailAddress" id="emailAddress" placeholder="Email Adress" value=""/>

                <br>

                <? if ($error == 3){

                 echo 
'<span style="color:red; id="email_error">E-mail already in use. Find another one.</span>';

                } 
?>

            </td>

        </tr>

        <tr>

        <td><label for="Password">Password</label></td>

            <td>

                <input type="password" name="password" id="password" placeholder="Must contain between 4 and 12 characters." value=""/>

                <br>

                <? if ($error == 5){

                 echo 
'<span style="color:red; id="password_error">Your password must contain between 4 and 12 characters.</span>';

                } 
?>

            </td>

        </tr>

        <tr>

        <td><label for="Confirm Password">Confirm Password</label></td>

            <td>

                <input type="password" name="rePassword" id="rePassword" placeholder="Confirm Password" value="" />

                <br>

                <? if ($error == 2){

                 echo 
'<span style="color:red; id="password_error">Passwords do not match. Try again.</span>';

                } 
?>

            </td>

        </tr>

        <tr>

        <td><label for="Birth">Birthday</label></td>

            <td>

                <input type="date" name="bday" placeoldaer="Birth"/>

            </td>

        </tr>

            </table>

    <center style="margin-bottom:10px;">

        <input type="submit" name="login_submit" value="Register" />

    </center>

</form>    

</article>













        <center>    <img src="img/line.png" /></center>
01/28/2018 18:29 {Skrillex}#2
Hi,
where you have this registration from?

Regards
01/28/2018 19:06 arjulie#3
include your database.php in your script
01/28/2018 19:18 SnickQ#4
Probably you have RowID in your users_master
01/28/2018 19:25 {Skrillex}#5
This is not the problem. The Problem is, that there is an problem in the html part of the php file. The php file dont execute the queries It just skip and go to main page.
01/28/2018 19:31 [ADM]_Dephisio#6
The html part is with the php part. Give a look under the php part that I posted.
01/28/2018 20:01 {Skrillex}#7
yes i know. I mean this part:

Quote:
<form action="Register" class="page_form" method="post" accept-charset="utf-8">
This needs to be linkes to your register.php or your name.php again.

Regards
01/29/2018 08:47 [ADM]_Dephisio#8
I moved the php part on another file and then I've changed this:
PHP Code:
 <form action="signup.php" class="page_form" method="post" accept-charset="utf-8"
But still doesn't work. I got this error:
Failure to create your account. Please read the information below fields.

I also tried to delete RowID but don't work
01/29/2018 14:47 [MXD]Takeshi#9
Quote:
Originally Posted by [ADM]_Dephisio View Post
I moved the php part on another file and then I've changed this:
PHP Code:
 <form action="signup.php" class="page_form" method="post" accept-charset="utf-8"
But still doesn't work. I got this error:
Failure to create your account. Please read the information below fields.

I also tried to delete RowID but don't work
UserUID is auto-increment?
01/29/2018 16:08 [ADM]_Dephisio#10
I tried this:
PHP Code:
USE [PS_UserData]
GO

ALTER TABLE 
[dbo].[Users_MasterDROP CONSTRAINT [DF_Users_Master_IsNew]
GO

ALTER TABLE 
[dbo].[Users_MasterDROP CONSTRAINT [DF_Users_Master_Point]
GO

ALTER TABLE 
[dbo].[Users_MasterDROP CONSTRAINT [DF_Users_Master_JoinDate]
GO

/****** Object:  Table [dbo].[Users_Master]    Script Date: 1/29/2018 7:07:38 AM ******/
DROP TABLE [dbo].[Users_Master]
GO

/****** Object:  Table [dbo].[Users_Master]    Script Date: 1/29/2018 7:07:38 AM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE 
[dbo].[Users_Master](
    [
UserUID] [intIDENTITY(1,1NOT NULL,
    [
UserID] [varchar](18NOT NULL,
    [
Pw] [varchar](12NOT NULL,
    [
JoinDate] [smalldatetimeNOT NULL,
    [
Admin] [bitNOT NULL,
    [
AdminLevel] [tinyintNOT NULL,
    [
UseQueue] [bitNOT NULL,
    [
Status] [smallintNOT NULL,
    [
Leave] [tinyintNOT NULL,
    [
LeaveDate] [smalldatetimeNULL,
    [
UserType] [char](1NOT NULL,
    [
UserIp] [varchar](15NULL,
    [
ModiIp] [varchar](15NULL,
    [
ModiDate] [datetimeNULL,
    [
Point] [intNOT NULL,
    [
Enpassword] [char](32NULL,
    [
Birth] [varchar](8NULL,
    [
IsNew] [bitNULL,
    [
Shoutbox] [varchar](18NULL,
    [
Email] [varchar](maxNULL,
    [
Skype] [varchar](maxNULL,
    [
MainCharID] [intNULL,
    [
Sign] [varchar](maxNULL,
PRIMARY KEY CLUSTERED 
(
    [
UserUIDASC
)WITH (PAD_INDEX OFFSTATISTICS_NORECOMPUTE OFFIGNORE_DUP_KEY OFFALLOW_ROW_LOCKS ONALLOW_PAGE_LOCKS ONON [PRIMARY]
ON [PRIMARYTEXTIMAGE_ON [PRIMARY]
GO

ALTER TABLE 
[dbo].[Users_MasterADD  CONSTRAINT [DF_Users_Master_JoinDate]  DEFAULT (getdate()) FOR [JoinDate]
GO

ALTER TABLE 
[dbo].[Users_MasterADD  CONSTRAINT [DF_Users_Master_Point]  DEFAULT ((0)) FOR [Point]
GO

ALTER TABLE 
[dbo].[Users_MasterADD  CONSTRAINT [DF_Users_Master_IsNew]  DEFAULT ((1)) FOR [IsNew]
GO 
but still nothing
01/29/2018 17:33 {Skrillex}#11
Okay,
i found the problem. I edit your query and post it here


This query should work now.

The query wasn´t able to put smalldatetime from Birth into a varchar(8) value.

Execute this query and It should work fine.

Regards
01/29/2018 20:15 [ADM]_Dephisio#12
Damn. Thank u so much haha u're nice
01/29/2018 20:16 {Skrillex}#13
No problem^^