help?

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:

help?

Post by Coca-Bear »

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? :D

Thanks

Coca_Bear
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Code

Post by AVATAr »

Show the code.. :)
Coca-Bear
Forum Newbie
Posts: 16
Joined: Wed Sep 18, 2002 9:55 pm
Location: SA
Contact:

Post by Coca-Bear »

oops forgot that :P

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&#1111;'month']; 
$mday = $today&#1111;'mday']; 
$year = $today&#1111;'year']; 
$hour = $today&#1111;'hours'];
$min = $today&#1111;'minutes'];
$sec = $today&#1111;'seconds'];
$day = $today&#1111;'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&#1111;"name"]; ?>.
You are <?php echo $_POST&#1111;"age"]; ?> years old.

<?php 

if (is_uploaded_file($_FILES&#1111;'userfile']&#1111;'tmp_name'])) &#123;
    copy($_FILES&#1111;'userfile']&#1111;'tmp_name'], "/test");
&#125; else &#123;
    echo "Possible file upload attack. Filename: " . $_FILES&#1111;'userfile']&#1111;'name'];
&#125;
/* ...or... */
move_uploaded_file($_FILES&#1111;'userfile']&#1111;'tmp_name'], "/test");
?>


 </body>
</html>
Coca-Bear
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

php version

Post by AVATAr »

What version of php are you using?

use:

Code: Select all

<?php
   echo phpinfo();
?>
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 »

php version 4.0.6

Coca-Bear
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

so

Post by AVATAr »

So... use:

Code: Select all

Hi <?php echo $HTTP_POST_VARS&#1111;'name']; ?>.
You are <?php echo $HTTP_POST_VARS&#1111;'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 »

thanks. that worked :P :P and i'll read up on that thread..

again thanks for the help.

Coca-Bear
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

keep walking

Post by AVATAr »

Just.. keep going... (keep walking!!! JW)
:D
Coca-Bear
Forum Newbie
Posts: 16
Joined: Wed Sep 18, 2002 9:55 pm
Location: SA
Contact:

Post by Coca-Bear »

ok i starting to learn alot now :P

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 :P

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") &#123; 
            print "You must specify a file to upload"; 
        &#125; 
        else &#123; 
        copy($file, "/$file_name"); 
        unlink($file); 
        &#125; 
    ?>
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
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

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 »

ok this may sound stupid.. how do i set it to 777? :p

thanks

Coca-Bear
User avatar
~J~R~R
Forum Newbie
Posts: 20
Joined: Wed Sep 18, 2002 12:19 pm
Location: Amsterdam, the Netherlanda

Post by ~J~R~R »

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 »

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 :P

Coca-Bear
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Code: Select all

&lt;?php
copy($file, "/$file_name");
?&gt;
to

Code: Select all

&lt;?php
copy($file, "$file_name"); 
?&gt;
Coca-Bear
Forum Newbie
Posts: 16
Joined: Wed Sep 18, 2002 9:55 pm
Location: SA
Contact:

Post by Coca-Bear »

oh great it worked :P thanks to everyone who has helped me out :P

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
Post Reply