Viewing Topic: "member
system
tutorial"
question |
Persis |
Subject: ""member
system
tutorial"..."
Posted: @ 6:00 am on Jul 16 2008 |
|
|
Member #: 719 Rank: User - (7) Since: 07/16/08 Posts: 6 From: USA
|
I've done
everything up
until the login
page, and it
looks like all
my code is in
order, no
errors or
anything. I
tried to
register though
as a test run,
and it just
clears the form
when I press
it. Is there
any reason
why?
my test site is
here. I'd
appreciate any
help! ^_^
|
| Viewed: 12,066 Times | |  |
Genius |
Subject: "re:
"member
system
tutorial&..."
Posted: @ 11:10 am on Jul 16 2008
|
|
|
 Member #: 582 Rank: User - (77) Since: 02/18/08 Posts: 76 From: kmmk
|
Try this:
Code:
<?php
session_start()
;
require_once('
db_connect.php
');
//SEE IF
ALREADY LOGGED
IN
if($_SESSION['
logged_in'] ==
1)
{
//REDIRECT TO
HOMEPAGE
header('Locati
on: http://' .
$_SERVER['HTTP
_HOST'] .
'');
} else {
if(isset($_POST
['submit']))<
br />
{
//BEGIN
CHECKING
USERNAME...
if(!$_POST['us
ername'])
die('Alert:
username field
was
blank.');
//array of
invalid
characters
$junk =
array('.' ,
',' , '/' ,
'\'' ,
'`' , ';' ,
'[' , ']' ,
'-', '_',
'*',
'&',
'^', '%',
'$', '#',
'@', '!',
'~', '+',
'(', ')',
'|', '{',
'}',
'<',
'>',
'?', ':',
'"',
'=');
//starting
lenght of
username
$len =
strlen($_POST[
'username']);<
br />
//replace
invalid
characters
$_POST['userna
me'] =
str_replace($ju
nk, '',
$_POST['userna
me']);
$test =
$_POST['userna
me'];
//if lenghts
are different
($len smaller),
invalid
characters
found, so
prompt
error.
if(strlen($test
) != $len) {
die('Username
Error: Username
contained
invalid
characters. You
can only use
A-Z, 0-9 and
the
underscore
(_).');
}
//Check if
username
already
exists...
$q2 =
mysql_query(&q
uot;SELECT *
FROM `members`
WHERE
`username` =
'".$_POS
T['username']
."'&quo
t;;
$q3 =
mysql_fetch_obj
ect($q2);
if($q3->user
name ==
$_POST['userna
me']) {
die('<BR>
;<BR>Sorr
y, but the
username
"'.$q3-&
gt;username.'
" is
taken, please
choose
another.');
}
//PASSWORD
if(!$_POST['pa
ssword']) {
die('Error:
Password field
was
blank');
}
if(!$_POST['ve
rify_password'
]) {
die('Error:
Verify Password
field was
blank.');
}
if($_POST['pas
sword'] !=
$_POST['verify
_password'])
{
die('Error:
The passwords
do not
match.');
}
if(strlen($_POS
T['password']
) < 6 ) {
die('Error:
Your password
is too short.
Must be 6 or
more characters
in
length.');
}
//ADD NEW
MEMBER
$insert
="INSERT
INTO `members`
(username,
user_password,
user_email)
VALUES
('".$_PO
ST['username'
]."',
'".md5($
_POST['passwor
d'])."'
,
'".$_POS
T['email'].&
quot;')"
;
$insert2 =
mysql_query($in
sert);
if(!$insert2)
die(mysql_error
());
echo('Registra
tion
Successful,
Welcome new
member! You can
now login to
your new
account.');
} else {
header("L
ocation:
login.php"
;;
} //end not
logged in
} //end submit
not pressed
?>
Change the
paths to yours.
|
Viewed: 12,061 Times | |  |
Persis |
Subject: "re:
"member
system
tutorial&..."
Posted: @ 3:45 pm on Jul 18 2008
|
|
|
Member #: 719 Rank: User - (7) Since: 07/16/08 Posts: 6 From: USA
|
thanks. I
think, since I
just recently
found your
edition of
bs0d's
tutorial, I'll
try that
instead. 
|
| Viewed: 12,030 Times | |  |
roym |
Subject: "re:
"member
system
tutorial&..."
Posted: @ 10:49 am on Sep 19 2008
|
|
|
 Member #: 752 Rank: User - (9) Since: 09/12/08 Posts: 9
|
how would i got
about linking
the comments to
the member
system so that
only members
can post but
all visitors
can view...
|
Viewed: 11,754 Times | |  |
Persis |
Subject: "re:
"member
system
tutorial&..."
Posted: @ 3:03 am on Sep 21 2008
|
|
|
Member #: 719 Rank: User - (7) Since: 07/16/08 Posts: 6 From: USA
|
you can set it
so you can
check IF
session/cookies
are set, then
show the
"post a
comment
form,"
ELSE show the
viewer that
they must login
to comment.
I switched to a
friend's
domain and I
have had a lot
more success
using various
things and
putting them
together. It's
helped me learn
more php too ^^
|
| Viewed: 11,724 Times | |  |
roym |
Subject: "re:
"member
system
tutorial&..."
Posted: @ 7:25 am on Sep 22 2008
|
|
|
 Member #: 752 Rank: User - (9) Since: 09/12/08 Posts: 9
|
and i would ad
the if and else
into member
system as
well..
|
Viewed: 11,694 Times | |  |
roym |
Subject: "re:
"member
system
tutorial&..."
Posted: @ 9:56 am on Sep 23 2008
|
|
|
 Member #: 752 Rank: User - (9) Since: 09/12/08 Posts: 9
|
would this
be correct?
Code:
//user must be
logged in
if($_SESSION['
logged_in'] ==
1) {
?>
<h3
id="respo
nd">Le
ave a
Reply</h3>
;
<br>
<form
name="com
ments"
action="&
lt;?
$_SERVER['PHP_
SELF'];
?>"
method="p
ost">
<input
type="hid
den"
name="pag
e"
value="&l
t;?
echo($_SERVER[
'REQUEST_URI']
);
?>">
;
<input
type="hid
den"
name="dat
e"
value="&l
t;?
echo(date(&quo
t;F j,
Y."  );
?>">
;
<input
type="hid
den"
name="tim
e"
value="&l
t;?
echo(time());
?>">
;
<table
width="90
%"
border="0
"
cellspacing=&q
uot;0"
cellpadding=&q
uot;0">
;
<tr>
<td><d
iv
align="ri
ght">U
sername:
</div><
;/td>
<td><i
nput
name="use
rname"
type="tex
t"
size="30
"
value="&
quot;></t
d>
</tr>
<tr>
<td><d
iv
align="ri
ght">C
ontact:
</div><
;/td>
<td><i
nput
type="tex
t"
name="con
tact"
size="30
"
value="&
quot;>
<i>(email
or
url)</i>&
lt;/td>
</tr>
<td><d
iv
align="ri
ght">S
ubject:
</div><
;/td>
<td><i
nput
type="tex
t"
name="sub
ject"
size="30
"
value="&
quot;></t
d>
</tr>
<tr>
<td><d
iv
align="ri
ght">C
omment:
</div><
;/td>
<td><t
extarea
name="com
ment"
cols="45
"
rows="5&
quot;
wrap="VIR
TUAL">
</textarea&g
t;</td>
</tr>
<tr>
<td></
td>
<td
colspan="
2"><
;input
type="res
et"
value="Re
set"
style="ba
ckground:
#2c2c2c;
font-family:
vrinda; color:
white; border:
0; width:80;
height=
20;">
<input
type="sub
mit"
name="sub
mit"
value="Ad
d
Comment"
style="ba
ckground:
#2c2c2c;
font-family:
vrinda; color:
white; border:
0; width:80;
height=
20;">&
lt;/td>
</tr>
</table>
</form>
<?
} else {
if($_SESSION['
logged_in'] ==
0)
echo 'You must
be a registered
member to
comment';
}
?>
Edited at 09:58:26 am on 09/23/08
|
Viewed: 11,680 Times | |  |
Viewing Page: 1 of 1 |
|