Help - Search - Members - Calendar
Full Version: Member Registration And Login System
Zymic Webmaster Forums > Zymic Free Web Hosting > Tutorials
Pages: 1, 2, 3
uncled1023
(tutorial part 1 of many!!!)




1)create a database. name it whatever you want.(EX: members)
2)create a new file and call it db_connect.php
insert the following code into the file and change the database variables to match yours.
CODE
<?php



$dbhost = 'localhost';


// your database username.
    $dbusername = 'database_username';

// the password that corresponds to the above username.
    $dbpasswd = 'password';

// the database name that your username is associated with.
    $database_name = 'database_name';

    
    $connection = mysql_connect("$dbhost","$dbusername","$dbpasswd")

    or die ("Couldn't connect to server.");


$db = mysql_select_db("$database_name", $connection)

    or die("Couldn't select database.");


// we write this later on, ignore for now.


include('check_login.php');


?>


3)now save it.
4)now go to your phpadmin and create a table with this query:
CODE
CREATE TABLE users (
id int(10) DEFAULT '0' NOT NULL auto_increment,
username varchar(40),
password varchar(50),
regdate varchar(20),
email varchar(100),
website varchar(150),
location varchar(150),
show_email int(2) DEFAULT '0',
last_login varchar(20),
PRIMARY KEY(id))


5)now create a new file and call it register.php and insert the following code:
CODE
<?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']."'";
                $sqlmembers = mysql_query($qry);
                $name_check = mysql_fetch_array ($sqlmembers);
                $name_checkk = mysql_num_rows ($sqlmembers);
    
    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']."',
            '".$_POST['passwd']."',
            '$regdate',
            '".$_POST['email']."',
            '".$_POST['website']."',
            '".$_POST['location']."',
            '".$_POST['show_email']."',
            'Never')";

    $sqlmembers = mysql_query($insert);
?>

<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>


6)save the file.
7)Create a new file and call it check_login.php and add this code:
CODE
<?php

session_start();

if (!isset($_SESSION['username']) || !isset($_SESSION['password'])) {
    $logged_in = 0;
    return;
} else {

    // remember, $_SESSION['password'] will be encrypted.

    if(!get_magic_quotes_gpc()) {
        $_SESSION['username'] = addslashes($_SESSION['username']);
    }
    // addslashes to session username before using in a query.
    $qry = "SELECT password FROM users WHERE username = '".$_SESSION['username']."'";
    $sqlmembers = mysql_query($qry);
    $pass =  mysql_num_rows($sqlmembers);

    if($pass != 1) {
        $logged_in = 0;
        unset($_SESSION['username']);
        unset($_SESSION['password']);
        // kill incorrect session variables.
    }

    $db_pass =  mysql_fetch_array ($sqlmembers);

    // now we have encrypted pass from DB in
    //$db_pass['password'], stripslashes() just incase:

    $db_pass['password'] = stripslashes($db_pass['password']);
    $_SESSION['password'] = stripslashes($_SESSION['password']);

    //compare:

    if($_SESSION['password'] == $db_pass['password']) {
        // valid password for username
        $logged_in = 1; // they have correct info
                    // in session variables.
    } else {
        $logged_in = 0;
        unset($_SESSION['username']);
        unset($_SESSION['password']);
        // kill incorrect session variables.
    }
}

// clean up
unset($db_pass['password']);

$_SESSION['username'] = stripslashes($_SESSION['username']);

?>


8)Save the file.
9)Create another file and name it login.php and paste the following code:
CODE
<?php

// database connect script.

require 'db_connect.php';

if($logged_in == 1) {
    die('You are already logged in, '.$_SESSION['username'].'.');

}

?>
<html>
<head>
<title>Login</title>
</head>
<body>
<?php

if (isset($_POST['submit'])) { // if form has been submitted



    /* check they filled in what they were supposed to and authenticate */

    if(!$_POST['uname'] | !$_POST['passwd']) {

        die('You did not fill in a required field.');

    }



    // authenticate.



    if (!get_magic_quotes_gpc()) {

        $_POST['uname'] = addslashes($_POST['uname']);

    }



    $qry = "SELECT username, password FROM users WHERE username = '".$_POST['uname']."'";
    $sqlmembers = mysql_query($qry);
$info = mysql_fetch_array ($sqlmembers);

    $check = mysql_num_rows ($sqlmembers);



    if ($check == 0) {

        die('That Account does not exist in our database.');

    }






    // check passwords match



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

    $info['password'] = stripslashes($info['password']);

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



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

        echo "Incorrect password, please try again.";

    }



    // if we get here username and password are correct,

    //register session variables and set last login time.



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



    $qry = "UPDATE users SET last_login = '$date' WHERE username = '".$_POST['uname']."'";

    $query=mysql_query($qry);



    $_POST['uname'] = stripslashes($_POST['uname']);

    $_SESSION['username'] = $_POST['uname'];

    $_SESSION['password'] = $_POST['passwd'];



?>
<h1>Logged in</h1>
<p>Welcome back <?php echo $_SESSION['username']; ?>, you are logged in.</p>

<?php

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

?>
<h1>Login</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 colspan="2" align="right">
<input type="submit" name="submit" value="Login">
</td></tr>
</table>
</form>
<?php
}
?>
</body>
</html>


10)save the file.
11)now make a new file and call it logout.php and put in the following code. but remember to change the __URL__to the page you want them to go to after they log out.
CODE
<?php

require 'db_connect.php';    // database connect script.

if ($logged_in == 0) {
    die('You are not logged in so you cannot log out.');
}

unset($_SESSION['username']);
unset($_SESSION['password']);
// kill session variables
$_SESSION = array(); // reset session array
session_destroy();   // destroy session.
header('Location: __URL__');
// redirect them to anywhere you like.
?>


12)after you save it, open whatever page you would like to protect.
13)add the following code before your header:
CODE
<?php

require 'db_connect.php';

// require our database connection
// which also contains the check_login.php
// script. We have $logged_in for use.

if ($logged_in == 0) {
    ?>


14)then add the conent you want them to see if they are not logged in.(for example:)
CODE
<?php

require 'db_connect.php';

// require our database connection
// which also contains the check_login.php
// script. We have $logged_in for use.

if ($logged_in == 0) {
    ?>
<html>
<head>
<title>Member Profile</title>
</head>
<body>
Im sorry, but you must be logged in to view this page!
</body>
</html>


15)now add
CODE
<?php
}
else {  ?>

after the end of what you wish to show to those not logged in. Now we will add the content that we will show the logged in users.
CODE
<html>
<head>
<title>Member Profile</title>
</head>
<body>
Welcome to the members only section!!!</body>
</html>


16)now we need to end the if/else statement with the following code:
CODE
<?php
}
?>


17) this should be what your members only page would look like:
CODE
<?php

require 'db_connect.php';

// require our database connection
// which also contains the check_login.php
// script. We have $logged_in for use.

if ($logged_in == 0) {
    ?>
<html>
<head>
<title>Member Profile</title>
</head>
<body>
Im sorry, but you must be logged in to view this page!
</body>
</html>
<?php
}
else {  ?>
<html>
<head>
<title>Member Profile</title>
</head>
<body>
Welcome to the members only section!!!</body>
</html>
<?php
}
?>


now save it.

And there you have it! A nice users script that will automatically add users to the datavase once they register, and will them to log in and access special pages!!

If you have any questions, PM me or visit my website at www.city-scapes.net.
wozzym
wow excellent job. ill try it tomorrow. biggrin.gif

Edit: php right? (im just learning php right now)
uncled1023
yes, its php
Gollum
Thank you so much. I have been looking for a decent tutorial on simple login scripts and never was able to find an easy to follow one.

Just a little stupid question though (I don't know PHP currently), does the database information in the code (has $ before it) able to be seen by users accessing the site, what I mean is it visible on the source code?
uncled1023
no, because it is before the <head>. glad you like it!
MrTouz
what could be good is an other tut based on this one with a user profile ! which is something ALL these scripts are missing
Crown
QUOTE(MrTouz @ Mar 8 2008, 01:41 PM) *
what could be good is an other tut based on this one with a user profile ! which is something ALL these scripts are missing

I may do one laters on when im not busy and not onway out tongue.gif
Banjo
QUOTE(MrTouz @ Mar 8 2008, 01:41 PM) *
what could be good is an other tut based on this one with a user profile ! which is something ALL these scripts are missing


He has a user profile up on his site which he may release the source for and im currently helping him to make it so you can edit details.
wozzym
ya if not ill try to make one tongue.gif
uncled1023
yes, i will release the user profile and view others profile system later, and also i might put up a tutorial for a pm system integrating the users...
anhbinh
Good Keep post
Soul Of Me
Added it and it works perfectly!
I would R3p you if it was possible!
Crown
QUOTE(Soul Of Me @ Mar 10 2008, 08:59 PM) *
Added it and it works perfectly!
I would R3p you if it was possible!

On his profile where his avatar is there is a like 5star thing you can click on a star which i think gives him rep
Crown
I seemed to be haveing problems with this script ...
http://www.crownstyles.com/LogSystem/register.php
What can i do ?

Meh dont matter doing my own
uncled1023
it looks like you have the registration alligned right, try alligning it center.
Banjo
If you planning on using this then you might want to add something to the registration script.

Read this

http://www.pixel2life.com/publish/tutorial...ord_encryption/

Will make it more secure.
ORiOn
cant create the table sad.gif


error:

CREATE TABLE users(
id int( 10 ) DEFAULT '0' NOT NULL AUTO_INCREMENT ,
username varchar( 40 ) ,
PASSWORD varchar( 50 ) ,
regdate varchar( 20 ) ,
email varchar( 100 ) ,
website varchar( 150 ) ,
location varchar( 150 ) ,
show_email int( 2 ) DEFAULT '0',
last_login varchar( 20 ) ,
PRIMARY KEY ( id )
)

Mensagens do MySQL : Documentação
#1067 - Invalid default value for 'id'



tanks for any help
uncled1023
yea, there is a problem. so i just manually installed it.
theraptor
This looks good. Is there a way you can import users from and already existing database and add users that join here to that database?
uncled1023
yes, you would just need to copy the following and add it right above the "insert into" script.
CODE
$insert = "INSERT INTO users (
            username,
            password,
            regdate,
            email,
            website,
            location,
            show_email,
            last_login)
            VALUES (
            '".$_POST['uname']."',
            '".$_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());
    }
require('db_connect.php');

and change the "users" to the other table you want to use. now if you are using a different database, then you will also have to make another db_connect2 with the right information for the new database and put a
CODE
require('db_connect2.php');
before the above script, and the entire script.
Nexus
I am so trying this script out. And if it works, then friggin own. This thing will be absolutely perfect for what I'm hoping to achieve...

*cough*WORLDDOMINATION*cough*

xD
uncled1023
lol, for a live exaple of what you can do with it, just go to my site. its in my sig.
ORiOn
Fatal error: Class 'DB' not found in /home/orion/public_html/testes/members system/db_connect.php on line 17

What's wrong??? wacko.gif wink.gif sad.gif


Line 17:
CODE
$db_object = DB::connect($datasource, TRUE);

uncled1023
are you using zymic hosting?
ORiOn
QUOTE(uncled1023 @ Mar 22 2008, 07:51 PM) *
are you using zymic hosting?



No unsure.gif
uncled1023
ok, does your hosting have PEAR installed?
ORiOn
QUOTE(uncled1023 @ Mar 22 2008, 09:19 PM) *
ok, does your hosting have PEAR installed?



humm.. i don't know, yes i supose...
uncled1023
ok, cause the DB.php is in the PEAR system. and without it, the user system will not work. i have not figured out a way to get it to work without it yet. but i should have a solution soon.
ORiOn
i had erase the require_once 'DB.php'; , and naw i writ ir again
ad i receive this error:

CODE
Warning: require_once(DB.php) [function.require-once]: failed to open stream: No such file or directory in /home/orion/public_html/testes/members system/db_connect.php on line 5

Fatal error: require_once() [function.require]: Failed opening required 'DB.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/orion/public_html/testes/members system/db_connect.php on line 5


Line 5:
CODE
require_once 'DB.php';
uncled1023
yea, its trying to look for the PEAR. but it doesnt have it. so ill try and find a connection that doesnt require a DB.php. should be simple.
ORiOn
QUOTE(uncled1023 @ Mar 22 2008, 09:32 PM) *
yea, its trying to look for the PEAR. but it doesnt have it. so ill try and find a connection that doesnt require a DB.php. should be simple.



ok
Tanks
uncled1023
ok... i cant figure out a way to transfer from the PEAR:biggrin.gifB format to another older format... Version 4.1.2 of PHP builds PEAR by default, but any version below that doesnt have PEAR. so im sorry, but maybe there is a way for your hosting company to upgrade their php system.
krazytaco
Hey, great system it appears. I do have one problem with it though. I have succesfully registered an accoutn and have logged it in. The login page confrims my test user is logged in. I modified the login page to then redirect back to 'index.php' when that happens though, I am returned with

CODE
Fatal error: Call to undefined method DB_Error::fetchRow() in [path]/check_login.php on line 29


Any ideas what thats about?
uncled1023
ok, did you change any of the code in the index.php?
krazytaco
My index.php file looks like this

CODE
<?php include("header.php"); ?>
<?php include('includes/include_connect.php'); ?>

<?php if ($logged_in == 0) {
    echo 'Sorry you are not logged in, this area is restricted to registered members. ';
    echo '<a href="login.php">Click here</a> to log in.';
    exit;
}
?>

...HTML FORM...


include_connect.php is simply db_connect.php with a different name. After the last php close it simply trails off into a form.
uncled1023
ok, is the index the one you are trying to have the login box in? or is it the one you are trying to block.
krazytaco
Well, I figured I would just add the login check to every page, just to ensure that users are logged in no matter which page they try to access.

Basically, I want users to start out at index.php, so I have it checking if they're logged in and if they aren't redirecting them to login.php. Once they've submitted on login.php, the page redirects them back to index.php. From there they can navigate to any other portion of the site, but each page should be verifying that they are logged in.
uncled1023
ok, if you want to Redirect the person to the login page, i would suggest this script.
CODE
<script type="text/javascript">
<!--
window.location = "/login.php"
//-->
</script>


because it automatically directs them there. so your index.php would look like this.
CODE
<?php include('includes/include_connect.php'); ?> //make sure this code and any other require codes are above your <head>

<?php include("header.php"); ?>
<?php include('includes/include_connect.php'); ?>

<?php if ($logged_in == 0) {
    <script type="text/javascript">
<!--
window.location = "/login.php"
//-->
</script>
}
else {

?>

...HTML FORM...

</body>
</html>
<?php
}
?>
krazytaco
Okay, well that script works but it doesn't solve the original problem. After a user has typed in their login details and once they have clicked "Login", they are greeted with the "Welcome _username_" message, and from there are redirected to index.php, where the same error is now appearing

(Fatal error: Call to undefined method DB_Error::fetchRow() in [path]/check_login.php on line 29)

I think the problem invloves check_login.php somehow, but I'm not entirely sure what some of the db functions you were using for it are, so I'm having problems debugging it. The code for check_login.php is

CODE
<?php

/* check login script, included in db_connect.php. */

session_start();

if (!isset($_SESSION['username']) || !isset($_SESSION['password'])) {
    $logged_in = 0;
    return;
} else {

    // remember, $_SESSION['password'] will be encrypted.

    if(!get_magic_quotes_gpc()) {
        $_SESSION['username'] = addslashes($_SESSION['username']);
    }

    // addslashes to session username before using in a query.
    $qry = "SELECT password FROM users WHERE username = '".$_SESSION['username']."'";
    $pass = $db_object->query($qry);

    if(DB::isError($pass) || $pass->numRows() != 1) {
        $logged_in = 0;
        unset($_SESSION['username']);
        unset($_SESSION['password']);
        // kill incorrect session variables.
    }

    $db_pass = $pass->fetchRow(); //This is line 29

    // now we have encrypted pass from DB in
    //$db_pass['password'], stripslashes() just incase:

    $db_pass['password'] = stripslashes($db_pass['password']);
    $_SESSION['password'] = stripslashes($_SESSION['password']);

    //compare:

    if($_SESSION['password'] == $db_pass['password']) {
        // valid password for username
        $logged_in = 1; // they have correct info
                    // in session variables.
    } else {
        $logged_in = 0;
        unset($_SESSION['username']);
        unset($_SESSION['password']);
        // kill incorrect session variables.
    }
}

// clean up
unset($db_pass['password']);

$_SESSION['username'] = stripslashes($_SESSION['username']);

?>
uncled1023
hm... it looks like the same one that i am using. what is your login.php script look like...
NeoCodes
I do not get the database variable. What is a database variable? It Says:

insert the following code into the file and change the database variables to match yours.
and then another thing says to insert a code to phpadmin. where is that. everythime i click phpadmin
on zymic it just wants me to login. HELP!! I DONT GET THIS STUFF..
krazytaco
QUOTE
I do not get the database variable. What is a database variable? It Says:

insert the following code into the file and change the database variables to match yours.


Those details are how you connect to your database
CODE
$db_engine = 'mysql';
$db_user = 'username';
$db_pass = 'password';
$db_host = 'hostname';
$db_name = 'database name';


The Engine is which database you use, so if for example you use MySQL, you put "mysql".
User is the username to connect to the database
Password is the password
Host is the address where you can reach your server at
Name is the name of the database within the server you want to use


Anyways, my login.php looks like this.


Edit: Fixed the problem, I had misnamed a variable within check_login.php
NeoCodes



QUOTE(krazytaco @ Mar 25 2008, 06:13 PM) *
Those details are how you connect to your database
CODE
$db_engine = 'mysql';
$db_user = 'username';
$db_pass = 'password';
$db_host = 'hostname';
$db_name = 'database name';


The Engine is which database you use, so if for example you use MySQL, you put "mysql".
User is the username to connect to the database
Password is the password
Host is the address where you can reach your server at
Name is the name of the database within the server you want to use
Anyways, my login.php looks like this.
CODE
<?php

// database connect script.

require 'includes/include_connect.php';

if($logged_in == 1) {
    die('You are already logged in, '.$_SESSION['username'].'.');

}

?>
<html>
<head>
<title>Login</title>
</head>
<body>
<?php

if (isset($_POST['submit'])) { // if form has been submitted

    /* check they filled in what they were supposed to and authenticate */
    if(!$_POST['uname'] | !$_POST['passwd']) {
        die('You did not fill in a required field.');
    }

    // authenticate.

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

    $qry = "SELECT username, password FROM ransom_users WHERE username = '".$_POST['uname']."'";
    $check = $db_object->query($qry);

    if (DB::isError($check) || $check->numRows() == 0) {
        die('That username does not exist in our database.');
    }

    $info = $check->fetchRow();

    // check passwords match

    $_POST['passwd'] = stripslashes($_POST['passwd']);
    $info['password'] = stripslashes($info['password']);
    $_POST['passwd'] = md5($_POST['passwd']);

    if ($_POST['passwd'] != $info['password']) {
        die('Incorrect password, please try again.');
    }

    // if we get here username and password are correct,
    //register session variables and set last login time.

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

    $qry = "UPDATE ransom_users SET last_login = '$date' WHERE username = '".$_POST['uname']."'";
    $update_login = $db_object->query($qry);

    $_POST['uname'] = stripslashes($_POST['uname']);
    $_SESSION['username'] = $_POST['uname'];
    $_SESSION['password'] = $_POST['passwd'];
    $db_object->disconnect();
?>

<h1>Logged in</h1>
<p>Welcome back <?php echo $_SESSION['username']; ?>, you are logged in.</p>
<meta http-equiv="REFRESH" content="0;url=http://www.two47youth.com/index.php"></HEAD>

<?php

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

?>
<h1>Login</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 colspan="2" align="right">
<input type="submit" name="submit" value="Login">
</td></tr>
</table>
</form>
<?php
}
?>
</body>
</html>


im using zymic hosting. my website is neocodes.clanteam.com would you like to set up my php for me? i just dont get it whatsoever.
wozzym
its not too hard. but im sure someone wouldnt mind doing it.
uncled1023
hm, i checked out your site, and it looks like you are trying to use a php code on a .html page. if you are using ANY php on that page, it HAS to be a .php page.
oziyn
ok im geting a db connection error when i try accesing any of the pages i just made
oziyn
why tha frig am i getting this

Parse error: syntax error, unexpected '.' in /www/99k.org/s/i/n/sinfull/htdocs/members/db_connect.php on line 15
uncled1023
in your db_connect.php, you have a period somewhere where it doesnt belong.

QUOTE(oziyn @ Apr 1 2008, 08:02 PM) *
ok im geting a db connection error when i try accesing any of the pages i just made

do you have your database username and password right in your db_connect.php?
oziyn
well actually i hav the period right after the passowrd like you have in ur guide
and is it my zymic username and pass or is it my db user and pass?

this is what i have on mine
CODE
<?php

//require the PEAR:biggrin.gifB classes.

require_once 'DB.php';

$db_engine = 'mysql';
$db_user = 'username';
$db_pass = 'password';
$db_host = 'localhost';
$db_name = 'database';

$datasource = $db_engine = 'mysql';
$db_user = 'sinfull_99k_org_chill';
$db_pass = '*********';.
$db_host = 'localhost';
$db_name = 'sinfull_99k_org_chill';

$db_object = DB::connect($datasource, TRUE);

/* assign database object in $db_object,

if the connection fails $db_object will contain

the error message. */

// If $db_object contains an error:

// error and exit.

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

$db_object->setFetchMode(DB_FETCHMODE_ASSOC);

//
include('check_login.php');
RoteX
Hey,

I must be retarded or something... i can't get to Step3, im stuck at Step2. hunter.gif
Can't import this to phpMyAdmin,

CODE
CREATE TABLE users (
id int(10) DEFAULT '0' NOT NULL auto_increment,
username varchar(40),
password varchar(50),
regdate varchar(20),
email varchar(100),
website varchar(150),
location varchar(150),
show_email int(2) DEFAULT '0',
last_login varchar(20),
PRIMARY KEY(id))


So, i tryed to do it manualy.. still the same error there,
CODE
CREATE TABLE `users` (
`id` INT( 10 ) NOT NULL DEFAULT '0' AUTO_INCREMENT ,
`username` VARCHAR( 40 ) NOT NULL ,
`password` VARCHAR( 50 ) NOT NULL ,
`regdate` VARCHAR( 20 ) NOT NULL ,
`email` VARCHAR( 100 ) NOT NULL ,
`website` VARCHAR( 150 ) NOT NULL ,
`location` VARCHAR( 150 ) NOT NULL ,
`show_email` INT( 2 ) NOT NULL DEFAULT '0',
`last_login` VARCHAR( 20 ) NOT NULL
) TYPE = innodb

MySQL :
#1067 - Invalid default value for 'id'


Some help would be nice. wacko.gif

Edit: It's fixed.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.