Php For Beginners - By Skazi

Pages: 1, 2
free web hosting

Latest Entry: (Post #17) by nickmealey on Mar 20 2005, 07:36 AM. (Line Breaks Removed)
nice, I'm going to learn. That got me started, thanx
Express your Opinion! Contribute Knowledge.

Free Web Hosting, No Ads > CONTRIBUTE > Tutorials

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. 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 ...
  2. Beginners Guide To Becoming A Computer Hardware Tech - (2)
  3. 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-...
  4. 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...
  5. 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...
  6. 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...



Looking for php, beginners, skazi

Searching Video's for php, beginners, skazi
advertisement



Php For Beginners - By Skazi



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free 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