Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts

    My request script is not working

    Hi,
    I've made a script which logs some information the quest has typed in a .txt file.
    Here is the code im using:
    PHP Code:
    This is what you posted: <br>
    Username: <?php echo $_POST["name"]; ?>. <br>
    Desired Password: <?php echo $_POST["password"]; ?> <br>
    Email Adress: <?php echo $_POST["email"]; ?> <br>
    Portfolio Site: <?php echo $_POST["site"]; ?><br>
    <br>
    If this is invalid, please contact me, [email]phpengine@hotmail.com[/email] <br>
    This script will be on PHPEngine later. At the moment i only wrote it for job 
    requests. 
    <?php
    $file 
    "jobs.txt"
    $username $_POST["name"];
    $password $_POST["password"];
    $email $_POST["email"];
    $site $_POST["site"];

    if(
    is_writable($file)){
      
    $open fopen($file,"a");
      
    fwrite($open,$username);
      
    fwrite($open,$password);
      
    fwrite($open,$email);
      
    fwrite($open,$site);
      
    fclose($open);
    }else{
      
    chmod($file,0777) or die("Attempted to chmod the file, it was unsuccessful, please chmod ".$file." to 0777 yourself");
      echo 
    'File was unwritable. Please refresh the page to try again';
    }
    ?>

  • #2
    Regular Coder
    Join Date
    Jan 2004
    Location
    Georgia
    Posts
    306
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <?php
    $file = fopen("jobs.txt", "w+"); //not sure about what access code you need so change this if needed
    $username = $_POST["name"];
    $password = $_POST["password"];
    $email = $_POST["email"];
    $site = $_POST["site"];

    if(is_writable($file)){
    $open = fopen("$file", "a+");
    fputs($open,$username);
    fputs($open,$password);
    fputs($open,$email);
    fputs($open,$site);
    fputs($open);
    }else{
    chmod($file,0777) or die("Attempted to chmod the file, it was unsuccessful, please chmod ".$file." to 0777 yourself");
    echo 'File was unwritable. Please refresh the page to try again';
    }
    ?>




    make sure your files called by this script are in the same directory as this script. make sure the permissions are set according to these access modes ( read/write )
    Last edited by DsgnrsTLZAdmin; 01-17-2004 at 07:26 PM.
    ~Designer's Toolz~

  • #3
    New Coder
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks. But can you tell me what was wrong with my own one?

  • #4
    New Coder
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It's not working. This is what it logs:
    H@-

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    MPCODER, you missed a semicolon at the end of this line:

    PHP Code:
    $file "jobs.txt" 
    Besides that, your script works fine. It only fails if "jobs.txt" does not exist, or if you haven't got the permission to change it's permissions.
    De gustibus non est disputandum.

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There is an error in DsgnrsTLZAdmins script:

    PHP Code:
    $file fopen("jobs.txt""w+"); 
    Both for is_writable() and fopen() later the variable $file should be a string containing the filename, and not an already opened file. Change the line in question to

    PHP Code:
    $file "jobs.txt"
    De gustibus non est disputandum.

  • #7
    New Coder
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks mordred

  • #8
    New Coder
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Now my script works. But can someone tell me how to let it log so that there is a character between every option like if you type hello as username and bye as password it logs this: hello|bye|


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •