My first PHP

Platform:  PHP
Published  Dec 12, 2008
Updated  Dec 12, 2008
Code
 



That's the HTML of it, I guess...I'm new to this so please go easy on me...That goes before the actual code. <? if($age >= "18"); {
echo "Hello, you are $age "; }
else{
echo "Sorry, you are not the correct age."; }
?>
</body>
</html>

Comments

Sign in to comment.
jonesy44   -  Jun 30, 2009
Wrong place to ask dude. Try Forums :)
 Respond  
gilbertsavier   -  Jun 30, 2009
Hi,

I need a code that lets my customers upload a image file from their computer and then that file does 2 things

1. gets uploaded to upload folder on my server
2. a copy of that file gets e-mailed to me

this is what I have so far, any improvements/additions on this code would really be appreciated...

1.//GET IMAGE INFO
2.
3. $dir = 'images/';
4. $file_name = $_FILES['file']['name'];
5. $file_tmp = $_FILES['file']['tmp_name'];
6.
7. //CHECK FOR UPLOADED FILE
8. if(is_uploaded_file($file_tmp)){
9. //MOVE TO DIR
10. move_uploaded_file($file_tmp, $dir.$file_name);
11. }

Thanks & regards,
Lokananth
 Respond  
F*U*R*B*Y*   -  Dec 20, 2008
or have it as a dropdown/select box for the equation? :P
 Respond  
jcbones   -  Dec 19, 2008
Nah, PHP won't parse symbols like that, it will just print it back to the page.

Try this instead...

Code
 
 Respond  
jonesy44   -  Dec 13, 2008
Set a variable with the post, it should parse all symbols.. i think, never really had the need to try it out before..
 Respond  
DangerOfFate   -  Dec 13, 2008
D:....I'm -trying- to code a PHP calculator of a sort, just an input field for someone to type like...2+2 and it'll return 4 when the action is submitted.
 Respond  
jonesy44   -  Dec 13, 2008
Nice to see another PHP scripter out there :L lacks a few on this site hehe.

I must be bored or something.. but this would incorporate all your HTML & PHP together;

Code
 
 Respond  
Hawkee   -  Dec 13, 2008
Danger, why don't you edit the snippet to reflect our suggestions?
 Respond  
DangerOfFate   -  Dec 12, 2008
heh..Thanks..I'm just a pessimist, I guess.
 Respond  
F*U*R*B*Y*   -  Dec 12, 2008
And also, i don't think you should put your own work down....

lol failure....


and

Tags lamer


Sure its not the best script out there, but its your first PHP script. I know my first php script was

Code
 
you wouldn't believe how much problems i had, firstly i had <?php hello world ?> i spent hours trying to get it to work, i ended up asking RussellReal and he told me i was missing the " and the ; but he wasn't going to tell me where.

We all start off at the same place, it doesn't matter what the quality of the script is, its worth the knowledge of what you gain from creating this script.
 Respond  
F*U*R*B*Y*   -  Dec 12, 2008
Also not all servers have.... uhmmm can't think of it of the top of my head, but they won't allow $age they require you to do $age = $_POST['age'];.


Not bad for a first script :) Hope to see more, and if your stuck on a problem, yell out on the forums and we'll all help out =)
 Respond  
DangerOfFate   -  Dec 12, 2008
Thanks Hawkee.
 Respond  
Hawkee   -  Dec 12, 2008
You should just put all the code together into the snippet. There's no reason to separate it like this. Also, always use <?php instead of <? to avoid compatibility problems with certain servers.
 Respond  
DangerOfFate   -  Dec 12, 2008
lol failure....
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.