Jump to content


login or out let the machine decide.


3 replies to this topic

#1 Spyder

    Jedi In Training

  • Members
  • PipPip
  • 438 posts
  • Gender:Male
  • Location:London, UK

Posted 12 November 2005 - 06:21 PM

thnx to rc69 i have a working phpbb integrated login. but if you are already logged in i don't want it to show the login box but a logout box instead and vice versa.

Thinking i hade the right idea i came up with this:
(i have added the line numbers so its easy to see.)
193 <?
194   if(!$_SESSION['username']){
195 echo " <form action="getin.php" method="POST">
196 Username: <input type="text" name="username">
197 Password: <input type="password" name="password" >
198 <input type="submit" value="submit" name="submit">
199 </form>
200 ";
201 }else{
202 echo "<div align="center"><form method="POST" action="logout.php">
203  <input type="submit" name="submit" value="logout">
204   </form></div></p>";
205 }
206 ?>

But I had this error:

Quote

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/pixels/public_html/idarkness/index.php on line 195


#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 12 November 2005 - 10:16 PM

Ok, you're going to have to start paying attention or nobody's going to help any more...
http://www.pixel2life.com/forums/index.php...ndpost&p=105900
http://php.net/manua...asic-syntax.php
Please read up a little bit before asking questions.
<?
if(!$_SESSION['username']){
  echo ' <form action="getin.php" method="POST">
  Username: <input type="text" name="username">
  Password: <input type="password" name="password" >
  <input type="submit" value="submit" name="submit">
  </form>
';
}else{
  echo '<div align="center"><form method="POST" action="logout.php">
  <input type="submit" name="submit" value="logout">
  </form></div></p>';
}
?>
Although, i do thank you for the error and line numbers :)

#3 Spyder

    Jedi In Training

  • Members
  • PipPip
  • 438 posts
  • Gender:Male
  • Location:London, UK

Posted 13 November 2005 - 04:57 AM

Oh yes, sorry rc69 i forgot about changing " to ' without the \ .
thnx again though, and I will think through and read some of the manual next time.

#4 maansson

    Young Padawan

  • Members
  • Pip
  • 132 posts
  • Gender:Male
  • Location:Lund, Sweden
  • Interests:Hmm, not much for Photoshop. Havn't taking time to learn it yet. Use Fireworks to the graphical area. More into coding and stuff. PHP, CSS, Java and of course HTML.

Posted 13 November 2005 - 04:03 PM

To overcome all these problems, why not do like this:
<?php
if($something) {
?>
<div align="center">Html code</div>
<?
}
else {
unt so weiter...
}
?>
Then you can always write you html-code the proper way. I rarely use "echo". Not very fond of it.

Sincerely yours,
maansson

Edited by maansson, 13 November 2005 - 04:04 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users