8 Replies - 7226 Views - Last Post: 11 December 2002 - 10:26 AM Rate Topic: -----

#1 iamcenz  Icon User is offline

  • You wish you were my hand!
  • member icon

Reputation: 7
  • View blog
  • Posts: 2,442
  • Joined: 26-March 01

if-then-else

Posted 05 December 2002 - 07:27 PM

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?

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


Is This A Good Question/Topic? 0
  • +

Replies To: if-then-else

#2 fyrestorm  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 10
  • View blog
  • Posts: 3,113
  • Joined: 04-April 02

Re: if-then-else

Posted 05 December 2002 - 07:34 PM

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

why don't you try this:

<?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)
Was This Post Helpful? 0
  • +
  • -

#3 iamcenz  Icon User is offline

  • You wish you were my hand!
  • member icon

Reputation: 7
  • View blog
  • Posts: 2,442
  • Joined: 26-March 01

Re: if-then-else

Posted 05 December 2002 - 07:39 PM

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

<?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);
?>



Was This Post Helpful? 0
  • +
  • -

#4 Cookie Mobster  Icon User is offline

  • nooneenooneenooonee
  • member icon

Reputation: 7
  • View blog
  • Posts: 4,730
  • Joined: 12-October 01

Re: if-then-else

Posted 05 December 2002 - 07:40 PM

Also it you remove the ; from the if line, the php parser interprets it to be the end of the if statement.
Was This Post Helpful? 0
  • +
  • -

#5 iamcenz  Icon User is offline

  • You wish you were my hand!
  • member icon

Reputation: 7
  • View blog
  • Posts: 2,442
  • Joined: 26-March 01

Re: if-then-else

Posted 05 December 2002 - 07:46 PM

i made it one set of <? ?> and i removed the ;... but its still giving me the error.
Was This Post Helpful? 0
  • +
  • -

#6 Cookie Mobster  Icon User is offline

  • nooneenooneenooonee
  • member icon

Reputation: 7
  • View blog
  • Posts: 4,730
  • Joined: 12-October 01

Re: if-then-else

Posted 05 December 2002 - 08:11 PM

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

:lol:
Was This Post Helpful? 0
  • +
  • -

#7 iamcenz  Icon User is offline

  • You wish you were my hand!
  • member icon

Reputation: 7
  • View blog
  • Posts: 2,442
  • Joined: 26-March 01

Re: if-then-else

Posted 05 December 2002 - 08:39 PM

ok, well no more errors thanks sam and fyrestorm
Was This Post Helpful? 0
  • +
  • -

#8 arniie  Icon User is offline

  • D.I.C Addict

Reputation: 0
  • View blog
  • Posts: 999
  • Joined: 08-October 02

Re: if-then-else

Posted 06 December 2002 - 03:55 AM

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 ??????
Was This Post Helpful? 0
  • +
  • -

#9 skrilla  Icon User is offline

  • boots.

Reputation: 2
  • View blog
  • Posts: 3,096
  • Joined: 05-July 02

Re: if-then-else

Posted 11 December 2002 - 10:26 AM

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

<?php echo(); ?>
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1