Page 1 of 2

help?

Posted: Wed Sep 18, 2002 9:55 pm
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

Code

Posted: Wed Sep 18, 2002 10:01 pm
by AVATAr
Show the code.. :)

Posted: Wed Sep 18, 2002 10:10 pm
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

php version

Posted: Wed Sep 18, 2002 10:27 pm
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.

Posted: Wed Sep 18, 2002 10:38 pm
by Coca-Bear
php version 4.0.6

Coca-Bear

so

Posted: Wed Sep 18, 2002 10:46 pm
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.

Posted: Wed Sep 18, 2002 10:59 pm
by Coca-Bear
thanks. that worked :P :P and i'll read up on that thread..

again thanks for the help.

Coca-Bear

keep walking

Posted: Wed Sep 18, 2002 11:02 pm
by AVATAr
Just.. keep going... (keep walking!!! JW)
:D

Posted: Thu Sep 19, 2002 2:52 am
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

Posted: Thu Sep 19, 2002 3:21 am
by Takuma
That's because the permission of the directory that you are trying to copy is not set properly, set it to 777.

Posted: Thu Sep 19, 2002 3:30 am
by Coca-Bear
ok this may sound stupid.. how do i set it to 777? :p

thanks

Coca-Bear

Posted: Thu Sep 19, 2002 5:39 am
by ~J~R~R
Search for CHMOD in your FTP program or use Telnet.

Posted: Thu Sep 19, 2002 7:50 am
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

Posted: Thu Sep 19, 2002 9:08 am
by Takuma

Code: Select all

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

Code: Select all

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

Posted: Thu Sep 19, 2002 9:22 am
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