View Full Version : php newbie


Rose
02-16-2006, 12:23 PM
well, i know absolutely nothing about php, but i'd love to learn the basics.
But where shall I start? Any good tips? tutorials? links?


What is php actually good for? I tried to read a few tutorials, but I'm simply lost in all this information that simply seems too complicated....
thanks for helping.

harmor
02-16-2006, 03:17 PM
PHP is for dynamic content.
Let's say you had a form, the only way to check and record the data is through PHP. There other alternatives such as Perl, CGI, ASP but PHP is the best solution.

I will a small tutorial to show you what PHP does.

Open Wordpad (I recommend downloading "Crimson Editor" when you get time though).

(All the code in the boxes are on one document, copy and paste the snippets inorder as you see them)

In wordpad put the following.

(Snippet 1)
<?php

if (!isset($_POST['form1']))
{
echo "<form action='' method='post'>
First Name: <input type='text' name='fname' />
Last Name: <input type='text' name='lname' />
<input type='submit' name='form1' value='Submit' />
</form>";
}


What "Snippet 1" is doing is checking if the submit button was pressed, if not display the form.
The form1 of if (!isset($_POST['form1'])) is referring to the value of name in <input type='submit' name='form1' value='Submit' />


(Snippet 2)

else
{
echo "Hello ".$_POST['fname']." ".$_POST['lname']." ";
}

?>

The $_POST['fname'] is referring to the value of name in <input type='text' name='fname' />
I'm sure you get the idea of how it works so no need to mention $_POST['lname']

Paste both snippets in order and save file as "test.php" (With quotes if using wordpad or notepad).

Upload "test.php" to your server and access it through the url.

Douglas
02-16-2006, 06:28 PM
Here is a really really good tutorial:

http://www.tizag.com/phpT/

I think that's one of the best :D

Rose
02-16-2006, 11:57 PM
thanks i'll check it out.

harmor: it's really kind you posted all that for me. but unfortunately it's all chinese to me... :(
can i use the editor i use for html too or do i need a new editor?

and yeah, php is for forms, but isn't php also used if you want to shorten the coding, like if the layout's the same on every page...?

harmor
02-17-2006, 01:14 AM
You can use hte same editor as you use HTML for.

Yes, PHP can be used to shorten your coding time by using "includes" but unlike SSI PHP can use variables which you'll find out bout soon enough.

Combat Babe
02-17-2006, 01:42 AM
You'll find the includes easy after you get the initial hang of it. I could make a thousand includes, but ask me to do anything else with php, and I'd laugh and point at you for thinking I knew how...cause I don't. :stickout: I'm limited to simple forms (if I have a tutorial open) and includes....

555678
02-25-2006, 04:32 PM
www.php.net/tut.php (http://www.php.net/tut.php)