Jump to content

[SOLVED] Lost and loster ..please help...


Recommended Posts

Okay I am trying to figure this out... and I get most of it... just havin issues with one little thing..

 

In the register.php example on http://www.free2code.net/tutorials/view/creating_a_php_login_script-5/page4.html

 

I am trying to figure out how to make it register the password using the OLD_PASSWORD method

 

Starting on line 74
}

// now we can add them to the database.
// encrypt password

$_POST['passwd'] = md5($_POST['passwd']);

if (!get_magic_quotes_gpc()) {
$_POST['passwd'] = addslashes($_POST['passwd']);
$_POST['email'] = addslashes($_POST['email']);
$_POST['website'] = addslashes($_POST['website']);
$_POST['location'] = addslashes($_POST['location']);
}

$regdate = date('m d, Y');

$insert = "INSERT INTO users (
username,
password,
regdate,
email,
website,
location,
show_email,
last_login)
VALUES (
'".$_POST['uname']."',
'OLD_PASSWORD('.$_POST['passwd'].'),
'$regdate',
'".$_POST['email']."',
'".$_POST['website']."',
'".$_POST['location']."',
'".$_POST['show_email']."',
'Never')";

 

I know it's these two lines and I am missing something

 

$_POST['passwd'] = md5($_POST['passwd']);

 

'OLD_PASSWORD('.$_POST['passwd'].'),

What am I doing wrong?

 

I try to never ask questions but this is driving me bonkers.. and 4 days... lost of reading trying differant stuff.

 

If I did not need the old password method I would not have asked.

 

Thanks in advance...

I am a game designer... not a MySQL/PHP Freak  :P

 

Link to comment
Share on other sites

I am so confused...

 

Yeah I tried that to at first that and got an error on line 73

:

Warning: preg_match() [function.preg-match]: Unknown modifier '/' in reg.php on line 73

DB Error: syntax error

 

It works as long as I am not trying to use the OLD_PASSWORD function

 

So that error makes no sense... I even left the website field blank.

 

I am using php 5 and Mysql 5.1 but running the database password in 4.0 compatibility

 

Here is the whole script... thank you for the suggestion... you could see how a newbie like myself would be puzzled....

 

 


<?php
require('db_connect.php');    // database connect script.
?>

<html>
<head>
<title>Register an Account</title>
</head>
<body>

<?php

if (isset($_POST['submit'])) { // if form has been submitted
    /* check they filled in what they supposed to, 
    passwords matched, username
    isn't already taken, etc. */

    if (!$_POST['uname'] || !$_POST['passwd'] ||
        !$_POST['passwd_again'] || !$_POST['email']) {
        die('You did not fill in a required field.');
    }

    // check if username exists in database.

    if (!get_magic_quotes_gpc()) {
        $_POST['uname'] = addslashes($_POST['uname']);
    }

    $qry = "SELECT username FROM users WHERE username = '".$_POST['uname']."'";
    $name_check = $db_object->query($qry);

    if (DB::isError($name_check)) {
        die($name_check->getMessage());
    }

    $name_checkk = $name_check->numRows();

    if ($name_checkk != 0) {
        die('Sorry, the username: <strong>'.$_POST['uname'].'</strong>'
          . ' is already taken, please pick another one.');
    }

    // check passwords match

    if ($_POST['passwd'] != $_POST['passwd_again']) {
        die('Passwords did not match.');
    }

    // check e-mail format

    if (!preg_match("/.*@.*..*/", $_POST['email']) ||
         preg_match("/(<|>)/", $_POST['email'])) {
        die('Invalid e-mail address.');
    }

    // no HTML tags in username, website, location, password

    $_POST['uname'] = strip_tags($_POST['uname']);
    $_POST['passwd'] = strip_tags($_POST['passwd']);
    $_POST['website'] = strip_tags($_POST['website']);
    $_POST['location'] = strip_tags($_POST['location']);

    // check show_email data

    if ($_POST['show_email'] != 0 & $_POST['show_email'] != 1) {
        die('Nope');
    }

    /* the rest of the information is optional, the only thing we need to 
    check is if they submitted a website, 
    and if so, check the format is ok. */

    if ($_POST['website'] != '' & !preg_match("/^(http|ftp):///", $_POST['website'])) {
        $_POST['website'] = 'http://'.$_POST['website'];
    }

    // now we can add them to the database.
    // encrypt password

    $_POST['passwd'] = md5($_POST['passwd']);

    if (!get_magic_quotes_gpc()) {
        $_POST['passwd'] = addslashes($_POST['passwd']);
        $_POST['email'] = addslashes($_POST['email']);
        $_POST['website'] = addslashes($_POST['website']);
        $_POST['location'] = addslashes($_POST['location']);
    }

    $regdate = date('m d, Y');

    $insert = "INSERT INTO users (
            username, 
            password, 
            regdate, 
            email, 
            website, 
            location, 
            show_email, 
            last_login) 
            VALUES (
            '".$_POST['uname']."', 
            'OLD_PASSWORD('".$_POST['passwd']."'), 
            '$regdate', 
            '".$_POST['email']."', 
            '".$_POST['website']."', 
            '".$_POST['location']."', 
            '".$_POST['show_email']."', 
            'Never')";

    $add_member = $db_object->query($insert);

    if (DB::isError($add_member)) {
        die($add_member->getMessage());
    }

    $db_object->disconnect();
?>

<h1>Registered</h1>

<p>Thank you, your information has been added to the database, 
you may now <a href="login.php" title="Login">log in</a>.</p>

<?php

} else {    // if form hasn't been submitted

?>
<h1>Register</h1>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table align="center" border="1" cellspacing="0" cellpadding="3">
<tr><td>Username*:</td><td>
<input type="text" name="uname" maxlength="40">
</td></tr>
<tr><td>Password*:</td><td>
<input type="password" name="passwd" maxlength="50">
</td></tr>
<tr><td>Confirm Password*:</td><td>
<input type="password" name="passwd_again" maxlength="50">
</td></tr>
<tr><td>E-Mail*:</td><td>
<input type="text" name="email" maxlength="100">
</td></tr>
<tr><td>Website:</td><td>
<input type="text" name="website" maxlength="150">
</td></tr>
<tr><td>Location</td><td>
<input type="text" name="location" maxlength="150">
</td></tr>
<tr><td>Show E-Mail?</td><td>
<select name="show_email">
<option value="1" selected="selected">Yes</option>
<option value="0">No</option></select>
</td></tr>
<tr><td colspan="2" align="right">
<input type="submit" name="submit" value="Sign Up">
</td></tr>
</table>
</form>

<?php

}

?>
</body>
</html>

Link to comment
Share on other sites

Hi,

 

From what I have quickly read about the OLD_PASSWORD() function, that is for the actual MySQL User database, not your own databases. Are you creating MySQL users, or is this a user table you are creating for your own application.

 

David.

Link to comment
Share on other sites

It's a user table for a mmo game being designed with an engine that only is able to access U/P's using the OLD_PASSWORD. And the boys at quest3d just put out a new version but never bothered to update their SQL version.

 

I have a database already that it can access but not register... so I am making a php page users can register threw.

 

 

 

 

Link to comment
Share on other sites

Okay never mind then... I guess I will figure it out on my own just like everything else. 2 people making this game..

 

2

 

and were 80% done.. will be the biggest mmo game and it's free...

 

One little issue.. one little line of code.. is holding it up... 1

 

Errrrrr

 

But... dun matter... what it's name is, see ya..

 

 

 

Link to comment
Share on other sites

Lol... I think not.... Everything is already built around it. 2 years worth of stuff.

 

Besides I got it  ;D

 

Just had to do something alittle backwards, but then just decided to make my own C pack for it instead so people could check their offline messages threw a Ajax IM. Long way around but... Learned some neat stuff in the process and now I have no more questions.

 

C++, Pascal, Cobalt, PHP, Perl, Ajax, sql, MSDB, Flash, Shockwave, html,shtml,etc etc..

 

Now I can add SQL to the list. 7 days later lol..

 

Peace.

 

 

 

 

 

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.