Jul 20, 2008

Php For Beginners - By Skazi

Free Web Hosting, No Ads > CONTRIBUTE > Tutorials
Pages: 1, 2

free web hosting

Php For Beginners - By Skazi

shadow skazi
In creating a php file, you can combine HTML and PHP in one file, but you MUST save it as a .php file if it contains any PHP information. Remember, these tutorials are just for your learning and you should not just copy and paste these into notepad and call it good. You also may realize PHP is alot like the C++ programming language tongue.gif

CODE
<html>
<head>
 <title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>


What the <?php echo '<p>Hello World</p>'; ?> command does is it exports The information between the 's as raw text. So it would display as

CODE
<p>Hello World</p>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Now we will use the echo() command to display what browser the viewer is using, so we can put a big fat banner telling them to switch to Mozilla Firefox tongue.gif but we don't want to do that because the site would look icky. We don't want to lose traffic, do we?

CODE
<?php echo $_SERVER['HTTP_USER_AGENT']; ?>


An output of this code would be Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) if the user is using Mozilla. What this code does is it gets the broswer information and echos it (displays it) for the viewer.

Now we could use this to our advantage and tell them which browser they are using or if they are not using Mozilla Firefox with this code...

CODE
<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) {
?>
<p>You are using Internet Explorer</p>
<?php
} else {
?>
<p>You are not using Internet Explorer</p>
<?php
}
?>


The output would be

<p>You are using Internet Explorer</p> or <p>You are not using Internet Explorer</p>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For this one, you will need two PHP files, one for the action, and one for the HTML.

CODE
<form action="action.php" method="post">
<p>Your name: <input type="text" name="name" /></p>
<p>Your age: <input type="text" name="age" /></p>
<p><input type="submit" /></p>
</form>


That's just simple HTML you would put on a site for a form. You would fill this out and it would display a sentence of "Hi ______, you are __ years old." And this is what we're going to do now. Create a action.php file and put this in it....

CODE
Hi <?php echo $_POST['name']; ?>,
You are <?php echo $_POST['age']; ?> years old.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

And that concludes the noob tutorial for PHP. I hope this has helped you create great websites as it has helped me get hosting credits >_>

++++++++++++++++
Tutorials Copyright
2005 shadow skazi
++++++++++++++++

 

 

 


Reply

whyme
nice little tutorial. tongue.gif

Reply

ill
Simple, and great for people who wanna start with PHP. Good job!

Reply

Amezis
Nice tutorial, and I really need to learn how to use php...

Reply

egbakaet
Hey, if any of you guys need a mail newsletter script, let me know. I got one that works beautifully and is barely a hassle. Only 3 files needed! biggrin.gif

Reply

thebluekirby
wow... this tuturial can come in handy when I feel like scripting in PHP! thanks!

Reply

Ralphie
thanks a lot for that tutorial. i am hoping to soon learn php so this is a nice little intro

Reply

beeseven
You don't need to have two pages for a form. You could just have some HTML then PHP then finish the HTML (pretend the file is called "file.php"):

CODE

<HTML>
<HEAD>
<TITLE>Title</TITLE>
<BODY>
<FORM METHOD="POST" ACTION="file.php">
Name: <INPUT TYPE="text" NAME="name">
<INPUT TYPE="submit">
</FORM>
<?php
echo "Hello, " . $_POST['name'];
?>
</BODY>
</HTML>

Reply

NotoriousZach
thanks...... Although it seems like every PHP tutorial online is all the same........Hello World, they show u how to get your browser and stuff blah blah......... I wish someone would write a tutorial Step by step telling how to do a certain task, and why they did it. I see too many tutorials that just tell u what to do not why you do it. Seems kinda pointless if you aren't sure why your doing something.

Reply

Señor Maniac
taken from php.net

Reply

Latest Entries

nickmealey
nice, I'm going to learn. That got me started, thanx

Reply

quiksilver
Thank you, this tutorial has been very helpful. I hope to learn more in PHP.

Reply

karlo
QUOTE(MSTR @ Mar 13 2005, 03:24 AM)
only way to learn php, is to understand atleast the basic of how coding works, not the basics of php but of coding, like understanding arrays, loops, for, if and other statements as well. Understanding variables, and before you get into php, learn to code html by hand.
*

Yes you are right. Before i am using getenv() function and it's really confusing to use it on if() functions. So, I decided to experiment on $_SERVER and it works. I discovered another thing, echo() is much more faster than print(). And, in arrays example $_SERVER, you can access it's arrays without using " and ' example, $_SERVER[REMOTE_ADDR]

Reply

MSTR
only way to learn php, is to understand atleast the basic of how coding works, not the basics of php but of coding, like understanding arrays, loops, for, if and other statements as well. Understanding variables, and before you get into php, learn to code html by hand.

Reply

doom145
THIS IS EXCELLTENT FOR N00BS.....I personally aint a n0b at php but this post is amazing. You could have added mor einfo as its like not very self explaining and some of the points of basic php hasnt been covered like how to make a simple script for a certain run program. BTW php is a way of running different things....its like html but html can only concentrate on one site while php has a bit more logic and hence it works out things and runs more websites.......Php...well u have to learn html b4 u learn php as it is super hard.... smile.gif

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Pages: 1, 2
Similar Topics

Keywords : php, beginners, skazi

  1. Google Base Api For Beginners?!
    (2)
  2. Learn C/c++ From The Beginning
    C/c++ tutorials for beginners and expert at the same time (11)
    Hello every one Today I’m going to write good c c++ tutorials The tutorials are mine showing my
    experience in c c++ i my be using some examples rote in some books (if i do i will pot a link or
    name of the book) And all the tutorials are at the main topic I don’t know how my topic count in
    this case because all I’m going to do is updates the same topic Any way lets just tray and see First
    sings first in order to compile your code you need compiler That compiler is an application that
    converts your code from human readable code to Binary cod or machine code There is all....
  3. I Need A Good Book About Jsp For Beginners
    I'm looking for a good book about learning JSP (0)
    I decided lately that I would like to learn JSP because I will probably need it on a project that I
    will have to make next semester and so I'm looking for a good book about this technology. I know
    that I should use Google first, but I am also posting here to see if someone can help. Also if you
    have a link to some web page with tutorials about JSP which you can recommend me you can post it
    here too. Thank you P.S. I already know Java....
  4. Beginners Guide To Becoming A Computer Hardware Tech
    (2)
    Welcome to my Beginners Guide To Becoming a Computer Hardware Tech guide into getting started with
    computer hardware installation, upgrading and maintaining. I will be talking about various items
    you will need and point to a huge index of links. This includes tutorials on building a computer
    from scratch, tips ands tricks, myths exposed and more. If you plan to build computers from scratch
    then you will need the proper reading in order to get a good understanding of what you will be
    dealing with when you build and maintain computers. The first times on the list ar....
  5. Free Forex Ebook
    For beginners and private traders (0)
    The Forex quick guide... for beginners and private traders QUOTE This book has been developed
    to help the Forex beginner, though experienced and professional traders may find it a handy
    reference. Beginners and novice traders are likely to benefit from reading the entire text, starting
    with Chapter 1, which provides a basic overview of what currency trading is, and how to get started.
    The chapters are set out in a logical flow, but do not need to be read in order to make sense, as
    each works as a discrete unit unto itself. You may prefer to focus first on those cha....
  6. Beginner's Php Tutorial Online At My Site
    (12)
    Hey everyone, over the last week I've been writing a PHP tutorial aimed at absolute beginners
    who have never even seen the syntax of PHP before let alone wrote a PHP script! The tutorial
    assumes you have a basic knowledge of HTML (for the tutorial you will need to write a couple of
    hyper links and forms, nothing complex!) and an internet browser. It tells you about where to
    find the other software needed (apache/XAMPP and a script.text editor) and how to check if it is
    working. The tutorial is basic and focuses on the use of the ECHO, INCLUDE/REQUIRE and I....
  7. A Trap17 How-to Guide For Beginners
    Something for those who can't get enough of the Trap17 Readme file (12)
    I am not entirely sure if this the right place to post about this, but here goes anyway... For
    those who find themselves slightly (or considerably more than slightly) clueless about where to get
    started after getting a hosting account, here is an user guide that might potentially help you
    out. I wrote it out of three hours, so forgive me if it's clumsy, but I'm hoping that a few
    people here may find it useful. Feedback is greatly appreciated /smile.gif"
    style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> I'm planning to build on
    a FAQ....
  8. How To Create Self-unzipping Files
    for beginners (18)
    This tutorial is based on winzip 10.0 (but it should work on other versions). Create or open the
    file you would like unzipped. Now, on the Actions menu, click make .exe file. A popup box should
    popup. Click ok. Now in the popup box that appears, type in the default folder that the program
    will unzip to. Press ok. Now another popup will tell you if you want to test the file, click yes.
    Now click ok again in the box that appears. Now press unzip. If it says - files unzipped
    succsessfully! Click ok and pat your self on the back! You have created the self-....
  9. Beginners Guide To .net Programming.
    (2)
    ok so I was wondering if anyone knows where I can find a good, .net dummy friendly guide? my main
    reason for want to learn it so that I can make .cab files that do registry edits for ppc. I know
    this should be easy to do, Any help would be greatly appreciated. Oh by the way please don't
    flame me as I posted this in the c/c++ forum also, because I know u can program in either c/c++ or
    .net for ppc programs. Thx in advanced, Mike....
  10. Beginners Guide To C/c++ Programming?
    (2)
    ok so I was wondering if anyone knows where I can find a good, c/c++ dummy friendly guide? my main
    reason for want to learn it so that I can make .cab files that do registry edits for ppc. I know
    this should be easy to do, Any help would be greatly appreciated. Thx in advanced, Mike....
  11. Beginner's Guide To Skiing
    Based on my own experience. (4)
    I really like skiing. It is so much fun that you won't know how you could have survived until
    your first time. So here are some things you should know before you head over to your lcoal ski
    area: Dressing: You should get a few basic things: -Base layer: long underwear, especially
    thermals, keep you warm, wick moisture from the skin, keep your legs from getting irritated by your
    ski pants -Middle layer: A fleece jacket; or anything aside from wool, which is very itchy. This
    will keep you warm in cold weather. If your outer jacket or parka (see below) is insulate....
  12. Question: Securing A Website For Beginners
    (1)
    I don't really understand 'bout it. What kind of security we have to make to hold our web
    secure. Only log in features? how bout 'deface' method? how does it work? thx in advance
    Please use detailed topic title. ....
  13. Dos Game Programming In C For Beginners
    (1)
    There are a number of tutorials available for the intermediate game programmer, but there are very
    few good tutorials for beginners who have never drawn a pixel on the screen. A quick search on the
    net reveals hundreds of sites devoted to 3D, polygons, texture- mapping and other advance topics,
    but the beginner has no where to get started. This tutorial is for C programmers who want to get an
    introduction to game programming. find this tutorial at Dos Game Programming in C for Beginners
    ....
  14. Making Interactive Cds With Flash
    My second flash tutorial for Beginners (2)
    Im back again with what i think it would be an interesting tutorial for all of you guys who wants to
    take flash out of the web and make really cool interactive CDS. First of all if all of you are
    thinking right now: "this dude is wrong for making interactive cds you have to use macromedia
    Director", well you are right macromedia director it's used to build interactive cds and dvds
    among other things, but you can also make interactive cds with Flash, the thing is: if you want to
    make a simple interactive CD you can totally do it with flash, of course Director brings ....
  15. Windows Security Over Regedit
    beginners guide: how to cheat windows (1)
    how to make windows secure over REGEDIT have you ever questioned yourself, how to hide the
    complete desktop of a guestaccount? well, here is the way to get it; ---THE USER NEEDS ADMIN
    RIGHTS FOR A SHORT TIME--- logon with the user u wanna manipulate . ---!!!--- click
    on start/run and type "regedit". the registryeditor should come up and you should see your
    computer registry with the hive-keys classes_root current_user local_machine etc. browse through
    "hkey_current_user" and go to "software\microsoft\windows\currentversion\p....
  16. Johnny's "thinking Outside The Box" For Graphics Designers
    A guide for beginners and experts alike (8)
    Johnny's Thinking Outside the Box for graphics designers A guide for beginners
    and experts alike Before you read this, be warned that this is not a tutorial. It won't teach
    you a new skill or method. It's simply here to teach you to be a better designer in general.
    This guide is mostly directed at sig designers, but I'm sure it can be applied to just about any
    field of art. I think the current level of graphics design can be stepped up a few notches, so
    here's a few tips. 1 -- Your own style The most valuable thing to any....
  17. Trap17 Website Building Tips For Beginners
    For a non-technical beginner's first site (2)
    Now you've got your Trap17 free hosting account, what do you do with it? This is not a
    tutorial on how to use everything available on Trap17 free hosting accounts. This is just a brief
    overview to give you an idea on where to start. I am not an extremely technical person myself, I
    know a little bit of HTML and CSS, and that's about it. So this is written for a non-technical
    beginner who knows little or nothing about building websites.
    **************************************************************************************** I have not
    used any of the features ....
  18. Beginners Guide To Smart Browsing
    (3)
    As a PC tech in my medium sized city, I often get asked this golden little question; " How do I
    protect my computer from malware? " And, and I love saying this because it always falls on deaf
    ears, I respond; " The only way to keep your computer safe is to browse intelligently. " And thats
    often when the customers leave, probably instantly forgetting what I said and changing their thought
    process to something along the lines of what theyre going to eat for lunch or who they would do if
    that person were there right now. But I digress. Now, since I never get to FINIS....
  19. Friendship Software For Dinamic Websites
    Open source software for beginners (2)
    Some people find web content management complicated. I am looking for a good open source portal
    with friendship features. For me is important an open source portal software used to create
    websites, intranets, extranets, project and community portals. I am curious to know experiences with
    different softwares and share opinions about this topic.....
  20. Which Scripting Language To Start With
    Best question for beginners (8)
    I dont know any scripting languages: Perl, PHP, asp, javascript etc. Which language would be better
    to start with? Any link to start with?(or I should start with google?)Let me know what good books
    are available. Well that is after you guys have recommended the language to start with
    /blink.gif' border='0' style='vertical-align:middle' alt='blink.gif' /> ....
  21. Create Simple Ligntnings
    Photoshop Tutorial (for beginners) (12)
    This is all very easy. If you don't know how to do it alredy, just follow these simple steps and
    try in now: 1) Open a new document (I use 500x500 pixels) 2) Press D to make the foreground and
    background colour the default. 3) Go to Filter -> Render -> Clouds. You should now have something
    like this: 4) Now go to Filter -> Render -> Difference Clouds. My image now looks like this:
    5) Type Ctrl + i to invert the image. It will now look something more like this: 6) Now type Ctrl
    + L. The Level box will pop ut. Make shore you have these settings: That'....
  22. Saint Michael Css2 Tips And Tricks Issue #1
    css tips and tricks for you beginners and experts (1)
    since my htmls tips and tricks issues are hot on the forum i decided to do some css stuff so lets
    get to work all you beginners and experts. Also note to those who read this is coming from other
    websites so i am not claming any rights to this info even though some people think if they make it,
    its theirs which is bs cuz if that were true then there would not be to many websites on the
    internet now would their?. Ok the scripting im using for right now is the the actually scripting
    on the website without external linking first css trick that is sometimes good to use is....
  23. Another Simple Php Tutorial For Beginners
    another easy-to-apply-and-use tutorial (5)
    Another easy to use and to apply PHP tutorial. CODE <?php print
    $_SERVER['USER_AGENT']; ?> Means to OUTPUT the visitor's browser.
    CODE <?php print $_SERVER['REMOTE_ADDR']; ?> Means to OUTPUT
    the visitor's IP address. CODE <?php print
    $_SERVER['SERVER_NAME']; ?> Means to OUTPUT the current server.
    CODE <?php print $_SERVER['DOCUMENT_ROOT']; ?> Menas to OUTPUT
    the current location where the PHP script is located....
  24. Installing Apache,mysql And Php In Windows
    Good text for beginners (4)
    Here it is the text i have found in CODE http://www.jevontech.com/ , and i'm posting
    this text because i remember the dificults i had when i wanted to do this right... Installing
    Apache , MySQL and PHP under Windows Introduction While many webservers run Linux, Unix or BSD most
    personals computers run on Windows. So it would be quite comfortable if web designers and
    developers could develop on their home computer.So in this E-book we will focus on configuring your
    computer to use Apache, MySQL and PHP, so you can work on your home computer. Step 1: Ins....

    1. Looking for php, beginners, skazi

Searching Video's for php, beginners, skazi
Similar
Google Base
Api For
Beginners?&#
33;
Learn C/c++
From The
Beginning -
C/c++
tutorials
for
beginners
and expert
at the same
time
I Need A
Good Book
About Jsp
For
Beginners -
I'm
looking for
a good book
about
learning JSP
Beginners
Guide To
Becoming A
Computer
Hardware
Tech
Free Forex
Ebook - For
beginners
and private
traders
Beginner'
;s Php
Tutorial
Online At My
Site
A Trap17
How-to Guide
For
Beginners -
Something
for those
who
can't
get enough
of the
Trap17
Readme file
How To
Create
Self-unzippi
ng Files -
for
beginners
Beginners
Guide To
.net
Programming.
Beginners
Guide To
C/c++
Programming?
Beginner'
;s Guide To
Skiing -
Based on my
own
experience.
Question:
Securing A
Website For
Beginners
Dos Game
Programming
In C For
Beginners
Making
Interactive
Cds With
Flash - My
second flash
tutorial for
Beginners
Windows
Security
Over Regedit
- beginners
guide: how
to cheat
windows
Johnny's
"thinki
ng Outside
The
Box"
For Graphics
Designers -
A guide for
beginners
and experts
alike
Trap17
Website
Building
Tips For
Beginners -
For a
non-technica
l
beginner'
;s first
site
Beginners
Guide To
Smart
Browsing
Friendship
Software For
Dinamic
Websites -
Open source
software for
beginners
Which
Scripting
Language To
Start With -
Best
question for
beginners
Create
Simple
Ligntnings -
Photoshop
Tutorial
(for
beginners)
Saint
Michael Css2
Tips And
Tricks Issue
#1 - css
tips and
tricks for
you
beginners
and experts
Another
Simple Php
Tutorial For
Beginners -
another
easy-to-appl
y-and-use
tutorial
Installing
Apache,mysql
And Php In
Windows -
Good text
for
beginners
advertisement



Php For Beginners - By Skazi



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE