Jump to content


Photo

i cant find my error in my register.php in notepad :(


  • Please log in to reply
29 replies to this topic

#21 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 15 July 2006 - 05:32 AM

youve got an error with your mysql_fetch_array() is my guess.  its die()ing, but there is no mysql_error() since the previous query went off fine.  it's just not a valid resource.  try removing the or die() from the mysql_fetch_array() and you might find something.

if you need the ID that MySQL auto-inserted in the previous query, use mysql_insert_id().  don't grab it from the database, as that wastes resources.

#22 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 15 July 2006 - 05:35 AM

let me go try all that brb

#23 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 15 July 2006 - 05:41 AM

which one of the or die(mysql_error());
did u want me to remove?

#24 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 15 July 2006 - 05:50 AM

ok though all ur i dont like this section of coding i have found the error since most of this coding wasnt updated for the new databases i hadnt made the script check the emails in the profile srry for the big mess
and will someone plz tell me why my karma is bad plz

#25 scheols

scheols
  • Members
  • PipPipPip
  • Advanced Member
  • 113 posts

Posted 15 July 2006 - 05:55 AM

why dont you do

$password = md5($_POST['pass']);

instead of

$password = $_POST[pass];
and remove:
$password = md5($password);

Dont Piss me Off today

#26 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 15 July 2006 - 06:17 AM

because i like to waste my time typing all that stuff on my script lol kiding idk

#27 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 15 July 2006 - 07:32 AM

ok if u guys think its such a great idea to put an action in tell the exact code to put in plz

I was not telling you you NEED to define the action. I told you what happens by default if you dont.

Read the answers you are given.

#28 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 15 July 2006 - 01:53 PM

ok though all ur i dont like this section of coding i have found the error since most of this coding wasnt updated for the new databases i hadnt made the script check the emails in the profile srry for the big mess
and will someone plz tell me why my karma is bad plz


Possibly because your questions are poorly phrased; fully of irritating stuff like plz, ur, srry; often appear to have mostly ignored any constructive suggestions about solving your problem; and are poorly thought out.

If you want people to help you, put some effort into it. Otherwise, people will simply move on to help someone else.

Use whole sentences. Use whole words. Use punctuation. Use thought before posting. Read replies.
Legend has it that reading the manual never killed anyone.
My site

#29 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 15 July 2006 - 02:00 PM

//another
if($_POST['submit']){

code
}

about a 30 of them lol............


There have been alot of posts about
if($_POST['submit']){


Maybe one of the moderators can make a sticky reguarding this issue.

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#30 pixy

pixy
  • Members
  • PipPipPip
  • Advanced Member
  • 295 posts

Posted 15 July 2006 - 03:03 PM

^ Wouldn't that do nothing? I'd think you'd need to do something like if (isset($_POST['submit'])) { ... but why?

What I do personally is create a hidden field and check if that has been submitted--that way, they can't mess it up since it's in the HTML...

Here, i'm just going to write it for you...Please ask questions if they're something that just seems out there--because they're a reson for everything. :)
<?php
if (isset($_POST['submitted'])) {
    $errors = array();
    if (empty($_POST['username'])) {
        $errors[] = 'You did not enter a username.';
    }
    else {
        $username = $_POST['username'];
    }
    if (empty($_POST['password'])) {
        $errors = 'You did not enter a password.';
    }
    else {
        $pw = $_POST['password'];
    }
    if (empty($_POST['password2'])) {
        $errors[] = 'You did not confirm your password.';
    }
    else {
        $pw2 = $_POST['password'];
    }
    if ($pw != $pw2) {
        $errors[] = 'Your password and confirmed password do not match.';
    }
    if (empty($errors)) { // No errors, so continue with script...
        // First, make sure the username doesn't already exist
        $query = "SELECT username FROM users WHERE username='$username'";
        $result = mysql_query($query);
        if (mysql_num_rows($query) == 0) { // No results come back, so can register
            $query = "INSERT INTO users (username, password) VALUES ('$username', SHA('$pw'))";
            // SHA() encrypts it, always incrypt passwords! :)
            $result = mysql_query($query);
            if ($result) {
                echo $username.', you have been sucessfully registered.';
                // Send an email if you wanna
            }
            else {
                echo mysql_error();
            }
        }
        else {
            echo 'Someone with that username has already registered.';
        }
    }
    else {
        foreach ($errors as $msg) {
            echo '<li> '.$msg.'</li>';
        }
    }
}
else {
    echo '<form action="register.php" method="post">
    <B>Username:</b> <input type="text" name="username" value="';
    if (isset($_POST['username'])) {
        echo stripslashes($_POST['username']);
    }
    echo '"><br>
    <b>Password:</b> <input type="password" name="password"><br>
    <b>Confirm Password:</b> <input type="password" name="password2"><br>
    <input type="submit" name="submit" value="Register">
    <input type="hidden" name="submitted" value="TRUE">
    </form>';
}
?>

This is a .44 Caliber Loveletter straight through my heart.

Tabulas + Threadless + Hire Me!





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users