Jump to content

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


BillyBoB

Recommended Posts

[quote]ok if u guys think its such a great idea to put an action in tell the exact code to put in plz[/quote]
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.
Link to comment
Share on other sites

[quote author=BillyBoB link=topic=100640.msg397569#msg397569 date=1152942605]
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
[/quote]

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.
Link to comment
Share on other sites

[quote author=redarrow link=topic=100640.msg397521#msg397521 date=1152935219]
//another
if($_POST['submit']){

code
}

about a 30 of them lol............
[/quote]

There have been alot of posts about [code=php:0]if($_POST['submit']){[/code]

Maybe one of the moderators can make a sticky reguarding this issue.
Link to comment
Share on other sites

^ 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. :)
[code]
<?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>';
}
?>
[/code]
Link to comment
Share on other sites

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.