shadow skazi 0 Report post Posted February 24, 2005 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 <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<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 but we don't want to do that because the site would look icky. We don't want to lose traffic, do we?<?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...<?phpif (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.<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....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 Copyright2005 shadow skazi++++++++++++++++ Share this post Link to post Share on other sites
whyme 0 Report post Posted February 25, 2005 nice little tutorial. Share this post Link to post Share on other sites
ill 0 Report post Posted February 25, 2005 Simple, and great for people who wanna start with PHP. Good job! Share this post Link to post Share on other sites
Amezis 0 Report post Posted February 25, 2005 Nice tutorial, and I really need to learn how to use php... Share this post Link to post Share on other sites
egbakaet 0 Report post Posted February 25, 2005 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! Share this post Link to post Share on other sites
thebluekirby 0 Report post Posted February 25, 2005 wow... this tuturial can come in handy when I feel like scripting in PHP! thanks! Share this post Link to post Share on other sites
Ralphie 0 Report post Posted February 25, 2005 thanks a lot for that tutorial. i am hoping to soon learn php so this is a nice little intro Share this post Link to post Share on other sites
beeseven 0 Report post Posted February 26, 2005 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"): <HTML><HEAD><TITLE>Title</TITLE><BODY><FORM METHOD="POST" ACTION="file.php">Name: <INPUT TYPE="text" NAME="name"><INPUT TYPE="submit"></FORM><?phpecho "Hello, " . $_POST['name'];?></BODY></HTML> Share this post Link to post Share on other sites
NotoriousZach 0 Report post Posted February 26, 2005 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. Share this post Link to post Share on other sites
Se?or Maniac 0 Report post Posted February 26, 2005 taken from php.net Share this post Link to post Share on other sites
maddog39 0 Report post Posted March 1, 2005 You all gotta understand that just like math, there is many many different ways to code and use php. There is always another way to do things. For instace the echo function can also be replaced the the print function because they do the exact same thing. Also if you are trying to get an enviornment like HTTP_USER_AGENT or REMOTE_ADDR you can do it by either the $_SERVER variable or the getenv(''); function. See what I mean. So if your trying to correct someone , chances are that there PHP is right and your just showing them another way to do the same thing. Get my point. Well I hope so, lol. Share this post Link to post Share on other sites
eskick 0 Report post Posted March 5, 2005 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"): <HTML><HEAD><TITLE>Title</TITLE><BODY><FORM METHOD="POST" ACTION="file.php">Name: <INPUT TYPE="text" NAME="name"><INPUT TYPE="submit"></FORM><?phpecho "Hello, " . $_POST['name'];?></BODY></HTML> 54199[/snapback] im just into installin php im not into makin php stuff but soon i will Share this post Link to post Share on other sites
Benz1435 0 Report post Posted March 5, 2005 I dont understand php very much.. im gonna have to start learning it more. Share this post Link to post Share on other sites
doom145 0 Report post Posted March 11, 2005 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.... Share this post Link to post Share on other sites
MSTR 0 Report post Posted March 12, 2005 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. Share this post Link to post Share on other sites