Php Tutorial - Basics...up To Mysql/file Commands

free web hosting
Free Web Hosting, No Ads > CONTRIBUTE > The Internet > Web Design

Php Tutorial - Basics...up To Mysql/file Commands

ppj
the best way to start php is probably not adjusting a script IMO - that misses out a stage. - the very first stage - here...

Why use php? because it allows things to be generated very quickly - without lots of html pages. It enables users you choose to allow, to input their own content to the pages you want them to.

1) save these files as anyfilename.php - pick your names, upload them to a php enabled server and go to the url they are at...

2) understand <?, ?>, .php, //////, /* */, and ;

Code:

<?

?>


THis tells the web browser when to expect php coding. So... when writing php, this needs to encase all php code - or it will be formatted as html.

Naming a filename .php allows for <? and ?> to be expected - or it will show as html.

Code:

<?
//// hello - this line will be overlooked

/* hello
these lines will be overlooked*/
?>



both of these 'hello's' will not be formatted as php - these 2 bits of code exclude the contained text.

Code:

<?
print "hello"
?>



print tells the php to print the contained text - if a variable is used then ""'s are not usually needed, if "" are used then the content will be shown as html. The above WILL NOT WORK. Each line of php code needs to be ended with a ;.

3) printing basic html

Code:

<?
print 'hello world';
?>



open the file - it will show the words hello world with no formatting.

4) printing and setting variables

Code:

<?
$hello = 'hello world';
///setting variables

print $hello;
///printing variables
?>




5) if else with variables

Code:

<?

$a = $_GET['a'];
///setting variables (3)

if (isset($a)) {
print '<a href="?a=0">Click here</a><br>';
///printing html (2)

print "a is set to:".$a;
} else {
print '<a href="?a=1">Click here</a><br>';
///printing html (2)

print "a is empty";

}

?>




for a form... adjusting my last script from above...


6) create the form html - save as form.php.

Code:

<?
$form = <<<HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Form!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form action="?a=1" method="post" name="" id="">
<table width="50%" border="0" align="center" cellpadding="4" cellspacing="0">
<tr>
<td width="22%">Subject</td>
<td width="78%"><input name="value" type="text" id="value"></td>
</tr>
</table>
</form>
</body>
</html>
<br>

HTML;
?>



that basically mates a text box to enter something into - which posts to ?a=1

then save the following as anythingyouwant.php .... load it...and should work as a simple form.
Code:

<?
include 'form.php';
///include the form we just made - so that you can print it when you need to.


$a = $_GET['a'];
///setting variables - has the script been submitted yet? - get the value from the url

if (isset($a)) {
///the script has been submitted

$value = $_POST['value'];
///retrieve the posted data.

print '<a href="/?">Click here</a><br>';
///printing html - return to script not submitted

print "value is set to:".$value;

} else {
////form isnt submitted - so print it.
print "a is empty<br>";

print "therefore include the form<br><br>";
///printing html (2)

print $form;

}

?>




should work... unless i missed off a ; or something silly (let me know below...if i have)


if you want to check the field to make it required - and show a form with a message if its not filled in, then this would be the edited version.....

Code:

<?
include 'form.php';
///include the form - so that you can print it when you need to.


$a = $_GET['a'];
///setting variables - has the script been submitted yet?

if (isset($a)) {
///the script has been submitted

$value = $_POST['value'];
///retrieve the posted data.

if(isset($value)) {
/////////FIELD SET?////////////

print '<a href="/?">Click here</a><br>';
///printing html - return to script not submitted

print "value is set to:".$value;
} else {
//////FEILD NOT SET - show form again, with message to fill it out///////

print "The required fields are empty<br>";

print "therefore include the form<br><br>";
///printing html (2)

print $form;


}

} else {
////form isnt submitted - so print it.
print "a is empty<br>";

print "therefore include the form<br><br>";
///printing html (2)

print $form;

}

?>



then learn mysql and your sorted

 

 

 


Reply

keifer
I have been looking for an ez to use PHP tutorial and finally i found one. I kinda have an understanding about PHP from playing around with scripts and modifiying them but i dont know all the rules and tags yet. Im sure this tutorial will help me improve my coding skills greatly (Im not saying im a pro by all means tho hehe) Thanx for taking the time to post it.

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:

Similar Topics

Keywords : php, basics, mysql, file, commands

  1. The Only Reason I Choose Ms Sql Server Rather Than Mysql
    (0)
  2. How To Extract The Audio From Youtube Videos
    get an mp3 file from youtube (2)
    How To Extract The Audio From YouTube Videos This lovely simple tutorial will tell you how
    to extract the audio from YouTube videos. Obviously , I am not in any way advocating that you take
    copyrighted music that is available illegally in video-form on YouTube and extract the audio from
    those videos rather than going down to HMV and buying the music. In this tutorial I will be using
    the following video: http://uk.youtube.com/watch?v=gUhhRc5eWNw Firstly, you download the video,
    which is simple. Just go to www.downloadyoutubevideos.com and paste the video....
  3. Need Advice On Setting Up Mysql Database.
    I have a huge amount of daily data updates to be inserted. (3)
    First of all, to get the idea of what I am trying to achieve here, please have a look at my
    idea thread, entitled Idea For Using A Cron Job To Grab Daily Travian Map.sql Updates . This gives
    a prelude to the project, what it is for, what it is supposed to do, etc. Now, what I need is
    specific advice on setting up the mySQL database(s) to implement this idea. There is a useful FAQ
    file for how to make use of the map.sql data located on the help.travian.com website, which also
    gives an example of the CREATE TABLE instruction that matches the data in the map.sql fi....
  4. Mysql Db Is Down Getting Following Error
    (2)
    My Mysql is Down can I get some help please? Appreciate it. Patrick Domain: patrickcurl.com Error:
    phpMyAdmin - Error #2002 - The server is not responding (or the local MySQL server's socket is
    not correctly configured)....
  5. It Went Well For A While
    MySQL problem back in all its glory. (5)
    Some time ago I had a stubborn problem when trying to access one of the interactive pages on my
    website and getting the following error: QUOTE Warning: fopen() : open_basedir restriction in
    effect. File(include/errors.xml) is not within the allowed path(s):
    (/home/mrdee:/usr/lib/php:/usr/local/lib/php:/tmp) in
    /home/mrdee/public_html/admin/include/commonfunctions.php on line 682 Warning:
    fopen(include/errors.xml) : failed to open stream: Operation not permitted in
    /home/mrdee/public_html/admin/include/commonfunctions.php on line 682 Cannot open XML data file:
    incl....
  6. File Sharing Hosts!
    Totally Free (0)
    Here, are some web-sites that allow you to save files on their servers. And there an opportunity to
    earn cash as well, as someone will download your files: QUOTE 1. www.netload.in 2.
    www.uploaded.to 3. www.depositfiles.com 4. www.rapidshare.com 5. www.ziddu.com 6.
    www.vip-file.com 7. www.sms-files.net 8. www.letitbit.net 9. www.eazyupload.net ....
  7. File Sharing Hosts!
    You can make money over here (2)
    Hello, guys! I found several web-sites which pay you for downloads of your files. It was
    approved on other forums that are paying defenitely; they are not scam projects. Here, they are: 1.
    www.depositfiles.com 2. www.letitbit.com 3. www.vip-file.com 4. www.upload.com 5. www.smsfiles.net
    There are more information on their official web-sites. To know more about it, please visit them.
    But, if you have questions, I may answer them.....
  8. Internal File Transfer
    (5)
    Is there some kind of file transfer utility that can be used within the intranet for file
    transfers..? We have so much need for such an utility here in my work place.... The problem with
    what we are using is very big... we are basically using skype in my workplace and the problem with
    that is it happens with the internet... So whenever i transfer files via skype it occupies the
    bandwidth.... which is very bad since we have a limited bandwidth connection. So... What i require
    is a utility where the transfer happens within the network and not via the internet. So... if ....
  9. Free Software For File Recovery
    RECUVA (4)
    Hi all, I was loking for a software to recover my lost files and I found this /biggrin.gif"
    style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> And the best part is ,
    its free Recuva - File Recovery Recuva (pronounced "recover") is a freeware Windows utility to
    restore files that have been accidentally deleted from your computer. This includes files emptied
    from the Recycle bin as well as images and other files that have been deleted by user error from
    digital camera memory cards or MP3 players. It will even bring back files that have been d....
  10. Where Is The Bookmarks File Stored With Ff2?
    (4)
    My bookmarks are critical and lengthy. I'd like to save them to a flash drive, since my laptop
    is ancient and it's been acting up lately. I went into the FireFox folder, but couldn't find
    the bookmarks info anywhere. there's a bookmarks.html page, but it doesn't contain the
    actual bookmarks. Where does FF2 store the bookmarks? Or is there an easier way to copy and paste
    the bookmarks to another file? /huh.gif" style="vertical-align:middle" emoid=":huh:" border="0"
    alt="huh.gif" /> 2 poor 4 a sig ....
  11. Html Form!
    Using MySQL?! (4)
    Hey, I need your help again! I need some good working tutorial how I can update my SQL through
    HTML form. I did use some tutorials online found with the help of google; but they do not work
    properly; I mean there are still small mistakes. I need to have a good tutorial to follow. It
    should be based on security and more things. It has to be done in proper way.......
  12. Mysql, Php, Apache Downloads And Setup Was A Nightmare
    Mysql, PHP, Apache (10)
    Mysql, PHP, Apache downloads were easy enough. Then came the setup process. This seemed to be an
    endless mess of going back and forth trying to get the programs to work together properly. Finaly I
    got them working after about 48 hours. There are great tutorials on the setup process, but only one
    or two actualy were easy enough for me to understand. I would like to see if I was the only one who
    had issues with this setup. Are there easier ways to setup the three?....
  13. Database With Mysql++
    getting mySQL++ to work with trap17 (7)
    Hi, I'm trying to build an online game and figured the easiest way to do the server list would
    be to make a mySQL database for it; however, I use the con() command on the IP i get from pinging my
    website and I always get an abnormal program termination; however, it will work with the mySQL on my
    own machine. The code is below: CODE #include <iostream> #include <iomanip>
    #include <mysql++> #include "pass.h"//holds my password (i program at
    school) int main(void) {     Connection con("t3jem3_test","....
  14. Mysql Won't Update
    (4)
    Ok, so I'm making some arcade administration software so I don't have to add games the hard
    way, well anyway, one of the features I have is that on the homepage is a featured author and as
    such I just have it so it updates one line in the mySQL. Well, the page with the form passes on the
    varibles fine and the updating page recieves them because I echoed everything, then I build the
    query and I even echo the query and it comes out exactly how I want it to, but for some reason, the
    database itself won't update even though all the varibles are there. Here's....
  15. Need To Shrink The File Size Of Web Image? - Photoshop Tricks
    (3)
    QUOTE NEED TO SHRINK THE FILE SIZE? USE TRANSPARENCY Want a killer tip for squeezing even
    more size out of your GIF Web images? Make something transparent. That's right, if you can pick
    an area of your image to make transparent, your file size will drop like a rock. For example, if
    you're putting a logo over a white background and you can make the white area around the logo
    transparent, your file size will be significantly smaller. The transparent areas are virtually
    ignored when determining file size, because, after all, there's nothing there. ....
  16. Qupis : Free Hosting With Php, Mysql, Cpanel. (one Line Text Ad At Bottom)
    a member of Xisto (41)
    Hello Members, We are proud to introduce a new member to Xisto group of sites.
    Qupis : Free Web Hosting 150 MB space, 5000 MB Bandwidth, php,
    mysql, CPanel (Latest). Emails, FTP, Addon domains, Parked Domains etc.
    http://www.Qupis.com
    Feel free to add your reviews and comments about it. -Trap17
    Management ....
  17. Read File (.txt) On Another Website Using Jsp?
    (3)
    in my jsp program,i need to read a file (.txt) on another website,how can i do this? thanks a lot.
    shorten title ....
  18. 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....
  19. How To Open A .daa File
    (39)
    Hi there, How do i have to open a file with extension .daa Somebody told me to copy it on cd and to
    run it from cd rom but i got the same problems. What dp i need to do to ppen the file? Thanks....
  20. Linux Question: Amarok And File Permissions
    please help, i can't get it to work with all music files (4)
    hey, i use to use Linux DC++ to download music from some hubs and i usually download it to
    /home/downloads/ and then i move the files to my collection on another HDD a sata one, on
    sda3/music/ but when i move the files using krushader root mode they become posessed by root and
    amarok can't play them displaying a locker on the file's icon. I tried to " chmod 774 music
    ", where music is my music directory, as root in konsole but no luck. What should i do to make a
    whole directory accessible from amarok as user?....
  21. How To Put Music In The Background Of A Powerpoint Presentation
    without having the viewer download the music file (10)
    Well, i made this power poit presentation in memory of my grandfather as many of you kno, passed
    away exactly a week ago....and i am trying to get this song to play as background music..and i did,
    but there is one humongus problem... in order for the people who are viewing it to hear the
    background music they have to download the music file as well ad the powerpoint presentation, which
    on my DSL conntection taked almost 2 minutes, and i could just imagine what it will be for a dial-up
    user (my grandma who wants to see it)... Some people may say, its impossible, but i kn....
  22. Simple C File Handling In Action
    Small code snipet which covers most of basic file handling and navigat (3)
    Yesterday I suddenly got a lot of work. The same work we try to push off, yes you are right all
    formalities to get the code review incorporated and update all source code files with code review
    headers. Imagine if you need to open 300 files one by one and append code review headers at the
    end. Since most files are reviewed in groups of 20 to 30 files. We require one header to be placed
    in say 20 to 30 files. To simplify I went back to my class assignment days and wrote this small c
    utility to open all files passed on command line and open attach code review headers an....
  23. Subquery In Mysql
    (5)
    Is there anyway to make subqueries work in MySQL? I'm pretty certain someone out there knows
    how. /smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /> Can anyone help?
    CODE Select * from ITEMS where ID="Select Max(ID) from ORDERS"; This works
    for MSAccess and SQL Server but why not in MySQL? I'll be writing some reports and I've
    shifted database from MSAccess to MySQL. Help! Thanks.....
  24. My Review Of Megaupload.com
    File Sharing Service (25)
    I'm sure most of you have heard of Megaupload, a service which enables you to upload your files
    to their server and share it with other people for free. I use such services so that I can share
    unlicensed manga through my site. Well, here's my review, and a bit of a rant at the end...
    /happy.gif' border='0' style='vertical-align:middle' alt='happy.gif' /> UPLOAD: 9/10 It's so
    easy! All you have to do is click on the browse button and choose the file you want to upload.
    Then, fill up the other options in the bottom when necessary. Send it and watch it ....
  25. Transfer File Of Any Size Using Winsock Control
    Winsock Help (5)
    This tutorial shows how to transfer file of any size using winsock control. - Open VB; - Select
    standard exe; - Press Ctrl + t to show the add component window; - Select winsock control and
    microsoft common dialog; - Add one winsock control in the project; - Name it winsock1; - If you want
    to add chat then add another winsock and name it winsock2; - Insert another winsock object if you
    want to add chat also; - Add a microsoft common dialog box; - Name it cd; - We will use this
    winsock1 object to transfer the file and winsock2 for chat; ------------- The basic idea : ....
  26. Import From Excel File Into Mysql Database
    (8)
    Has anyone tried using the excel import function that comes with phpmyadmin
    http://www.phpmyadmin.net/home_page/ - it does not require any additional plug-ins or scripts and
    is fairly straightforward to use. In phpmyadmin, if you click on the database table which you wish
    to import the data to , there is a link on the bottom left corner which says "insert data from a
    text file into the table" - although it says text file it still can be used to import an excel file.
    When you click on this link you will be taken to a page where you will be asked for the file name
    (the....
  27. My File Manager Is Working
    (2)
    I tried to change the html for my site in file manager but it just has the default page - the one
    when you activate your site. /sad.gif' border='0' style='vertical-align:middle' alt='sad.gif' />
    How do i change files?....
  28. Increment A Mysql Column
    how to increment a MySQL column one unit (7)
    Hi, I have a column in a MySQL table which contains a counter of the views of the object described
    by this table. I would like to increment this value by one everytime the object is viewed. Obviously
    came into my mind the possibility of retrieving the value of this field, store it in a variable
    increment this value by one and perform an UPDATE query again with this new value. My question is if
    there is a MySQL option to update the field with its actual value plus an unit increment. I hope you
    understand the issue.....
  29. Complete Login System
    With PHP + MYSQL (57)
    Its an complete login sistem made and tested by me and I think itwill be very usefull for people who
    are tryn to learn PHP. First, let's make register.php: CODE <?
    include("conn.php"); // create a file with all the database connections
    if($do_register){ // if the submit button were clicked if((!$name)
    || (!$email) || (!$age) || (!$login) ||
    (!$password) || (!$password2)){ print "You can't let
    any fields in blank....
  30. Mysql Database Setup : Setting Up Mysql Database
    Guide to use MySQL database in your site (6)
    A SMALL INTRODUCTION TO DATABASE ============================= I have seen that many members have
    problems with Database. Here is a small INFO which should give you the IDEA. mySQL is a DATABASE
    server. You can access it using the link in Cpanel. Cpanel can be accessed by
    "www.YOUR-SITE.com/Cpanel" There you have 4 Main Options :- 1> CREATE A DATABASE 2> CREATE A USER
    3> ADD USER TO DATABASE 4> PHPMYADMIN CREATE : IT ALLOWS YOU TO CREATE A DATABASE CREATE USER
    : IT ALLOWS YOU TO CREATE A USER. USING THIS, YOU CAN ACCESS THE DATABASE. A DATABASE CANNOT BE....

    1. Looking for php, basics, mysql, file, commands

Searching Video's for php, basics, mysql, file, commands
Similar
The Only
Reason I
Choose Ms
Sql Server
Rather Than
Mysql
How To
Extract The
Audio From
Youtube
Videos - get
an mp3 file
from youtube
Need Advice
On Setting
Up Mysql
Database. -
I have a
huge amount
of daily
data updates
to be
inserted.
Mysql Db Is
Down Getting
Following
Error
It Went Well
For A While
- MySQL
problem back
in all its
glory.
File Sharing
Hosts! -
Totally Free
File Sharing
Hosts! -
You can make
money over
here
Internal
File
Transfer
Free
Software For
File
Recovery -
RECUVA
Where Is The
Bookmarks
File Stored
With Ff2?
Html
Form! -
Using
MySQL?!
Mysql, Php,
Apache
Downloads
And Setup
Was A
Nightmare -
Mysql, PHP,
Apache
Database
With Mysql++
- getting
mySQL++ to
work with
trap17
Mysql
Won't
Update
Need To
Shrink The
File Size Of
Web Image? -
Photoshop
Tricks
Qupis : Free
Hosting With
Php, Mysql,
Cpanel. (one
Line Text Ad
At Bottom) -
a member of
Xisto
Read File
(.txt) On
Another
Website
Using Jsp?
A Trap17
How-to Guide
For
Beginners -
Something
for those
who
can't
get enough
of the
Trap17
Readme file
How To Open
A .daa File
Linux
Question:
Amarok And
File
Permissions
- please
help, i
can't
get it to
work with
all music
files
How To Put
Music In The
Background
Of A
Powerpoint
Presentation
- without
having the
viewer
download the
music file
Simple C
File
Handling In
Action -
Small code
snipet which
covers most
of basic
file
handling and
navigat
Subquery In
Mysql
My Review Of
Megaupload.c
om - File
Sharing
Service
Transfer
File Of Any
Size Using
Winsock
Control -
Winsock Help
Import From
Excel File
Into Mysql
Database
My File
Manager Is
Working
Increment A
Mysql Column
- how to
increment a
MySQL column
one unit
Complete
Login System
- With PHP +
MYSQL
Mysql
Database
Setup :
Setting Up
Mysql
Database -
Guide to use
MySQL
database in
your site
advertisement



Php Tutorial - Basics...up To Mysql/file Commands



 

 

 

 

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