PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Coca-Bear
Forum Newbie
Posts: 16 Joined: Wed Sep 18, 2002 9:55 pm
Location: SA
Contact:
Post
by Coca-Bear » Wed Sep 18, 2002 9:55 pm
hi i just started in php. and i signed up to a free webhoster (
http://www.netfirms.com ) that supports php. now i have made a simple form and a simple upload form. but when i try them out $_ do not work. everything else works just not $_ someone said that i dont have gobal register on.. how do i enable them using a web hoster? there is no php.ini to edit or anything?
Can anyone help? maybe susgest a webhoster(free) that actaully works?
Thanks
Coca_Bear
AVATAr
Forum Regular
Posts: 524 Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:
Post
by AVATAr » Wed Sep 18, 2002 10:01 pm
Show the code..
Coca-Bear
Forum Newbie
Posts: 16 Joined: Wed Sep 18, 2002 9:55 pm
Location: SA
Contact:
Post
by Coca-Bear » Wed Sep 18, 2002 10:10 pm
oops forgot that
this is main php page
Code: Select all
<html>
<head>
<title>Coca-Bear's PHP Testing!</title>
</head>
<body>
<?php echo "Hi Welcome to my website!!!!<p>"; ?>
<?php
$_one = "10";
$two = "20";
$equals = ($one + $two);
$today = getdate();
$month = $todayї'month'];
$mday = $todayї'mday'];
$year = $todayї'year'];
$hour = $todayї'hours'];
$min = $todayї'minutes'];
$sec = $todayї'seconds'];
$day = $todayї'weekday'];
?>
<form action="action.php" method="POST">
Your name: <input type="text" name="name" />
Your age: <input type="text" name="age" />
<input type="submit">
</form>
<form enctype="multipart/form-data" action="action.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="100000000">
Send this file: <input name="userfile" type="file">
<input type="submit" value="Send File">
</form>
<?=$_one?> + <?=$two?> = <?=$equals?>
<BR>
<?php echo " Date: $day $month $mday, $year"; ?>
<BR>
<?php echo " Time: $hour : $min"; ?>
</body>
</html>
this is action.php
Code: Select all
<html>
<head>
<title>Right....</title>
</head>
<body>
Hi <?php echo $_POSTї"name"]; ?>.
You are <?php echo $_POSTї"age"]; ?> years old.
<?php
if (is_uploaded_file($_FILESї'userfile']ї'tmp_name'])) {
copy($_FILESї'userfile']ї'tmp_name'], "/test");
} else {
echo "Possible file upload attack. Filename: " . $_FILESї'userfile']ї'name'];
}
/* ...or... */
move_uploaded_file($_FILESї'userfile']ї'tmp_name'], "/test");
?>
</body>
</html>
Coca-Bear
AVATAr
Forum Regular
Posts: 524 Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:
Post
by AVATAr » Wed Sep 18, 2002 10:27 pm
What version of php are you using?
use:
there you can read all the info about your php server.
Coca-Bear
Forum Newbie
Posts: 16 Joined: Wed Sep 18, 2002 9:55 pm
Location: SA
Contact:
Post
by Coca-Bear » Wed Sep 18, 2002 10:38 pm
php version 4.0.6
Coca-Bear
AVATAr
Forum Regular
Posts: 524 Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:
Post
by AVATAr » Wed Sep 18, 2002 10:46 pm
So... use:
Code: Select all
Hi <?php echo $HTTP_POST_VARSї'name']; ?>.
You are <?php echo $HTTP_POST_VARSї'age']; ?> years old.
read
Passing Variables in PHP 4.2+ if you are interested.
Coca-Bear
Forum Newbie
Posts: 16 Joined: Wed Sep 18, 2002 9:55 pm
Location: SA
Contact:
Post
by Coca-Bear » Wed Sep 18, 2002 10:59 pm
thanks. that worked
and i'll read up on that thread..
again thanks for the help.
Coca-Bear
AVATAr
Forum Regular
Posts: 524 Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:
Post
by AVATAr » Wed Sep 18, 2002 11:02 pm
Just.. keep going... (keep walking!!! JW)
Coca-Bear
Forum Newbie
Posts: 16 Joined: Wed Sep 18, 2002 9:55 pm
Location: SA
Contact:
Post
by Coca-Bear » Thu Sep 19, 2002 2:52 am
ok i starting to learn alot now
i've made my own counter for my website. now i'm trying to make a simple upload form. but i keep getting this one error. wondering if you ppls can help
Code: Select all
<form action="upload.php" method="post" ENCTYPE="multipart/form-data">
<input type="file" size=40 name="file"><br>
<input type="hidden" name="MAX_FILE_SIZE" value="100000">
<input type="submit" value="upload">
</form>
and this in upload.php
Code: Select all
<?
if ($file == "none") {
print "You must specify a file to upload";
}
else {
copy($file, "/$file_name");
unlink($file);
}
?>
i get this error.
Warning: Unable to create '/cbb2.gif': Read-only file system in upload.php on line 13
any ideas?
Thanks
Coca-Bear
Takuma
Forum Regular
Posts: 931 Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:
Post
by Takuma » Thu Sep 19, 2002 3:21 am
That's because the permission of the directory that you are trying to copy is not set properly, set it to 777.
Coca-Bear
Forum Newbie
Posts: 16 Joined: Wed Sep 18, 2002 9:55 pm
Location: SA
Contact:
Post
by Coca-Bear » Thu Sep 19, 2002 3:30 am
ok this may sound stupid.. how do i set it to 777? :p
thanks
Coca-Bear
~J~R~R
Forum Newbie
Posts: 20 Joined: Wed Sep 18, 2002 12:19 pm
Location: Amsterdam, the Netherlanda
Post
by ~J~R~R » Thu Sep 19, 2002 5:39 am
Search for CHMOD in your FTP program or use Telnet.
Coca-Bear
Forum Newbie
Posts: 16 Joined: Wed Sep 18, 2002 9:55 pm
Location: SA
Contact:
Post
by Coca-Bear » Thu Sep 19, 2002 7:50 am
ok i changed every folder to 777 by.
clicking on the folder then going to Commands>File Actions>CHMOD> and changing the manual to 777. then it says it has been changed... but i still get this error..
Warning: Unable to create '/cbb2.gif': Read-only file system in upload.php on line 13
help
Coca-Bear
Takuma
Forum Regular
Posts: 931 Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:
Post
by Takuma » Thu Sep 19, 2002 9:08 am
Code: Select all
<?php
copy($file, "/$file_name");
?>
to
Code: Select all
<?php
copy($file, "$file_name");
?>
Coca-Bear
Forum Newbie
Posts: 16 Joined: Wed Sep 18, 2002 9:55 pm
Location: SA
Contact:
Post
by Coca-Bear » Thu Sep 19, 2002 9:22 am
oh great it worked
thanks to everyone who has helped me out
oh and just my final question(so far :p) how would i go about moving the file to a certain dir.?
Thanks again
Coca-Bear