Jump to content

[SOLVED] Problems with mkdir and headers


grandman

Recommended Posts

hello,

 

I have a small script which is called when members log-in. if they are a new member, the script should create a new area for them, if and existing member, it should direct them to their own area.

 

My problem comes from trying to check if the area exists, here's the script:

 

<?php   

        $dirname = $_POST["username"];   

        $filename = "/home/vars/public_html/main/se/pass/pat/join/on/control/{$dirname}/";   

       

        if (file_exists($filename)) {   

          header ( "Location: " . "$filename" . $_POST["username"]);

        } else {   

            mkdir("/home/vars/public_html/main/se/pass/pat/join/on/control/{$dirname}", 0777);   

            echo "welcome " . $_POST["username"] . "Your Area Is Being created.";   

      }   

  ?> 

 

Error message:

 

Warning: Cannot modify header information - headers already sent by (output started at /home/vars/public_html/main/se/pass/pat/join/crete.php:1) in /home/vars/public_html/main/se/pass/pat/join/crete.php on line 6 

 

I don't understand, is it saying there are two scripts? i only have one script. also what is being sent anywhere? or is there a way of achieving this?

 

DG

Link to comment
https://forums.phpfreaks.com/topic/135407-solved-problems-with-mkdir-and-headers/
Share on other sites

When redirecting via location() it's has to be the first thing that's displayed on the page. Make sure there is no content or whitepace being output before it.

 

Hello, thank you for that, it must have been the white spaces, all I did was close everything up. I have another problem now though, which is with mkdir, do I have to start a new thread for that?

 

DG

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.