TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
Advertisement
Associates
Associates
techtuts Darkmindz
CSS Tutorials Tutorialsphere.com - Free Online Tutorials
Boston PHP SurfnLearn
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-29-2007, 04:55 AM   #1 (permalink)
The Acquainted
 
Join Date: Sep 2007
Location: Arizona
Posts: 114
Thanks: 10
Andrew is on a distinguished road
Default Your old code?

Well, I was feeling a bit bored and nostalgic, so I went through all my threads at various forums, and found all my design and PHP work I did back then. Here is the PHP work I found, thought you guys might enjoy seeing how horrible I was. This was from over 2 years ago (August/September '05). I'm rather sad knowing I could have kept coding PHP, and be pretty good by now.

This script never did work, by the way. Now I see why. :)

(I'm just linking to my site since they are rather long and have HTML code mixed in for forms)
http://www.psdtocode.com/old.phps
http://www.psdtocode.com/old2.phps
Send a message via AIM to Andrew Send a message via MSN to Andrew
Andrew is offline  
Reply With Quote
Old 10-29-2007, 11:18 AM   #2 (permalink)
Super Moderator
Advanced Programmer 
 
bluesaga's Avatar
 
Join Date: Sep 2007
Posts: 164
Thanks: 0
bluesaga is on a distinguished road
Default

Lol ouch, i do not have the code but when i was learning i use to have switches and paste the entire html template into each switch case like:

PHP Code:
switch ($state)
{
   case 
"home":
      
//full html doc and php inserting variables, including header and footer. no includes, just copy + paste html
   
break;
   case 
"account":
      
//full html doc and php inserting variables, including header and footer no inlcudes just copy + paste html
   
break;

Note this was like 2002 and i would of been like 14... lol
__________________
Halo 3 Cheats
bluesaga is offline  
Reply With Quote
Old 10-29-2007, 02:20 PM   #3 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 1,654
Thanks: 73
Wildhoney is on a distinguished road
Default

Lol. I remember I always used to use <?=$myVariable; ?> when I was coding years ago. I must dig out some of my old code though! I'm sure it'll tickle you all.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 10-29-2007, 05:00 PM   #4 (permalink)
The Wanderer
 
cherries's Avatar
 
Join Date: Oct 2007
Posts: 20
Thanks: 0
cherries is an unknown quantity at this point
Default

My old code would be something like this:
PHP Code:
<?php
include('connect.php');
global 
$db;

if(
$db == null){
    die(
'LOL! You could not connect to DB!!! LOL!!');
}

if(
$_POST['submit']){
     
$HUGELISTOFVARIABLES $_POST['stuff'];

     
$result mysql_query('SOME HUGE QUERY');
     if(
$result){
         echo 
"AWESOME! LOL!!!";
     }
}else{
//HUGE FORM HTML
}
?>
as compared to now:
PHP Code:
<?php
    
class template
    
{
        private 
$code;

        public function 
__construct $szFile )
        {
            
$this->code file_get_contents($szFile);
        }
        
        public function 
replaceVars $aVars )
        {
            foreach ( 
$aVars as $key => $value )
            {
                
$this->code str_replace($key$value$this->code);
            }
        }
        
        public function 
publish ( )
        {
            echo 
$this->code;
        }
    }
    
    
/***
    * Example Usuage:
        $tpl = new template('templates/xtc.tpl');
        $tpl->replaceVars(array('HOME_URL' => 'http://www.google.com'));
        $tpl->publish();
    */
?>
cherries is offline  
Reply With Quote
Old 10-29-2007, 07:05 PM   #5 (permalink)
The Frequenter
Prolific Welcomer Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 356
Thanks: 24
Haris is on a distinguished road
Default

PHP Code:
<?php echo 'Hello World'?>
I started out with echos.
Haris is offline  
Reply With Quote
Old 10-29-2007, 10:32 PM   #6 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 1,654
Thanks: 73
Wildhoney is on a distinguished road
Default

Yeah, I used to mix all my PHP with my HTML. Lovely stuff!
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 10-29-2007, 10:51 PM   #7 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 1,654
Thanks: 73
Wildhoney is on a distinguished road
Default

Quote:
Originally Posted by Haris View Post
PHP Code:
<?php echo 'Hello World'?>
I started out with echos.
I don't get it. What's wrong with echoes?
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 10-29-2007, 11:29 PM   #8 (permalink)
The Acquainted
 
Join Date: Sep 2007
Location: Arizona
Posts: 114
Thanks: 10
Andrew is on a distinguished road
Default

He was saying that is how he started coding, with the basic Hello World script.

Also, on the Chatwebdev IRC channel, Dread (a great PHP coder), and Shaun were also digging out their old code, too. See what I started? :)
Send a message via AIM to Andrew Send a message via MSN to Andrew
Andrew is offline  
Reply With Quote
Old 10-30-2007, 01:02 AM   #9 (permalink)
Moderator
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 684
Thanks: 15
Village Idiot is on a distinguished road
Default

Here is a crappy under-featured forum I made with about two months of PHP experience.

http://www.justanotherportfolio.com/forum.zip
Village Idiot is offline  
Reply With Quote
Old 11-29-2007, 06:07 PM   #10 (permalink)
bdm
The Acquainted
Good Samaritan 
 
Join Date: Nov 2007
Posts: 127
Thanks: 14
bdm is on a distinguished road
Default

Quote:
Originally Posted by bluesaga View Post
PHP Code:
switch ($state)
{
   case 
"home":
      
//full html doc and php inserting variables, including header and footer. no includes, just copy + paste html
   
break;
   case 
"account":
      
//full html doc and php inserting variables, including header and footer no inlcudes just copy + paste html
   
break;

LOL

When I first got into PHP, a friend of mine told me how he made all of his dynamic sites using only one file (index.php). I couldn't believe my eyes! I was amazed and used it on a few sites until I saw the downfall. Although, my index.php used if statements as if they were going out of style. Actually, I didn't even know what a switch statement was either. The worse part of it all was that I didn't put a common header and footer in my index.php. Each 'page' would contain EVERYTHING including the doctype. Needless to say, updating my site sucked ass.

Not too long later, someone told me about seperating my header and footer into their own entity and simply including them on the top and bottom of my script. I nearly soiled mysql when I learned this nifty trick.

:)
bdm is offline  
Reply With Quote
Old 11-29-2007, 06:47 PM   #11 (permalink)
The Gregarious
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 532
Thanks: 26
sketchMedia is on a distinguished road
Default

I'd be toooo embarrassed to post my code, but lets say i didnt bother seperating presentation from logic
__________________
sketchMedia is offline  
Reply With Quote
Old 11-29-2007, 09:25 PM   #12 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 1,654
Thanks: 73
Wildhoney is on a distinguished road
Default

Quote:
Originally Posted by sketchMedia View Post
I'd be toooo embarrassed to post my code, but lets say i didnt bother seperating presentation from logic
Oh go on! If my PC actually worked without me kicking it to get its hard-drives whirring again, I'd pull up some of my old code .
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 11-29-2007, 11:29 PM   #13 (permalink)
The Gregarious
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 532
Thanks: 26
sketchMedia is on a distinguished road
Default

ok, I'll see what i can find.
__________________
sketchMedia is offline  
Reply With Quote
Old 11-30-2007, 02:30 AM   #14 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 1,654
Thanks: 73
Wildhoney is on a distinguished road
Default

I'll get the tissues ready for when laughter results in tears!
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 12-01-2007, 04:40 PM   #15 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 1,654
Thanks: 73
Wildhoney is on a distinguished road
Default

Hehe. I found some of my old code. This is a snippet from my Javascript hangman game which is still quite addictive! The RAR file is dated the 12th of Match, 2006, so you can see how far I've come. Without further ado:

(I would edit the DB details, but it's years old anyway.)

php Code:
define('MS_GAME', 'GAME'.substr(rand(99999, 10000).ip2long($_SERVER['REMOTE_ADDR']), 0, 12));
define('MYSQL_USER', 'adam_mine05user');
define('MYSQL_PASS', 'sYi3haVveV39qQ');
define('MYSQL_HOST', 'localhost');
define('MYSQL_DB', 'adam_minesweeper');
ini_set('max_execution_time', '120');

$minesweeperSQL = @mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS) or die('<div style="font-size: 10px; font-family: Tahoma, Verdana, Helvetica">MySQL Server not responding.</div>');
@mysql_select_db(MYSQL_DB) or die('<div style="font-size: 10px; font-family: Tahoma, Verdana, Helvetica">MySQL database "'.MYSQL_DB.'" does not exist.</div>');

if(isset($_GET['records'])) {
    $level = mysql_real_escape_string(strip_tags($_GET['records']));
    $sql = "SELECT rName, rTime FROM `records` WHERE rLevel = '$level' ORDER BY rTime ASC LIMIT 0,10";
    $resultsRS = mysql_query($sql);
    $records = '<table id="records"><tr id="record"><th style="width: 10px"></th><th style="width: 120px">Name</th><th>Time (Seconds)</th>';
    $n = 1;
    while($row = mysql_fetch_array($resultsRS)) {
        $records .= '<tr><td>'.$n.'</td><td>'.$row['rName'].'</td><td>'.$row['rTime'].'</td></tr>';
        $n++;
    }
    $records .= '</tr></table>';
    echo $records;
    mysql_free_result($resultsRS);
    die();
} elseif(isset($_GET['name']) && isset($_GET['seconds'])) {
    function microtime_float() {
        list($usec, $sec) = explode(" ", microtime());
        return ((float)$usec + (float)$sec);
    }
    $time_start = mysql_real_escape_string(strip_tags($_GET['seconds']));
    $time_end = microtime_float();
    $time = $time_end - $time_start;
    $name = substr(mysql_real_escape_string(strip_tags($_GET['name'])), 0, 40);
    $level = mysql_real_escape_string(strip_tags($_GET['level']));
    $level = $_GET['level'];
    setcookie('Minesweeper', $name);
    $sql = "INSERT INTO `records` (rName, rLevel, rTime) VALUES ('$name', '$level', '$time')";
    mysql_query($sql);
} elseif(isset($_GET['cell']) && isset($_GET['game'])) {
    $cell = substr(mysql_real_escape_string($_GET['cell']), 0, 3);
    $game = $_GET['game'];
    $sql = "SELECT `gValue` FROM `game` WHERE gCell = '$cell' AND gID = '$game'";
    $resultsRS = mysql_query($sql);
    $row = mysql_fetch_array($resultsRS);
    if($row == 0) {
        echo $row[0];   
    }
    elseif($row[0] == 'Mine') {
        echo $row[0];
        die()
    } else {
        switch($row[0]) {
            case(1):
                $number = 1;
                $colour = '#5B35FF';
                break;
            case(2):
                $number = 2;
                $colour = '#007103';
                break;
            case(3):
                $number = 3;
                $colour = '#FF3535';
                break;
            case(4):
                $number = 4;
                $colour = '#002B8C';
                break;
            case(5):
                $number = 5;
                $colour = '#910202';
                break;
            case(6):
                $number = 6;
                $colour = '#00A997';
                break;
            case(7):
                $number = 7;
                $colour = '#000000';
                break;
            case(8):