6 Replies - 360 Views - Last Post: 14 August 2012 - 01:24 AM Rate Topic: -----

#1 JonyGraphics  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 13-August 12

PHP system prints the worlds in the field to a .txt file on click

Posted 13 August 2012 - 01:44 PM

Hello everyone,
I've been trying to make a PHP script.

For example I have a vote page on some website, so I created a nice customized form that includes in the following:

[field] Username:

[button] Go voting

So whenever a member puts his username and clicks Go voting, the system will print his username to a .txt file with the following information:

[IP] [DATE] [Username]

e.x [ 192.168.1.1 3-3-12 17:58 JonyGraphics ]

People were telling me to do it with mysql instead of .txt but I find mysql diffcult for that kind of script.

So my question is, How would that script be called?
I tried to find a tutorial for that but could never find the right name for this script.
I tried searching for PHP logging but could not find what I was looking for.

Thank you.

P.S This is not to scam people for their IP addresses, this is needed to log all of the votes for my server's accounts.

Regards
Jony.

Is This A Good Question/Topic? 0
  • +

Replies To: PHP system prints the worlds in the field to a .txt file on click

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 3873
  • View blog
  • Posts: 11,410
  • Joined: 18-April 07

Re: PHP system prints the worlds in the field to a .txt file on click

Posted 13 August 2012 - 01:52 PM

You just have to point your form at the script in its "action" property. For instance, assume our script was called "voting.php". We could create the form like this...

<form method="post" action="voting.php">
<!-- some fields -->
</form>



Now when the user submits the form it will take the values in the form and send them to voting.php for processing. Depending on the method used (here we use POST) the values of the fields will be in either the $_POST array or $_GET array.

So if our field was named "username" then you will find its value in $_POST["username"]. :)
Was This Post Helpful? 0
  • +
  • -

#3 JonyGraphics  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 13-August 12

Re: PHP system prints the worlds in the field to a .txt file on click

Posted 13 August 2012 - 01:57 PM

Yeah but the action is to paste the username, ip, date to the .txt file and redirect to another page which is the actual vote page powered by another website.

So whenever players don't get their rewards in-game (on my minecraft server), I can look up thought the logs.txt or if someone is spamming with multiple accounts.

So basically I were only looking for the name of that script, to find a full tutorial about this.

Thank you for the reply!
Was This Post Helpful? 0
  • +
  • -

#4 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 3873
  • View blog
  • Posts: 11,410
  • Joined: 18-April 07

Re: PHP system prints the worlds in the field to a .txt file on click

Posted 13 August 2012 - 02:11 PM

You hook your form up to your script, where it will write the username, ip and date to the text file and then from there you redirect the user to the other page on the other website.

;)

Edit: You can also call your PHP script using an AJAX call where it will then write to the text file. Then let it proceed through the processing of your form to the other site. Either way works.

This post has been edited by Martyr2: 13 August 2012 - 02:13 PM

Was This Post Helpful? 0
  • +
  • -

#5 JonyGraphics  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 13-August 12

Re: PHP system prints the worlds in the field to a .txt file on click

Posted 13 August 2012 - 02:22 PM

Okay thanks, Ill look forward into something.
But as I said it would be better if there could be some tutorials released about something similar!

thank you Marty.
Was This Post Helpful? 0
  • +
  • -

#6 JonyGraphics  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 13-August 12

Re: PHP system prints the worlds in the field to a .txt file on click

Posted 13 August 2012 - 02:49 PM

Sorry for the bump, well erm I can't edit?

Okay I did something that posts only the username from the field into the logs.txt file

Index:

<html>
<body>
<form name="form1" method="post" action="signup.php"> Username: <input type="text" name="user">
<br
</form>
</body>
</html>



Process.php:

<?php



$username = $_POST['user'];

//data display logs.txt

$data = "$username\n";



//logs.txt write

$fh = fopen("logs.txt", "a");

fwrite($fh, $data);



//Close the file

fclose($fh);



print "Processing...";



?>




It now posts the username that the user put in.

How do I make it find out his IP + the date he posted his username at?

Thank you.
Was This Post Helpful? 0
  • +
  • -

#7 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 2898
  • View blog
  • Posts: 7,553
  • Joined: 08-June 10

Re: PHP system prints the worlds in the field to a .txt file on click

Posted 14 August 2012 - 01:24 AM

View PostJonyGraphics, on 13 August 2012 - 11:49 PM, said:

How do I make it find out his IP + the date he posted his username at?

you’ll find both in the $_SERVER superglobal.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1