[solved] - Thanks Everyone - login php script problem

  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

ok, the extra ) was my fault, sorry about that.

You need to put the $_POST stuff on the admin_login.php page, not the login.php page. It RETRIEVES the data, it doesn't send data... see what I mean?

So:

1) Get rid of the PHP stuff in your HTML form, unless you're planning to use a cookie to add their username to the VALUE field for username, there's no point.

2) Remove any other PHP code you added to the login.php form due to this thread.

3) On admin_login.php (the target, aka, ACTION, for your login form) make it look like this:

PHP Code: [ Select ]
 
 
 
<?
 
   include('connect.php');
 
 
 
   function get_data_by_method($method_hash,$element){
 
      foreach ($method_hash as $key => $value) {
 
         if($key == $element){return $value; }
 
      }
 
      return "";
 
   }
 
 
 
 
 
   $user = get_data_by_method($_POST,"username");
 
   $pass = md5(get_data_by_method($_POST,"password"));
 
 
 
 
 
   $sql = "SELECT username,password FROM admin WHERE username='".$user."' and password='".$pass)."';";
 
   $results = mysql_fetch_array(mysql_query($sql));
 
 
 
   if(!isset($db_user)){$db_user = false;}
 
   if(!isset($db_pass)){$db_pass = false;}
 
 
 
   foreach($results as $field => $value){
 
      if($field == "username"){$db_user = $value; }
 
      if($field == "password"){$db_pass = $value; }
 
   }
 
 
 
   if(!$db_user || !$db_pass){ echo "couldnt get informtion"; }
 
   else{
 
      if($db_user == $user && $db_pass == $pass){
 
         setcookie("admin",$userid,time() + 3600);
 
         echo "Welcome Admin - You have Admin Access <a href=admin.php>click here to continue</a>";
 
      }
 
      else{ echo "You do not have permission to access this area, sorry <a href=login.php>click here to go back</a>"; }
 
   }
 
?>
 
 
  1.  
  2.  
  3.  
  4. <?
  5.  
  6.    include('connect.php');
  7.  
  8.  
  9.  
  10.    function get_data_by_method($method_hash,$element){
  11.  
  12.       foreach ($method_hash as $key => $value) {
  13.  
  14.          if($key == $element){return $value; }
  15.  
  16.       }
  17.  
  18.       return "";
  19.  
  20.    }
  21.  
  22.  
  23.  
  24.  
  25.  
  26.    $user = get_data_by_method($_POST,"username");
  27.  
  28.    $pass = md5(get_data_by_method($_POST,"password"));
  29.  
  30.  
  31.  
  32.  
  33.  
  34.    $sql = "SELECT username,password FROM admin WHERE username='".$user."' and password='".$pass)."';";
  35.  
  36.    $results = mysql_fetch_array(mysql_query($sql));
  37.  
  38.  
  39.  
  40.    if(!isset($db_user)){$db_user = false;}
  41.  
  42.    if(!isset($db_pass)){$db_pass = false;}
  43.  
  44.  
  45.  
  46.    foreach($results as $field => $value){
  47.  
  48.       if($field == "username"){$db_user = $value; }
  49.  
  50.       if($field == "password"){$db_pass = $value; }
  51.  
  52.    }
  53.  
  54.  
  55.  
  56.    if(!$db_user || !$db_pass){ echo "couldnt get informtion"; }
  57.  
  58.    else{
  59.  
  60.       if($db_user == $user && $db_pass == $pass){
  61.  
  62.          setcookie("admin",$userid,time() + 3600);
  63.  
  64.          echo "Welcome Admin - You have Admin Access <a href=admin.php>click here to continue</a>";
  65.  
  66.       }
  67.  
  68.       else{ echo "You do not have permission to access this area, sorry <a href=login.php>click here to go back</a>"; }
  69.  
  70.    }
  71.  
  72. ?>
  73.  
  74.  


Let me know if that works

.c

*EDIT: Changed function name to work for ANY collectoin hash, not just post....
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

ok 1)

Code: [ Select ]
<? include('http://www.69kilobytes.co.uk/header.php'); ?>

<form name=admin_login method=post action=admin_login.php>
<input type=text name=username id=user>
<input type=password name=password id=MD5('$pass')>
 <input type=submit value=submit name=submit>
</form>

<? include('http://www.69kilobytes.co.uk/footer.php'); ?>
  1. <? include('http://www.69kilobytes.co.uk/header.php'); ?>
  2. <form name=admin_login method=post action=admin_login.php>
  3. <input type=text name=username id=user>
  4. <input type=password name=password id=MD5('$pass')>
  5.  <input type=submit value=submit name=submit>
  6. </form>
  7. <? include('http://www.69kilobytes.co.uk/footer.php'); ?>


link: http://www.69kilobytes.co.uk/cp/login.php

i will post the rest as well...
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

ok the admin login php page

link: http://www.69kilobytes.co.uk/cp/admin_login.php

ERROR line 15... and it still says "You do not have permission blah blah" meaning the username and password did not work. Even though they are correct.
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

Ok... sorry, I noticed something else... the md5 stuff was wrong, and there isn't anything actually reading the data retrieved from the query. I've updated the script above, see if that works. If it doesn't, I'll create a test database and actually trying the scripts... I'm writting from memory here.. heh
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

Stop the presses!

heh

Give this a try. I combined the connect.php include file in for sake of ease. I ran this against a test database and it worked. Give it a try on your site and let me know.

PHP Code: [ Select ]
 
<?
 
   function get_data_by_method($method_hash,$element){
 
      foreach ($method_hash as $key => $value){
 
         if($key == $element){ return $value; }
 
      }
 
      return "";
 
   }
 
 
 
 
 
  $submit = get_data_by_method($_POST,"submit");
 
   $user = get_data_by_method($_POST,"username");
 
   $pass = md5(get_data_by_method($_POST,"password"));
 
   if(!isset($db_user)){$db_user = false;}
 
   if(!isset($db_pass)){$db_pass = false;}
 
 
 
   $username = "";
 
   $password = "";
 
   $host = "";
 
   $database = "";
 
   mysql_connect($host,$username,$password) or die("Cannot connect to the database.<br>" . mysql_error());
 
   mysql_select_db($database) or die("Cannot select the database.<br>" . mysql_error());
 
   $result = mysql_query("SELECT username,password FROM userdata WHERE username='".$user."' and password='".$pass."';");
 
   while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
 
      $db_user = $row["username"];
 
      $db_pass = $row["password"];
 
   }
 
 
 
   if(!$db_user || !$db_pass){ echo "couldnt get informtion"; }
 
   else{
 
      if($db_user == $user && $db_pass == $pass){
 
         setcookie("admin",$userid,time() + 3600);
 
         echo "Welcome Admin - You have Admin Access <a href=admin.php>click here to continue</a>";
 
      }
 
      else{ echo "You do not have permission to access this area, sorry <a href=login.php>click here to go back</a>"; }
 
   }
 
   mysql_free_result($result);
 
?>
 
 
  1.  
  2. <?
  3.  
  4.    function get_data_by_method($method_hash,$element){
  5.  
  6.       foreach ($method_hash as $key => $value){
  7.  
  8.          if($key == $element){ return $value; }
  9.  
  10.       }
  11.  
  12.       return "";
  13.  
  14.    }
  15.  
  16.  
  17.  
  18.  
  19.  
  20.   $submit = get_data_by_method($_POST,"submit");
  21.  
  22.    $user = get_data_by_method($_POST,"username");
  23.  
  24.    $pass = md5(get_data_by_method($_POST,"password"));
  25.  
  26.    if(!isset($db_user)){$db_user = false;}
  27.  
  28.    if(!isset($db_pass)){$db_pass = false;}
  29.  
  30.  
  31.  
  32.    $username = "";
  33.  
  34.    $password = "";
  35.  
  36.    $host = "";
  37.  
  38.    $database = "";
  39.  
  40.    mysql_connect($host,$username,$password) or die("Cannot connect to the database.<br>" . mysql_error());
  41.  
  42.    mysql_select_db($database) or die("Cannot select the database.<br>" . mysql_error());
  43.  
  44.    $result = mysql_query("SELECT username,password FROM userdata WHERE username='".$user."' and password='".$pass."';");
  45.  
  46.    while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
  47.  
  48.       $db_user = $row["username"];
  49.  
  50.       $db_pass = $row["password"];
  51.  
  52.    }
  53.  
  54.  
  55.  
  56.    if(!$db_user || !$db_pass){ echo "couldnt get informtion"; }
  57.  
  58.    else{
  59.  
  60.       if($db_user == $user && $db_pass == $pass){
  61.  
  62.          setcookie("admin",$userid,time() + 3600);
  63.  
  64.          echo "Welcome Admin - You have Admin Access <a href=admin.php>click here to continue</a>";
  65.  
  66.       }
  67.  
  68.       else{ echo "You do not have permission to access this area, sorry <a href=login.php>click here to go back</a>"; }
  69.  
  70.    }
  71.  
  72.    mysql_free_result($result);
  73.  
  74. ?>
  75.  
  76.  
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

but.... How will the other pages know i logged in? :O

Thanks for the code i really appreciate it. I spent a week trying to get this bit working


is this ok?
PHP Code: [ Select ]
if(isset($_COOKIE["admin"])) { echo 'welcome'; } else { echo 'You need to login to view this area of the site';}?>
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

oops, i didn't take that into account. you can't use $userid, unless you add that to the mysql query. after SELECT, replace userid with whatever the auto-incrementing primary key field name is (uid, id, userid, whatever it is)

PHP Code: [ Select ]
 
    $result = mysql_query("SELECT userid,username,password FROM userdata WHERE username='".$user."' and password='".$pass."';");
 
    while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
 
        $db_uid = $row["userid"];
 
        $db_user = $row["username"];
 
        $db_pass = $row["password"];
 
    }
 
 
  1.  
  2.     $result = mysql_query("SELECT userid,username,password FROM userdata WHERE username='".$user."' and password='".$pass."';");
  3.  
  4.     while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
  5.  
  6.         $db_uid = $row["userid"];
  7.  
  8.         $db_user = $row["username"];
  9.  
  10.         $db_pass = $row["password"];
  11.  
  12.     }
  13.  
  14.  


Then, when you're setting the cookie, use:

PHP Code: [ Select ]
setcookie("admin",$db_uid,time() + 3600);



PHP Code: [ Select ]
 
<?
 
  if(!isset($cookie_uid)){$cookie_uid = false;}
 
  $cookie_uid = get_data_by_method($_COOKIE,"admin");
 
  if(!$cookie_uid){ header("Location: login.php"); }
 
?>
 
 
  1.  
  2. <?
  3.  
  4.   if(!isset($cookie_uid)){$cookie_uid = false;}
  5.  
  6.   $cookie_uid = get_data_by_method($_COOKIE,"admin");
  7.  
  8.   if(!$cookie_uid){ header("Location: login.php"); }
  9.  
  10. ?>
  11.  
  12.  

This must go at the top of the page or the header call will give an error. You must send all headers before anything is actually sent to the browser, or you will get an error.


Also, just to note on some naming conventions. I like to use $db_varname to denote any variable that contains a value that was pulled from the database. That's the "real" data, and no potentially garbage data that someone has submitted... It has no real bearing on the script, it just makes it easier to read, for me anyway.

.c
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

PHP Code: [ Select ]
 
$cookie_uid = get_data_by_method($_COOKIE,"admin");
 
 
  1.  
  2. $cookie_uid = get_data_by_method($_COOKIE,"admin");
  3.  
  4.  


Fatal error: Call to undefined function: get_data_by_method() in /home/virtual/site2/fst/var/www/html/cp/admin.php on line 4
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

again, if you add the function get_data_by_method to a common include file you can call it from anywhere. If you don't, then you'll need to include the whole function on every page.

I would suggest adding:

PHP Code: [ Select ]
require_once("common.php");


to every page on your site (the path to the common.php file must be set right, obviously, just as you would with regular link).

Do not include anthing except functions or variable declarations in the file, since it will be on every page. The require_once call means you will get a fatal error if it's not found (make sure the path is right) and the _once part means it will only every be included once, even if you accidently include another file that also tries to include it. require and include do the same thing, the only difference is require stops the parser if the file isn't found, include doesn't.

I make a habit of using include_once or require_once, unless I specifically want to include a particular file more than once on a given page, which is pretty rare.

.c
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

oh... and if you add that function to an include, make sure to remove it from any page you have copied it on to. You don't want to have the function defined twice, that can cause some unexpected results...

Remember, including a file is basically the same thing as copying and pasting the whole file you're including into the document you're including it on where the include call is (heh how many times can YOU use include in the same sentence?). So

file 1:
hello there

file 2:
blah
include(file1)
blahh

is the same as:
blah
hello there
blahh


so, if instead, file 2 was:
blah
hello there
include(file1)
blahh

you're really have:
blah
hello there
hello there
blahh

see what I mean?
.c
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

please read previous post :P
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

I know about the includes dude :$ im not that much of a noob no more :P
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

heh, you never know =]

Anyway, in that case. Just add the function to an include file called common.php and on every page you want to protect:

PHP Code: [ Select ]
 
<?
 
  $path_to_includes = "../includes/";
 
  require_once($path_to_includes."common.php");
 
  if(!isset($cookie_uid)){$cookie_uid = false;}
 
  $cookie_uid = get_data_by_method($_COOKIE,"admin");
 
  if(!$cookie_uid){ header("Location: login.php"); }
 
?>
 
 
 
 
  1.  
  2. <?
  3.  
  4.   $path_to_includes = "../includes/";
  5.  
  6.   require_once($path_to_includes."common.php");
  7.  
  8.   if(!isset($cookie_uid)){$cookie_uid = false;}
  9.  
  10.   $cookie_uid = get_data_by_method($_COOKIE,"admin");
  11.  
  12.   if(!$cookie_uid){ header("Location: login.php"); }
  13.  
  14. ?>
  15.  
  16.  
  17.  
  18.  


(Ok... I added something new... heh, just change the $path_to_includes value to be whatever it needs to be based on the page...)


OR

Just copy the function to the page. It would be the same, using the include is just easier and cleaner.

.c
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

dude, there is no such function as:

get_data_by_method

i even checked on php.net
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

It's part of the code I provided above:

PHP Code: [ Select ]
 
 
 
    function get_data_by_method($method_hash,$element){
 
        foreach ($method_hash as $key => $value){
 
            if($key == $element){ return $value; }
 
        }
 
        return "";
 
    }
 
 
 
 
  1.  
  2.  
  3.  
  4.     function get_data_by_method($method_hash,$element){
  5.  
  6.         foreach ($method_hash as $key => $value){
  7.  
  8.             if($key == $element){ return $value; }
  9.  
  10.         }
  11.  
  12.         return "";
  13.  
  14.     }
  15.  
  16.  
  17.  
  18.  
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

Im still running in to problems...

I opened up my cookie folder... once i logged in i refreshed the cookie folder and the cookie didnt appear.

Also, i can still go on to the 'secure' pages without even logging in? The log out button works fine but i had to rearrange it to this:

PHP Code: [ Select ]
 
<?PHP
 
session_start();
 
session_destroy();
 
 
 
echo "You have been successfully logged out.";
 
?>
  1.  
  2. <?PHP
  3.  
  4. session_start();
  5.  
  6. session_destroy();
  7.  
  8.  
  9.  
  10. echo "You have been successfully logged out.";
  11.  
  12. ?>


The common.php file
PHP Code: [ Select ]
<?
 
  require_once("admin_login.php");
 
  if(!isset($cookie_uid)){$cookie_uid = false;}
 
  $cookie_uid = get_data_by_method($_COOKIE,"admin");
 
  if(!$cookie_uid){ header("Location: login.php"); }
 
?>
  1. <?
  2.  
  3.   require_once("admin_login.php");
  4.  
  5.   if(!isset($cookie_uid)){$cookie_uid = false;}
  6.  
  7.   $cookie_uid = get_data_by_method($_COOKIE,"admin");
  8.  
  9.   if(!$cookie_uid){ header("Location: login.php"); }
  10.  
  11. ?>


now this is working fine, but this is the main cause of going on to secure pages logged in or logged out.

I been trying to figure it out, but i got a splitting headache. Im almost out of time too.[/php]
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

Ok, try this.

Remove all the stuff about cookies...

In your common.php file:

PHP Code: [ Select ]
 
<?
 
  session_start();
 
  if(!isset($_SESSION['username'])){$_SESSION['username'] = false;}
 
?>
 
 
 
 
  1.  
  2. <?
  3.  
  4.   session_start();
  5.  
  6.   if(!isset($_SESSION['username'])){$_SESSION['username'] = false;}
  7.  
  8. ?>
  9.  
  10.  
  11.  
  12.  


Make sure common.php is included on your homepage so the session will be activated and the username variable instantiated to false.

Now, on your admin_login.php file:


PHP Code: [ Select ]
 
<?
 
    function get_data_by_method($method_hash,$element){
 
        foreach ($method_hash as $key => $value){
 
            if($key == $element){ return $value; }
 
        }
 
        return "";
 
    }
 
 
 
 
 
  $submit = get_data_by_method($_POST,"submit");
 
    $user = get_data_by_method($_POST,"username");
 
    $pass = md5(get_data_by_method($_POST,"password"));
 
    if(!isset($db_user)){$db_user = false;}
 
    if(!isset($db_pass)){$db_pass = false;}
 
 
 
    $username = "";
 
    $password = "";
 
    $host = "";
 
    $database = "";
 
    mysql_connect($host,$username,$password) or die("Cannot connect to the database.<br>" . mysql_error());
 
    mysql_select_db($database) or die("Cannot select the database.<br>" . mysql_error());
 
    $result = mysql_query("SELECT username,password FROM userdata WHERE username='".$user."' and password='".$pass."';");
 
    while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
 
        $db_user = $row["username"];
 
        $db_pass = $row["password"];
 
    }
 
 
 
    if(!$db_user || !$db_pass){ echo "couldnt get informtion"; }
 
    else{
 
        if($db_user == $user && $db_pass == $pass){
 
           $_SESSION['username'] = $db_user;
 
            echo "Welcome Admin - You have Admin Access <a href=admin.php>click here to continue</a>";
 
        }
 
        else{ echo "You do not have permission to access this area, sorry <a href=login.php>click here to go back</a>"; }
 
    }
 
    mysql_free_result($result);
 
?>
 
 
  1.  
  2. <?
  3.  
  4.     function get_data_by_method($method_hash,$element){
  5.  
  6.         foreach ($method_hash as $key => $value){
  7.  
  8.             if($key == $element){ return $value; }
  9.  
  10.         }
  11.  
  12.         return "";
  13.  
  14.     }
  15.  
  16.  
  17.  
  18.  
  19.  
  20.   $submit = get_data_by_method($_POST,"submit");
  21.  
  22.     $user = get_data_by_method($_POST,"username");
  23.  
  24.     $pass = md5(get_data_by_method($_POST,"password"));
  25.  
  26.     if(!isset($db_user)){$db_user = false;}
  27.  
  28.     if(!isset($db_pass)){$db_pass = false;}
  29.  
  30.  
  31.  
  32.     $username = "";
  33.  
  34.     $password = "";
  35.  
  36.     $host = "";
  37.  
  38.     $database = "";
  39.  
  40.     mysql_connect($host,$username,$password) or die("Cannot connect to the database.<br>" . mysql_error());
  41.  
  42.     mysql_select_db($database) or die("Cannot select the database.<br>" . mysql_error());
  43.  
  44.     $result = mysql_query("SELECT username,password FROM userdata WHERE username='".$user."' and password='".$pass."';");
  45.  
  46.     while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
  47.  
  48.         $db_user = $row["username"];
  49.  
  50.         $db_pass = $row["password"];
  51.  
  52.     }
  53.  
  54.  
  55.  
  56.     if(!$db_user || !$db_pass){ echo "couldnt get informtion"; }
  57.  
  58.     else{
  59.  
  60.         if($db_user == $user && $db_pass == $pass){
  61.  
  62.            $_SESSION['username'] = $db_user;
  63.  
  64.             echo "Welcome Admin - You have Admin Access <a href=admin.php>click here to continue</a>";
  65.  
  66.         }
  67.  
  68.         else{ echo "You do not have permission to access this area, sorry <a href=login.php>click here to go back</a>"; }
  69.  
  70.     }
  71.  
  72.     mysql_free_result($result);
  73.  
  74. ?>
  75.  
  76.  



Then, on any page you wish to protect with a login:

PHP Code: [ Select ]
 
 
 
<?
 
  if(!$_SESSION['username']){header("Location: login.php");}
 
?>
 
 
 
 
  1.  
  2.  
  3.  
  4. <?
  5.  
  6.   if(!$_SESSION['username']){header("Location: login.php");}
  7.  
  8. ?>
  9.  
  10.  
  11.  
  12.  


Then, when you want to log out:
PHP Code: [ Select ]
 
<?
 
  $_SESSION['username'] = false;
 
  session_destroy();
 
?>
 
 
 
 
 
Give that a try instead of cookies.
 
 
 
.c
  1.  
  2. <?
  3.  
  4.   $_SESSION['username'] = false;
  5.  
  6.   session_destroy();
  7.  
  8. ?>
  9.  
  10.  
  11.  
  12.  
  13.  
  14. Give that a try instead of cookies.
  15.  
  16.  
  17.  
  18. .c
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

i fixed it carnix! read topic title :P [solved]
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

Ah, excellent!
.c
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

one thing though :$

i created a news script to add/edit/delete from a dbase.

But i got a table like this...

Code: [ Select ]
<table width="90%" height="109" border="1" cellpadding="0" cellspacing="0" bordercolor="666666" class="newstable">
       <tr>
        <td height="21" class="news_title">Title</td>
       </tr>
       <tr>
        <td height="63" align="right" valign="bottom" class="news_bg"><br>
         <font size="2" face="Verdana, Arial, Helvetica, sans-serif"><em><br>
         Click here for more...</em></font></td>
       </tr>
       <tr>
        <td height="12" class="news_title">
         <div align="right"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Posted
          By: $USER Date: $Date</font></div></td>
       </tr>
      </table>
      <br>
  1. <table width="90%" height="109" border="1" cellpadding="0" cellspacing="0" bordercolor="666666" class="newstable">
  2.        <tr>
  3.         <td height="21" class="news_title">Title</td>
  4.        </tr>
  5.        <tr>
  6.         <td height="63" align="right" valign="bottom" class="news_bg"><br>
  7.          <font size="2" face="Verdana, Arial, Helvetica, sans-serif"><em><br>
  8.          Click here for more...</em></font></td>
  9.        </tr>
  10.        <tr>
  11.         <td height="12" class="news_title">
  12.          <div align="right"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Posted
  13.           By: $USER Date: $Date</font></div></td>
  14.        </tr>
  15.       </table>
  16.       <br>


i connect to dbase, and "SELECT * FROM news WHERE"...

How do i insert this on to the table and make it loop until it has input all the news? there is an id on the news table btw.
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

dont worry, i done it.

Post Information

  • Total Posts in this topic: 51 posts
  • Users browsing this forum: spork and 85 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.