During the last few weeks, I often find on my website these "Comment":

htmlkurss.xyz \r\n \r\nI've been visiting your website a few times 
and decided to give you some positive feedback because I find it very       
Well done. \r\n \r\nI was wondering if you as someone with experience of 
creating a useful website could help me out with my new site by givingsome 
feedback about what I could improve? \r\n \r\nYou can find my site by 
searching for "casino gorilla" in Google (it's the gorilla 
themed online casino comparison). \r\n \r\nI would appreciate if you could 
check it out quickly and tell me what you think. \r\n\r\ncasinogorilla.com 
\r\n \r\nThank you for help and I wish you a great week!",
"datetime":"04\/28\/2019 01:44:49 pm"}

I have this Website (under construction) and people can write comments here.

Then I have two files, my PHP file where I have my code for HTML Form-Element, and the PHP class constructor, and I have a .txt file, where the comments are written.

Can anyone explain what does it does?

closed as off-topic by schroeder Apr 29 at 20:06

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be about Information security within the scope defined in the help center." – schroeder
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Nothing. Looks like spam. The better question to ask is how it appeared on your website? Can you provide more details? – user2320464 Apr 29 at 17:59
  • 1
    seems like a genuine comment with no malicious parameters. – Vipul Nair Apr 29 at 18:50
  • What "code" are you talking about? Nothing seems strange here. – schroeder Apr 29 at 18:52
  • Are you talking about \r\n \r\n and "? – schroeder Apr 29 at 18:55
  • yes , about it , and 5 Days bevor more.. , all comment here i.imgur.com/K5MfdB8.png – 567hz Apr 29 at 19:45

It looks like you are dumping the POST array into a text file when an individual comments.

When inspecting the DOM, I can see you make use of post.

<form method="POST">
        <label for="name"><b>Name * </b></label>
        <input type="text" id="name" name="Name" value="">
        <label for="email"><b>E-mail * </b></label>
        <input type="email" id="email" name="Email" value="">

So I'm guessing in the back-end your php code looks like this:

$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$txt = $_POST;
fwrite($myfile, $txt);

What you can do to get rid of the "code" is obtain the individual elements, such as this example:

$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$txt = "Commenter Name: " . $_POST["Name"] . "\r\n";
$txt .= "Email: " . $_POST["Email"] . "\r\n--\r\n";
fwrite($myfile, $txt);

This will allow you to obtain the original string values without the formatting or array notation. Above Example:

Commenter Name: Jhon Doe 
Email: Joe@blow.com
Commenter Name: Jane Doe 
Email: test@example.com

This should make things a lot cleaner and easier to read, I recommend storing comments in a table or mailing to yourself using the php mail(); function.

  • @567hz This should help: w3schools.com/php/php_forms.asp – DevSushi Apr 29 at 20:22
  • thanks for you comment ! , can you please give me a address where explain it.. , i am new with php... i know on html build table with <table> and <tr> but together with the function mail() , i do not know.... – 567hz Apr 29 at 20:22
  • @567hz For the mail function, you will need to setup a mail server. Use Dovecot, postfix, and make a local mail user. Here is a tutorial: tecmint.com/setup-postfix-mail-server-in-ubuntu-debian – DevSushi Apr 29 at 20:25
  • thanks , i will does it on my localhost , but what to does on my web host ... – 567hz Apr 29 at 21:03
  • For your hosted server you will need to make MX records in your DNS for it to work, sorry I did not mention this: my.bluehost.com/hosting/help/mx (set servername to your servers IP to loopback, leave subdomain empty, and have priority at the default or 5) – DevSushi Apr 29 at 21:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.