SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2003
    Location
    Baltimore
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Code not working!!

    Hey all,

    Ive had this little code on my site which put users emails that they submit into a text file so i can email them at a later date. I now am trying to use this code to input URLs but when people type in their URL it says that it has been added to the list but hasn't.

    In the email list itself it creates a new line but doesn't have any URL in it so i believe that it is just not printing the URL but still creating a new line.

    Can someone in the know just look through this code for me please and see where i screwed it up because it used to work perfectly!

    Here is the code for the user when they are inputting:

    <?php
    print"<form method='POST' action='write.php'>Your URL: <input type='text' name='email' size='40'><br><p><input type='submit' value='Submit'></p></form></CENTER>";
    ?>

    and then here is the code in write.php which deals with the saving of the information into the file:

    <?php

    include("config.cfg");

    // Open file for APPENDING! NO DATA LOST!!!
    if(!$fd = fopen($outfile, "a")) {
    echo("Error opening file.");
    exit;}

    // Write the string to the file.
    if(!fwrite($fd, $writestring)) {
    echo("Error writing to file.");
    exit;}

    fclose($fd);

    include("thankyou.php");
    ?>

    and here is what is in the config.cfg file:

    <?php

    $writefile = "email";
    $outfile = "emails.txt";
    $writestring = "$email\n";

    ?>

    so anyone got any idea why it is not working?

    I am pretty sure it is something in the index file because i haven't touched any of the other files.

    Also i have CHMODed everything correctly!

    :S:S lol

    thanks for any help
    AJ

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    when register globals is off, you must reference variables which come from the user by using the superglobals. in your case, you form submits via post, so you need to use the $_POST array. if you form was get, then you would use $_GET. if your looking for a cookie, it would be $_COOKIE etc..

    $writestring = $_POST['email'] . "\n";

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2003
    Location
    Baltimore
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks its working now!

    How come it used to work then? but now it doesnt?

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Someone must have disabled register_globals ... inside of your servers php.ini file.


Bookmarks

Posting Permissions

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