Putting HTML in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

MexicanHat: I'm guessing at the start of each of your closed off pages?
Image Image
User avatar
Heavy
Forum Contributor
Posts: 478
Joined: Sun Sep 22, 2002 7:36 am
Location: Viksjöfors, Hälsingland, Sweden
Contact:

Post by Heavy »

Now, don't get me the angry way if I hurt your pride, the following is just me trying to help you out.

When I see this:
Mexican Hat wrote:Still confused.

Code: Select all

<?php
   function valid_login($username, $password) &#123;
      return ($username == 'name1' && $password == 'pass1') or
             ($username == 'name2' && $password == 'pass2') or
             ($username == 'name3' && $password == 'pass3');
   &#125;

   function login_screen($failed = 0) &#123;
?><html> 
  <head><LINK REL=StyleSheet HREF="_style.css" TYPE="text/css"></HEAD> 
  <body bgcolor="#e1e1e1"><center> 
  <form action="<?php echo $_SERVER&#1111;'PHP_SELF']; ?>" method='post'>
  <table border="0">
  <TR><TD>Username:<TD><input type="text" name="username" maxlength="20">
  <TR><TD>Password: <TD><input type="password" name="password" maxlength="20">
  <TR><TD colspan="2"><center><input type="submit" name="submit" value="Login">
  </table>
  </form>
  <BR><BR>

      if ($failed) $output .= <font color = red><b>Failed ".$_SESSION&#1111;'count']." time(s) : Keep Trying Biatch</b></font>

      return $output ."<BR><BR></center></body></html>";
   &#125;


   session_start();
   if( ! isset($_SESSION&#1111;'count']) ) $_SESSION&#1111;'count'] = 0;
   else $_SESSION&#1111;'count']++;

   if( ! isset($_SESSION&#1111;'logged_in']) ) &#123;
      if ( ! isset($_POST&#1111;'submit'])) &#123;
         die (login_screen());
      &#125; elseif ( valid_login($_POST&#1111;'username'], $_POST&#1111;'password']) ) &#123;
         $_SESSION&#1111;'count']  = 1;
         $_SESSION&#1111;'logged_in']  = 1;
      &#125; elseif ( $_SESSION&#1111;'count'] > 3 ) &#123;
         header("Location: baby/index.html");
         exit;
      &#125; else &#123;
         die ( login_screen($failed = 1) );
      &#125;
   &#125;
But I know that not right. Where do I put this code:

Code: Select all

&#125;


   session_start();
   if( ! isset($_SESSION&#1111;'count']) ) $_SESSION&#1111;'count'] = 0;
   else $_SESSION&#1111;'count']++;

   if( ! isset($_SESSION&#1111;'logged_in']) ) &#123;
      if ( ! isset($_POST&#1111;'submit'])) &#123;
         die (login_screen());
      &#125; elseif ( valid_login($_POST&#1111;'username'], $_POST&#1111;'password']) ) &#123;
         $_SESSION&#1111;'count']  = 1;
         $_SESSION&#1111;'logged_in']  = 1;
      &#125; elseif ( $_SESSION&#1111;'count'] > 3 ) &#123;
         header("Location: baby/index.html");
         exit;
      &#125; else &#123;
         die ( login_screen($failed = 1) );
      &#125;
   &#125;&#1111;/
Peace :(
... I wonder whether you know about matching braces.
I also wonder if you wrote that yourself. It is OK if you did not, but I mean, If you don't know what echo is, the above is an awful lot of php code.

When I see this:
Mexican Hat wrote:I'm trying to get the hang of php but it's still confusing. The thing I don't understand is why you can't just put your regular HTML in php you have to change it around with / or '.

Peace 8)
it seems to me like you need to read about these things:
http://www.php.net/manual/en/langref.php
but especially:
http://www.php.net/manual/en/langref.php
and
http://www.php.net/manual/en/language.types.string.php

Don't just skim through the chapters. Read them carefully, it is not very much, but I guess those links will get you on track.

If I have made a mistake probing for your present skills. FLAAAAME ME.
Just know that I just want to help.

Peace :roll:
Last edited by Heavy on Fri Jun 27, 2003 1:16 pm, edited 1 time in total.
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

heavey: echo, print and things like that don't appear in markup languages... i know a number of people that pick up markup languages and think they can do it all... as sooon as they get off markup languages they freeze.. they realize it's nothing like what they thought...i get the feeling that he learned markup languages and is now trying to learn a scripting lang. we should also tell him about xemacs. http://www.xemacs.org

it's the best programming editor out there if you wantmy opinion
User avatar
Heavy
Forum Contributor
Posts: 478
Joined: Sun Sep 22, 2002 7:36 am
Location: Viksjöfors, Hälsingland, Sweden
Contact:

Post by Heavy »

m3rajk wrote:heavey: echo, print and things like that don't appear in markup languages...
Yeah.
I saw this:

Code: Select all

<?php
session_start();
   if( ! isset($_SESSION['count']) ) $_SESSION['count'] = 0;
   else $_SESSION['count']++; 
?>
and thought that keeping track of sessions and all, one usually have come across echo.

I use Zend Studio Personal Edition. What can I say... It's slow. But it is the only editor I have come across that really suits my needs, and has syntax hiliting beyond others, code completion with class digging and other cool things.

(Don't like emacs myself.)

EDIT: I made a post about editors here.
User avatar
Mexican Hat
Forum Newbie
Posts: 19
Joined: Sat Mar 08, 2003 8:35 pm
Location: Baltimore, Maryland
Contact:

Post by Mexican Hat »

Hey Heavy,

Yeah that code I got off of someone here on this forum. I didn't make it myself. I started trying to learn php just a month ago but haven't gotten very far. So I really don't know much about it. I think I'm try to skip ahead more than I can handle.

I'll try to read up on some stuff from the links you provided.

I'll start working on the login thing once I read up on some php because I have no clue really what going on.

Oh do any of you people know of any good php books?

Peace :roll:
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

yes
and i also know what was the cheapest place for me to get them even with sales tax... you're not going to have sales tax from this place...

Programming PHP
PHP Cookbook
User avatar
Mexican Hat
Forum Newbie
Posts: 19
Joined: Sat Mar 08, 2003 8:35 pm
Location: Baltimore, Maryland
Contact:

Thanks

Post by Mexican Hat »

YeaH I think I might go with "Programming PHP". I've heard some good things about it.

Peace :lol:
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

i have both. programmping php is a great tutorial if you're got familiarty with languages and like all oreilly books, a great reference after you are comfortable with the language.

the cookbook has sample code solutions to specific common problems. basic things that they expect people to deal with often and be able to modify for their specific needs.
Post Reply