My first php page ever!

Discussion in 'PHP' started by Gnet, Feb 17, 2007.

  1. #1
    Ok i can edit php and modify it add a template but cant make it
    So im learning

    Here is one made from scratch!

    Using ids and echos!

    http://gurilla.net/php/page.php

    tell me how ya like!
     
    Gnet, Feb 17, 2007 IP
  2. Anita

    Anita Peon

    Messages:
    1,142
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Well, it looks like it's working, glad I'm not Travis.
     
    Anita, Feb 17, 2007 IP
  3. Dirty-Rockstar

    Dirty-Rockstar Guest

    Messages:
    252
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    .......yay? im not sure what it means but its good/ im new with php too. copy paste this ;)
    3 days so far learning. dont know if its the most convinient way. and someone told me to use switches, but its art to me. enjoy. ps im not hijacking your thread. just giving you a template to have fun with


    EDIT: change test.php to the name of your page. so change it to page.php or it wont work look for this below in teh code. the full code is the bigger box. the smaller box shows what you need to change

    </TABLE>
    $text_before
    <form method='post' action=test.php>
    PHP:


    <?
    $number=$_POST[numberentered];
    $black="bgcolor='black'";
    $white="bgcolor='white'";
    $yellow="bgcolor='yellow'";
    $blue="bgcolor='blue'";
    $red="bgcolor='red'";
    $orange="bgcolor='orange'";
    $grey="bgcolor='grey'";
    $purple="bgcolor='purple'";
    $green="bgcolor='green'";
    $text_before="<b>Pick a number between 1 and 9</b>";
    $text_after="<b>YAY, You picked the number<br>$number</b>";
    $bgcolor='';
    $text='';
    $wrong="<b>You picked $number<br> Theres no color for $number yet!</b>";
    if(!isset($number)) 
    { 
    $text="<b>Pick a Number</b>";
    
    }
    
    elseif($number==1)
    {
    $text_before=$text_after;
    $bgcolor=$black;
    }
    
    elseif($number==2)
    {
    $text_before=$text_after;
    $bgcolor=$red;
    }
    
    elseif($number==3)
    {
    $text_before=$text_after;
    $bgcolor=$yellow;
    }
    
    elseif($number==4)
    {
    $text_before=$text_after;
    $bgcolor=$white;
    }
    
    elseif($number==5)
    {
    $text_before=$text_after;
    $bgcolor=$blue;
    }
    
    elseif($number==6)
    {
    $text_before=$text_after;
    $bgcolor=$green;
    }
    
    elseif($number==7)
    {
    $text_before=$text_after;
    $bgcolor=$orange;
    }
    
    elseif($number==8)
    {
    $text_before=$text_after;
    $bgcolor=$grey;
    }
    
    elseif($number==9)
    {
    $text_before=$text_after;
    $bgcolor=$purple;
    }
    
    else{
    $text_before=$wrong;
    $text="<b>BOOOO!</b>";
    }
    
    Print"
    
    <center>
    
    <br>
    <TABLE BORDER=1>
    <TR>
      <TD $bgcolor width='50' height='50' value='value' name='name'>$text</TD>
     
    
    </TABLE>
    $text_before
    <form method='post' action=test.php>
    
    
    <input type='text' name='numberentered' value='$number' maxlength='1'><br>
    <input type='submit' name='submit' value='Click'>
    </form></center>";
    
    
    
    
    ?>
    
    
    PHP:
     
    Dirty-Rockstar, Feb 17, 2007 IP
  4. Gnet

    Gnet Peon

    Messages:
    5,340
    Likes Received:
    529
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Travis is an annoying kid i know who thinks he can beat mr gates at his own game, but sadly cant tie his own shoes. lol
    plus sucks at maths and cant use a pc to save his life..
    so no chance of being a prodigy there..

    now lets see how to dbs and loops
     
    Gnet, Feb 17, 2007 IP
  5. Dirty-Rockstar

    Dirty-Rockstar Guest

    Messages:
    252
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #5
    let me know how db's go. im still lost. I didnt really attack loops yet, but the while statement looks easy. im going with arrays next, and carring vars over between all pages running. maybe we can compare notes. eventually i would like to code a text based rpg. i have a kick ass idea, but lack the coding knowledge. last idea i gave out they took it off me and made the game. now make 400$ + on 'donations' every month. game has been out for 7 months :(
     
    Dirty-Rockstar, Feb 17, 2007 IP
  6. Gnet

    Gnet Peon

    Messages:
    5,340
    Likes Received:
    529
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hey i used your code to make a cursing script, give it your name and it just curses at ya.
    http://gurilla.net/php/page2.php
    but something is wrong it takes the input but spits nothing :(

    and you can get me on msn anytime id like to compare notes as well! :)


    
    <style type="text/css">
    <!--
    .headert {
        font-family: Arial, Helvetica, sans-serif;
        font-size: 36px;
        color: #666666;
        align: center;
    }
    .yay {
        font-family: Arial, Helvetica, sans-serif;
        font-size: 30px;
        color: #6666CC;
        align: center;
        padding-left: 10px;
    }
    -->
    </style>
    
    <body>
    <html>
    <?
    $name=$_POST[nameentered];
    $text_before="<div align=center class=yay>Whats your name?</div>";
    $text_after="<div align=center class=yay>I think i know a <br>$name</div>";
    $bgcolor='';
    $text='';
    $wrong="<b>You're name is $name<br> dude i really dont know a $name, i swear!</b>";
    if(!isset($number))
    {
    $text="<div align=center class=yay>Pick a Number</div>";
    $Travis="<div align=center class=headert>YOU're an ASS!</div>";
    
    }
    
    elseif($name==Travis)
    {
    $text_before=$text_after;
    echo $Travis;
    }
    
    else{
    $text_before=$wrong;
    $text="<b>BOOOO!</b>";
    }
    
    Print"
    
    <center>
    
    <br>
    $text_before
    <form method='post' action=page2.php>
    
    
    <input type='text' name='numberentered' value='$number' maxlength='17'><br>
    <input type='submit' name='submit' value='Click'>
    </form></center>";
    
    
    
    
    ?>
    
    PHP:

     
    Gnet, Feb 17, 2007 IP
  7. Dirty-Rockstar

    Dirty-Rockstar Guest

    Messages:
    252
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #7
    ill look at the code later and fix it for you. hrmm, upon closer inspection its botched horribly. ill just make a script to do it. ill add you to msn tommorow. very tired. tried to make a calculator and it exploded. peace
     
    Dirty-Rockstar, Feb 18, 2007 IP