Jump to content

Insert and Display from MySQL


timmah1

Recommended Posts

How do I insert the IP Address of a person that has signed up?

It worked before, but now it won't, any suggestions?
[code]
$ip = $REMOTE_ADDR;
$insert = mysql_query("insert into $table values ('NULL','".$_POST["username"]."',"."PASSWORD('".$_POST["password"]."'),'".$_POST["email"]."',NOW(),'".$_POST["ip"]."',
[/code]

Also, how do I display the timestamp in a way of Month,Day,Year instead of how it's inserted into the database?
It's in the database like this
[b]2006-12-29 10:42:45[/b]
But I want to display it like this
[b]December 29, 2006[/b]

Thanks in advance
Link to comment
https://forums.phpfreaks.com/topic/34575-insert-and-display-from-mysql/
Share on other sites

this is how I got my ip
[code]<?php
$ipaddress = $_SERVER['REMOTE_ADDR'];
?>
[/code]
looks different from yours, so give it a try.

for the date:
[code]<?php
$date = strtotime($r['date'])
$date = date('F d, Y',$date);?>
[/code]

'F d, Y' is the bit you change to suit your format of time.
Ted
The time thing works good, except it is showing today's date

I need it to display the signup_date

How do I do that?

Also, my structure in the database is datetime for the date
[code]
signup_date  datetime    No  0000-00-00 00:00:00 
[/code]
[code]
$signup_date = strtotime($r['signup_date']);
$signup_date = date('F d, Y h:i',$signup_date);
[/code]

Have you connected to your database correctly?
the connection should look like:
mysql_connect("", "", "") or die(mysql_error());
and the bit before it should look:
$read = mysql_query("SELECT signup_date FROM table");
$r = mysql_fetch_array($read);
Ted
that didn't work either, when i do that, the whole page is blank

when I do this
[code]
while ($row = mysql_fetch_array($result)) {
$date = strtotime($row['signup_date']);
$signup_date = date('F d, Y h:i',$signup_date);
echo "<tr>
<td>$row[signup_date]</td>
<td><a href=http://www.stagingtree.com/$row[UserFrom]>$row[UserFrom]</a></td>
<td><a href=http://www.stagingtree.com/myaccount.php?op=view&id=$row[mail_id]>$row[Subject]</a></td>
<td>$row[status]</td>
<td>Delete</td>
</tr>";
[/code]
everything shows up but the date

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.