9 Replies - 3647 Views - Last Post: 24 January 2003 - 07:34 AM Rate Topic: -----

#1 kidd0  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 12-November 02

client login system..

Posted 22 January 2003 - 07:33 PM

I am working on a customer login system, for a computer selling company.
Its my first full php project, and its going good.

I need to include login.php into an existing php tag.
Heres part of the code.

<?php

require 'config.php';

if ($logged_in == 0) {
	die('
<HTML>
<HEAD>
<meta http-equiv="Content-Language" content="en-us">

<TITLE>Addict PC - The Ultimate System at the Ultimate Price</TITLE>
</HEAD>
<BODY BGCOLOR=#E9E9E9 topmargin="0">
<!-- ImageReady Slices (template.psd) -->
<TABLE WIDTH=750 BORDER=0 ALIGN="CENTER" CELLPADDING=0 CELLSPACING=0 bgcolor="#FFFFFF">
  <!--DWLayoutTable-->
  <TR> 
    <TD width="63"> <IMG SRC="images/spacer.gif" WIDTH=63 HEIGHT=1></TD>
    <TD width="81"> <IMG SRC="images/spacer.gif" WIDTH=81 HEIGHT=1></TD>
    <TD width="3"> <IMG SRC="images/spacer.gif" WIDTH=3 HEIGHT=1></TD>
    <TD width="53"> <IMG SRC="images/spacer.gif" WIDTH=53 HEIGHT=1></TD>
    <TD width="80"> <IMG SRC="images/spacer.gif" WIDTH=80 HEIGHT=1></TD>
    <TD width="110"> <IMG SRC="images/spacer.gif" WIDTH=110 HEIGHT=1></TD>
    <TD width="40"> <IMG SRC="images/spacer.gif" WIDTH=40 HEIGHT=1></TD>
    <TD width="140"> <IMG SRC="images/spacer.gif" WIDTH=140 HEIGHT=1></TD>
    <TD width="80"> <IMG SRC="images/spacer.gif" WIDTH=80 HEIGHT=1></TD>
    <TD width="100"> <IMG SRC="images/spacer.gif" WIDTH=100 HEIGHT=1></TD>
    <TD></TD>
  </TR>
  <TR> 
    <TD COLSPAN=2 ROWSPAN=2> <IMG SRC="images/topleftlogo.gif" WIDTH=144 HEIGHT=72></TD>
    <TD COLSPAN=2 ROWSPAN=2> <IMG SRC="images/logopc.gif" WIDTH=56 HEIGHT=72></TD>
    <TD COLSPAN=6> <IMG SRC="images/buttonlogo.gif" WIDTH=550 HEIGHT=44></TD>
    <TD> <IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=44></TD>
  </TR>
  <TR> 
    <TD> <a href="http://pc.addictgamers.com/computers.html"><img src="images/computers.gif" alt="Computers" name="computers" width="80" height="28" border="0"></a></TD>
    <TD> <a href="http://pc.addictgamers.com/how.html"><img src="images/howwework.gif" alt="How We Work" name="howwework" width="110" height="28" border="0"></a></TD>
    <TD> <a href="http://pc.addictgamers.com/faq.html"><img src="images/faq.gif" alt="FAQ" name="faq" width="40" height="28" border="0"></a></TD>
    <TD> <a href="http://pc.addictgamers.com/agreement.html"><img src="images/agreement.gif" alt="License Agreement" name="agreement" width="140" height="28" border="0"></a></TD>
    <TD> <a href="http://pc.addictgamers.com/support.html"><img src="images/support.gif" alt="Support" name="support" width="80" height="28" border="0"></a></TD>
    <TD> <IMG SRC="images/template_09.gif" WIDTH=100 HEIGHT=28></TD>
    <TD> <IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=28></TD>
  </TR>
  <TR> 
    <TD ROWSPAN=2> <A HREF="http://pc.addictgamers.com"> <IMG SRC="images/home.gif" WIDTH=63 HEIGHT=26 BORDER=0></A></TD>
    <TD ROWSPAN=2> <A HREF="http://pc.addictgamers.com/contact.html"> <IMG SRC="images/contact.gif" WIDTH=81 HEIGHT=26 BORDER=0></A></TD>
    <TD COLSPAN=8> <IMG SRC="images/barundrnav.gif" WIDTH=606 HEIGHT=18></TD>
    <TD> <IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=18></TD>
  </TR>
  <TR> 
    <TD> <IMG SRC="images/template_13.gif" WIDTH=3 HEIGHT=8></TD>
    <TD COLSPAN=7 ROWSPAN=2 valign="top"> <IMG SRC="images/header_how.gif" WIDTH=603 HEIGHT=85></TD>
    <TD> <IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=8></TD>
  </TR>
  <TR> 
    <TD COLSPAN=3 ROWSPAN=2 valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="images/nav.gif">
        <!--DWLayoutTable-->
        <tr> 
          <TD width="147" height="883" valign="top"><!--DWLayoutEmptyCell--><font color="000000" face="Verdana" size="2"><?php include("login.php");?></TD>


See the last part of code> the include? Well, I cannot have php in a php code such as the beginning of the code:
if ($logged_in == 0) {
	die('

How can I have an include, in HTML to show up login.php? If it cannot be done, how can I recode the
if ($logged_in == 0) {
	die('
to allow php inside the tags?

Is This A Good Question/Topic? 0
  • +

Replies To: client login system..

#2 Quik  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2
  • View blog
  • Posts: 3,750
  • Joined: 06-March 01

Re: client login system..

Posted 22 January 2003 - 10:35 PM

if this is what your asking, you could do this:


top of the page..

<?

if (isset($loggedin)) { }
else { header("Location: login.php"); }

?>



Put that at the top of the page.. This is usually used for a cookie though.. (which is usually how a login system works. You set a cookie to determine weather or not they have logged in.. so the original format was as follows:

<?

if (isset($HTTP_COOKIE_VARS['user'])) { }
else { header("Location: login.php"); }

?>

Was This Post Helpful? 0
  • +
  • -

#3 arniie  Icon User is offline

  • D.I.C Addict

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

Re: client login system..

Posted 23 January 2003 - 03:45 AM

quik is right..


i don't understand why you haven't closed the php tag:

(bold tags show what you could do....)

Quote

<?php

require 'config.php';

if ($logged_in == 0) {

header("Location: login.php");

} else {
?>

<HTML>
<HEAD>
<meta http-equiv="Content-Language" content="en-us">................

////bottom of page/////
<?
}
?>

Was This Post Helpful? 0
  • +
  • -

#4 kidd0  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 12-November 02

Re: client login system..

Posted 23 January 2003 - 05:14 AM

It is not using cookies.
It is setup using sessions.

Also, loggedin=0 is what non-logged in people see
and =1 is what logged in people see

I want it so that I can just include login.php, into logged in=1 without screwing up code.
Was This Post Helpful? 0
  • +
  • -

#5 MathewS  Icon User is offline

  • D.I.C Regular

Reputation: 18
  • View blog
  • Posts: 343
  • Joined: 14-May 02

Re: client login system..

Posted 23 January 2003 - 06:02 AM

is this what you are looking for?

Quote

<?php

require 'config.php';

if ($logged_in == 0) {
?>
<HTML>
<HEAD>
<meta http-equiv="Content-Language" content="en-us">

<TITLE>Addict PC - The Ultimate System at the Ultimate Price</TITLE>
</HEAD>
<BODY BGCOLOR=#E9E9E9 topmargin="0">
<!-- ImageReady Slices (template.psd) -->
<TABLE WIDTH=750 BORDER=0 ALIGN="CENTER" CELLPADDING=0 CELLSPACING=0 bgcolor="#FFFFFF">
<!--DWLayoutTable-->
<TR>
<TD width="63"> <IMG SRC="images/spacer.gif" WIDTH=63 HEIGHT=1></TD>
<TD width="81"> <IMG SRC="images/spacer.gif" WIDTH=81 HEIGHT=1></TD>
<TD width="3"> <IMG SRC="images/spacer.gif" WIDTH=3 HEIGHT=1></TD>
<TD width="53"> <IMG SRC="images/spacer.gif" WIDTH=53 HEIGHT=1></TD>
<TD width="80"> <IMG SRC="images/spacer.gif" WIDTH=80 HEIGHT=1></TD>
<TD width="110"> <IMG SRC="images/spacer.gif" WIDTH=110 HEIGHT=1></TD>
<TD width="40"> <IMG SRC="images/spacer.gif" WIDTH=40 HEIGHT=1></TD>
<TD width="140"> <IMG SRC="images/spacer.gif" WIDTH=140 HEIGHT=1></TD>
<TD width="80"> <IMG SRC="images/spacer.gif" WIDTH=80 HEIGHT=1></TD>
<TD width="100"> <IMG SRC="images/spacer.gif" WIDTH=100 HEIGHT=1></TD>
<TD></TD>
</TR>
<TR>
<TD COLSPAN=2 ROWSPAN=2> <IMG SRC="images/topleftlogo.gif" WIDTH=144 HEIGHT=72></TD>
<TD COLSPAN=2 ROWSPAN=2> <IMG SRC="images/logopc.gif" WIDTH=56 HEIGHT=72></TD>
<TD COLSPAN=6> <IMG SRC="images/buttonlogo.gif" WIDTH=550 HEIGHT=44></TD>
<TD> <IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=44></TD>
</TR>
<TR>
<TD> <a href="http://pc.addictgamers.com/computers.html"><img src="images/computers.gif" alt="Computers" name="computers" width="80" height="28" border="0"></a></TD>
<TD> <a href="http://pc.addictgamers.com/how.html"><img src="images/howwework.gif" alt="How We Work" name="howwework" width="110" height="28" border="0"></a></TD>
<TD> <a href="http://pc.addictgamers.com/faq.html"><img src="images/faq.gif" alt="FAQ" name="faq" width="40" height="28" border="0"></a></TD>
<TD> <a href="http://pc.addictgamers.com/agreement.html"><img src="images/agreement.gif" alt="License Agreement" name="agreement" width="140" height="28" border="0"></a></TD>
<TD> <a href="http://pc.addictgamers.com/support.html"><img src="images/support.gif" alt="Support" name="support" width="80" height="28" border="0"></a></TD>
<TD> <IMG SRC="images/template_09.gif" WIDTH=100 HEIGHT=28></TD>
<TD> <IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=28></TD>
</TR>
<TR>
<TD ROWSPAN=2> <A HREF="http://pc.addictgamers.com"> <IMG SRC="images/home.gif" WIDTH=63 HEIGHT=26 BORDER=0></A></TD>
<TD ROWSPAN=2> <A HREF="http://pc.addictgamers.com/contact.html"> <IMG SRC="images/contact.gif" WIDTH=81 HEIGHT=26 BORDER=0></A></TD>
<TD COLSPAN=8> <IMG SRC="images/barundrnav.gif" WIDTH=606 HEIGHT=18></TD>
<TD> <IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=18></TD>
</TR>
<TR>
<TD> <IMG SRC="images/template_13.gif" WIDTH=3 HEIGHT=8></TD>
<TD COLSPAN=7 ROWSPAN=2 valign="top"> <IMG SRC="images/header_how.gif" WIDTH=603 HEIGHT=85></TD>
<TD> <IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=8></TD>
</TR>
<TR>
<TD COLSPAN=3 ROWSPAN=2 valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="images/nav.gif">
<!--DWLayoutTable-->
<tr>
<TD width="147" height="883" valign="top"><!--DWLayoutEmptyCell--><font color="000000" face="Verdana" size="2"><?php include("login.php");?></TD>
<?php
} else {
echo "welcome"
}
?>

Was This Post Helpful? 0
  • +
  • -

#6 arniie  Icon User is offline

  • D.I.C Addict

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

Re: client login system..

Posted 23 January 2003 - 06:50 AM

errr...isn't that what i just said?

apart from, I'm confused....do you want people that ARE logged in (ie loggedin=1) to see the html (ie the page) ????

You can also do this as an include file..


anyway basically (as RDS said) you need to learn php b4 you start asking questions like this....as this is simple stuff.
Was This Post Helpful? 0
  • +
  • -

#7 Quik  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2
  • View blog
  • Posts: 3,750
  • Joined: 06-March 01

Re: client login system..

Posted 23 January 2003 - 10:04 AM

from my above code:

<?

if ($loggedin != 1) { }
else { header("Location: login.php"); }

?>


Thats it.
Dont include your page with 'elses' because thats just stupid. You would have to edit all your files within the PHP code instead of actually viewing the design. Not only that, but all your code that has "red" and anything with quotations screws it up. So dont do else { echo " page........... "; }
just do the above
Was This Post Helpful? 0
  • +
  • -

#8 Dr. Tim  Icon User is offline

  • D.I.C Addict

Reputation: 0
  • View blog
  • Posts: 993
  • Joined: 20-March 02

Re: client login system..

Posted 23 January 2003 - 04:44 PM

Do you know what a table is, Kiddo?
Was This Post Helpful? 0
  • +
  • -

#9 kidd0  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 12-November 02

Re: client login system..

Posted 23 January 2003 - 04:46 PM

OMG, STFU.
Was This Post Helpful? 0
  • +
  • -

#10 Quizzical  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 172
  • Joined: 05-August 01

Re: client login system..

Posted 24 January 2003 - 07:34 AM

wouldnt .htaccess and .htpasswd be MUCH easier and more secure?
Just a thought...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1