Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,648 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,110 people online right now. Registration is fast and FREE... Join Now!




if-then-else

 
Reply to this topicStart new topic

if-then-else

iamcenz
post 5 Dec, 2002 - 06:27 PM
Post #1


You wish you were my hand!

Group Icon
Joined: 26 Mar, 2001
Posts: 2,385



Dream Kudos: 201
My Contributions


ok, i need to know how to do this, im working on something to set up a admin center for a blog system i plan i writting, well right now im working on the user authentification, so i set up a user login and stuff, now i need to test it to make sure it logs in, but i cant seem to set up the if else stuff, this is what i got, can you tell me what i am doing wrong?

CODE

17: <?php if ((!$userid) || (!$username) || (!$password)) exit; ?>
18: <?php else include(home.php); ?>


and this is the parse error:
QUOTE

Parse error: parse error, unexpected T_ELSE in D:\foxserv\www\php\login.php on line 18
User is offlineProfile CardPM

Go to the top of the page

fyrestorm
post 5 Dec, 2002 - 06:34 PM
Post #2


D.I.C Lover

Group Icon
Joined: 4 Apr, 2002
Posts: 3,103



Thanked 2 times

Dream Kudos: 228
My Contributions


just out of curiosity why do you have the two different lines within <?php ?>

why don't you try this:

CODE

<?php
  if ((!$userid) || (!$username) || (!$password)) exit;
  else include(home.php);
?>


although that may not make any difference

one thought is that sometimes even though it gives you a line that it thinks the error is on, it can possibly occur before that line... (you're a programmer though so i'm sure you knew that)
User is offlineProfile CardPM

Go to the top of the page

iamcenz
post 5 Dec, 2002 - 06:39 PM
Post #3


You wish you were my hand!

Group Icon
Joined: 26 Mar, 2001
Posts: 2,385



Dream Kudos: 201
My Contributions


yeah i know that, but there is nothing else on the page really, look,

CODE

<?php require_once('Connections/conn.php'); ?>
<?php
mysql_select_db($database_conn, $conn);
$query_login = "SELECT * FROM users";
$login = mysql_query($query_login, $conn) or die(mysql_error());
$row_login = mysql_fetch_assoc($login);
$totalRows_login = mysql_num_rows($login);
?>
<html>
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<p>
 <?php if ((!$userid) || (!$username) || (!$password)) exit; ?>
 <?php else include(home.php); ?>
</p>
<form name="form1" method="post" action="">
 <input name="userid" type="hidden" id="userid">
 <br>
 username:
 <input name="username" type="text" id="username">
 <br>
 password:
 <input name="password" type="text" id="password">
 <br>
 <input type="submit" name="Submit" value="Login">
</form>
</body>
</html>
<?php
mysql_free_result($login);
?>

User is offlineProfile CardPM

Go to the top of the page

Cookie Mobster
post 5 Dec, 2002 - 06:40 PM
Post #4


nooneenooneenooonee

Group Icon
Joined: 12 Oct, 2001
Posts: 4,723



Dream Kudos: 18
My Contributions


Also it you remove the ; from the if line, the php parser interprets it to be the end of the if statement.
User is offlineProfile CardPM

Go to the top of the page

iamcenz
post 5 Dec, 2002 - 06:46 PM
Post #5


You wish you were my hand!

Group Icon
Joined: 26 Mar, 2001
Posts: 2,385



Dream Kudos: 201
My Contributions


i made it one set of <? ?> and i removed the ;... but its still giving me the error.
User is offlineProfile CardPM

Go to the top of the page

Cookie Mobster
post 5 Dec, 2002 - 07:11 PM
Post #6


nooneenooneenooonee

Group Icon
Joined: 12 Oct, 2001
Posts: 4,723



Dream Kudos: 18
My Contributions


lol, you have to choose one of the two, either remove the ; or make one set of <?php ?>.

laugh.gif
User is offlineProfile CardPM

Go to the top of the page

iamcenz
post 5 Dec, 2002 - 07:39 PM
Post #7


You wish you were my hand!

Group Icon
Joined: 26 Mar, 2001
Posts: 2,385



Dream Kudos: 201
My Contributions


ok, well no more errors thanks sam and fyrestorm
User is offlineProfile CardPM

Go to the top of the page

arniie
post 6 Dec, 2002 - 02:55 AM
Post #8


D.I.C Addict

****
Joined: 8 Oct, 2002
Posts: 999

just out of pure curiosity, which do you lot prefer using: (i know it makes no difference)

<?php ?> || <? ?>

and do you lot use <?= OR <? echo ??????
User is offlineProfile CardPM

Go to the top of the page

skrilla
post 11 Dec, 2002 - 09:26 AM
Post #9


boots.

*****
Joined: 5 Jul, 2002
Posts: 2,848



Dream Kudos: 14
My Contributions


uh........................

<?php echo(); ?>
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 04:56AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month