Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Um... script? Please read!

  1. #1
    Join Date
    Apr 2010
    Posts
    8
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Um... script? Please read!

    I'm in search for a script that allows me to do the following.

    *Enter a user name
    *Click submit to be redirected to a specified link
    *Data from the form should be saved and displayed in a .txt file
    *The form's data should log the users' ip address and date they submit the form

    Can anyone help me?

  2. #2
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Well, it depends on how you want it and what you are able to use. For instance PHP will do what you want, but will your server run PHP or is it an ASP server? Is the redirect on your site or to another site. Does the form only have a user name field or is this a complete form with tons of other stuff such as check boxes and radio buttons. Do you require a notification email, should that be sent to the user as well? When you say "display the .txt file" do you actually want it displayed on the page? So anyone filling out the form can see the info that everyone else has filled out?

    Are you only saving user name and IP?

    What is the purpose? Have you seen an example you can link to?

    ....
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #3
    Join Date
    Apr 2010
    Posts
    8
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by BLiZZaRD View Post
    Well, it depends on how you want it and what you are able to use. For instance PHP will do what you want, but will your server run PHP or is it an ASP server? Is the redirect on your site or to another site. Does the form only have a user name field or is this a complete form with tons of other stuff such as check boxes and radio buttons. Do you require a notification email, should that be sent to the user as well? When you say "display the .txt file" do you actually want it displayed on the page? So anyone filling out the form can see the info that everyone else has filled out?

    Are you only saving user name and IP?

    What is the purpose? Have you seen an example you can link to?

    ....
    My web server will run PHP as far as I know, I've been using a couple of PHP scripts and they work fine. The redirect will be to another website, not my own. The form I need only needs a user name field as long as it's able to log at least the date the form was submitted and the user name that was inputted in the field. An email notification isn't needed and yes, anyone may view the .txt file because it shouldn't matter, but I'll try my best to keep it away from the public.

    So really, I only need the user name and the date the form was submitted to save and be displayed to prevent cheating. The purpose of this is to log votes for my website. There are top list websites that allow people to vote, etc., and whatever website has the most votes gets to the top of the list, which produces more traffic through the number one ranked website. I'm trying to figure out how to create this because I'd like to offer special forum rewards and what not to my users to help out the community. I've seen this used on several other websites, but unfortunately I do not have a link to an example.

  4. #4
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Well, what you are after is a little more complicated. But do able. Would be done by now if I wasn't sneaking peeks in from work.

    This will get you started:

    PHP Code:
    <?php
    session_start
    ();
    $userName $_POST["user"];
    $agent $_SERVER['HTTP_USER_AGENT'];
    $uri $_SERVER['REQUEST_URI'];
    $ip $_SERVER['REMOTE_ADDR'];
    $ref $_SERVER['HTTP_REFERER'];
    $visitTime date("r");        //Example: Thu, 21 Dec 2000 16:01:07 +0200
    if($_SESSION["logged"] != "yes")
    {


    $logLine "$visitTime - IP: $ip || User Agent: $agent  || Page: $uri || Referrer: $ref\n";
    $fp fopen("visitorLog.txt""a");
    fputs($fp$logLine);
    fclose($fp);
    $_SESSION["logged"] = "yes";
    }
    ?>
    Basically it will track the time, page they came from, and the IP into a file named visitorlog.txt.

    Next I will work on displaying the user name and the form for that as well as sending them to another page upon submission. Sorry its not all in one piece, doing it as I can, in between boss walking by my desk and doing my paying job
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  5. #5
    Join Date
    Apr 2010
    Posts
    8
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by BLiZZaRD View Post
    Well, what you are after is a little more complicated. But do able. Would be done by now if I wasn't sneaking peeks in from work.

    This will get you started:

    PHP Code:
    <?php
    session_start
    ();
    $userName $_POST["user"];
    $agent $_SERVER['HTTP_USER_AGENT'];
    $uri $_SERVER['REQUEST_URI'];
    $ip $_SERVER['REMOTE_ADDR'];
    $ref $_SERVER['HTTP_REFERER'];
    $visitTime date("r");        //Example: Thu, 21 Dec 2000 16:01:07 +0200
    if($_SESSION["logged"] != "yes")
    {


    $logLine "$visitTime - IP: $ip || User Agent: $agent  || Page: $uri || Referrer: $ref\n";
    $fp fopen("visitorLog.txt""a");
    fputs($fp$logLine);
    fclose($fp);
    $_SESSION["logged"] = "yes";
    }
    ?>
    Basically it will track the time, page they came from, and the IP into a file named visitorlog.txt.

    Next I will work on displaying the user name and the form for that as well as sending them to another page upon submission. Sorry its not all in one piece, doing it as I can, in between boss walking by my desk and doing my paying job
    Haha, no problem, I fully understand and I appreciate you helping me get started. I can't wait till the rest of the bits are pieces are complete.

  6. #6
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Just for clarification, and correct me were I am wrong....

    You have a page people will go to with a text field for them to enter a user name and a submit button. They enter the user name and click submit. They are taken to another website. Their IP, time and user name are logged in a .txt file on your server for you to see.

    I assume they come back to your page at some point? This is where their user name and time they clicked the submit button will be displayed?
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  7. #7
    Join Date
    Apr 2010
    Posts
    8
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by BLiZZaRD View Post
    Just for clarification, and correct me were I am wrong....

    You have a page people will go to with a text field for them to enter a user name and a submit button. They enter the user name and click submit. They are taken to another website. Their IP, time and user name are logged in a .txt file on your server for you to see.

    I assume they come back to your page at some point? This is where their user name and time they clicked the submit button will be displayed?
    Correct all the way until you say they eventually visit the page where everything is logged at, the .txt file. Once they have been redirected to the specified URL and their user name, date and ip address if possible has been logged, it's over and I will thank you forever.

  8. #8
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Oh! Even better. Okay I thought you wanted the info displayed.

    So really, I only need the user name and the date the form was submitted to save and be displayed to prevent cheating.
    I will see what I can do here real quick...
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  9. #9
    Join Date
    Apr 2010
    Posts
    8
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by BLiZZaRD View Post
    Oh! Even better. Okay I thought you wanted the info displayed.



    I will see what I can do here real quick...
    Well yes, displayed that way I can see whom submitted the form, their user name, the date they did it, etc., what we've been discussing for a bit now. :P

  10. #10
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Yes I get that now, I thought you wanted it displayed on the page.

    Now that you don't it was very easy and I am all done. Here you go:

    PHP Code:
    <?
    $userName 
    $_POST["User"];
    $agent $_SERVER['HTTP_USER_AGENT'];
    $uri $_SERVER['REQUEST_URI'];
    $ip $_SERVER['REMOTE_ADDR'];
    $ref $_SERVER['HTTP_REFERER'];
    $visitTime date("r");
    if (
    $_GET['submit']=="true")
     {
     
    $logLine "$visitTime - IP: $ip || UserName:  $userName  ||  User Agent: $agent  || Page: $uri || Referrer: $ref\n";
      
    $fp fopen"visitorlog.txt""a" );
      
    fwrite$fp$logLine );
      
    fclose$fp );
      
    header("Location: http://theOtherSite.com"); //Change this to the site you want them redirected to
     
    }
    ?>
    <html>

    <head>
    <title>User Info</title>
    </head>

    <body>
    <form name="user" method="post" action="form.php?submit=true"> //Change 'form.php' to whatever the name of the file where this code is placed is called.
    <p>User Name:&nbsp;<input type="text" name="User" value="User"></p>
    <p align="center"><input type="submit" name="submit" value="Submit"></p>
    </form>
    </body>

    </html>
    Please note the two edit places ( followed by //Change this line.... ) Make those changes and you are off and running.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  11. The Following User Says Thank You to BLiZZaRD For This Useful Post:

    Envy (04-14-2010)

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
  •