treehouse : what would you like to learn today?
Web Design Web Development iOS Development

fwrite adding unwanted charecters

  • Hi, I have this PHP code:

    <?php
              if (isset($_POST['page'])) {
                  $file = fopen(ROOT . 'pages/' . $_POST['page'], "wb");
                  if(!$file === false) {
                      echo fwrite($file,  stripslashes($_POST['content']));
                      fclose($file);
                      $title = strtolower(str_replace(" ", "_", $_POST['title']));
                      rename(ROOT . 'pages/' .  $_POST['page'], ROOT . 'pages/' . $title . '.php');
                  }
             }
          ?>
    

    And it keep adding newlines and spaces where i don't what them. Please can you help me!