0

In my site's registration, the insert is only working for certain data, not sure why

heres the code (I know, no salt, I will fix that next)

if ($id == "0" || $id == null)
{   echo '<title>Start</title>';
    $content .= '
        <body><center>
            <h1>TitleBar</h1>
            <img src="logo.png" alt="Smiley face" height="400" width="400">
            <form action="?id=loginF" method="POST">
            <fieldset>
            <legend>LOGIN </legend>
            <p><label for="username">Username</label> <input type="text" name="username" required="required" autofocus="autofocus"/></p>
            <p><label for="password">Password</label> <input type="password" name="password" required="required"/></p>
            <p class="submit"><input type="submit" value="Login"/></p>
            </fieldset>
            </form>

        </center>
    ';
    echo $content;
}

This next section is for after the form is submitted:

if ($id == "loginF")
        {
        echo '<title>Login</title>';
        $username = $_POST['username'];
        $password = $_POST['password'];
        $email = $_POST['username'];
        $snapchat = new Snapchat($username,$password);
         echo $username;
        $_SESSION['name'] = $username;
        $_SESSION['pass'] = $password;
        $ulz="INSERT INTO user_attribs(username,email,salted)VALUES('$username'
                    ,'$email','$password')";
        mysql_query($ulz);
        $content .= '
        <ul>
            <li><a href="?id=getSnaps">Get Snaplist</a></li>
            <li><a href="?id=getFriends">Get Friendlist</a></li>
            <li><a href="?id=sendSnap">Send pics</a></li>
            <li><a href="?id=logout">Logout</a></li>
        </ul>
        ';
        echo $content;

    }

for example:

top@kek.com with any password will insert as a username

however, any username with, for example, an @hotmail.com address will not insert

what could be the cause of that?

I tried to google it, I honestly have no idea.

EDIT::

I want to be more specific in the error. I did some testing. The following CAN insert: hotmail.com, .hotmail.com, a@hotmail.com, art@hotmail.com, however, a.rt@hotmail.com cannot be inserted. it must be the front period.

user2962806
  • 47
  • 2
  • 7

1 Answers1

0

After looking at the table description, username was VARCHAR(15)

This was what caused the problem. By extending the column length, I was able to get the data inserted.

user2962806
  • 47
  • 2
  • 7
  • Oh for crying outloud, I was actually going to mention that earlier, I should've followed my instinct on that one LOL! – Funk Forty Niner Apr 30 '14 at 05:35
  • Email addresses can be at times rather long. So it's best to have a larger than anticipated column length. I set everything to its full max when it comes to VARCHAR. – Funk Forty Niner Apr 30 '14 at 05:39