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 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2003
    Location
    Here
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I need help with this form script...

    The script is:

    <?
    function WriteToFile ($Name, $News) {
    /* Function Write to File takes up two arguments - URL and News - which will be written to an external file. */
    $TheFile = "data.txt";
    $Open = fopen ($TheFile, "a");
    if ($Open) {
    fwrite ($Open, "$Name\t$News\n");
    fclose ($Open);
    $Worked = TRUE;
    } else {
    $Worked = FALSE;
    }
    return $Worked;
    } // End of Write to File Function.
    ?>
    <html>
    <head>
    <title>Using Files</title>
    <body>
    <?php
    /* This page recieves and handles the data generated by "form.html". */
    $Pattern = "(http://)?([^[:space:]]+)([[:alnum:]\.,-_?/&=])";
    if (eregi($Pattern, $Array["Name"])) {
    $Replace = "<a href=\"http://\\2\\3\" target=\"_new\">\\2\\3</a>";
    $Array["Name"] = eregi_replace($Pattern, $Replace, $Array["Name"]);
    $CallFunction = WriteToFile($Array["Name"], $Array["News"]);
    if ($CallFunction) {
    print ("Your submission-$Array[Name]-has been received!<br>\n");
    } else {
    print ("Your submission was not processed due to a system error!<br>\n");
    }
    } else {
    print ("Please enter something\n");
    }
    ?>
    </body>
    </html>


    And I don't know which parts to take out, so that the Name will not be linked, ince I took this code from a book, and I would like to modify it. Thank you.

  • #2
    New Coder
    Join Date
    Mar 2003
    Location
    Somewhere far beyond
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts
    cut this out:
    PHP Code:
    $Replace "<a href=\"http://\\\\2\\\\3\" target=\"_new\">\\\\2\\\\3</a>";
    $Array["Name"] = eregi_replace($Pattern$Replace$Array["Name"]); 
    WBR, Weirdan.

  • #3
    New Coder
    Join Date
    Feb 2003
    Location
    Here
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you. I'm gonna try it now.


  •  

    Posting Permissions

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