webdevRefinery Forum: How to make a recent-signups page in PHP? - webdevRefinery Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Rate Topic: -----

User is offline goldenpages 

  • Group: Members
  • Posts: 46
  • Joined: 03-August 12
  • Expertise:HTML,PHP

Posted 17 August 2012 - 06:07 PM (#1)

How to make a recent-signups page in PHP?


How do I let users know when somebody signs up on the home page?
You know once someone signs up, their profile is: http://mysite.com/profile.php?id=150

that means it will display the data of user 150.

But once someone signs up, how do I let people know on the home.php page?

Something like a recent-posts but instead, recent-signups.

So it will show everyone who signed up within the last few days and will
give a link to their profile. (profile.php?id=150)

How do i go about doing something like this?

I already have a full signup, signin, and signout and profile system.

Its just stressful having to do the ?id=150 to get to each users' page. something like a user's list.

How do i do it?

Thanks guys
0


User is offline TheMaster 

  • *-c0de master-*
  • Group: Members
  • Posts: 748
  • Joined: 24-May 10
  • LocationAustralia
  • Expertise:HTML,CSS,PHP,Java

Posted 17 August 2012 - 06:26 PM (#2)

This very much depends in how you are inserting the users into the user table. Whenever I am making a signup system - I have a "join_date" column in the table, so that I can do something like this.

If you dont, I would suggest adding one. The following could might still work without a date field though:

This outputs latest 5 users to have joined.
$query = mysql_query("SELECT user FROM users ORDER BY id desc LIMIT 5");

while ($row = mysql_fetch_array($query)) {

echo $row['user'] . '<br>';

}


Are you using PDO? If so just tell me so I can 1) Cheer, and 2) Change the code to make it work with that!
0


User is offline goldenpages 

  • Group: Members
  • Posts: 46
  • Joined: 03-August 12
  • Expertise:HTML,PHP

Posted 17 August 2012 - 07:15 PM (#3)

TheMaster, on 17 August 2012 - 06:26 PM, said:

This very much depends in how you are inserting the users into the user table. Whenever I am making a signup system - I have a "join_date" column in the table, so that I can do something like this.

If you dont, I would suggest adding one. The following could might still work without a date field though:

This outputs latest 5 users to have joined.
$query = mysql_query("SELECT user FROM users ORDER BY id desc LIMIT 5");

while ($row = mysql_fetch_array($query)) {

echo $row['user'] . '<br>';

}


Are you using PDO? If so just tell me so I can 1) Cheer, and 2) Change the code to make it work with that!



i am using pdo
0


User is offline TheMaster 

  • *-c0de master-*
  • Group: Members
  • Posts: 748
  • Joined: 24-May 10
  • LocationAustralia
  • Expertise:HTML,CSS,PHP,Java

Posted 17 August 2012 - 07:35 PM (#4)

Are you using mySQL?
0


User is offline goldenpages 

  • Group: Members
  • Posts: 46
  • Joined: 03-August 12
  • Expertise:HTML,PHP

Posted 17 August 2012 - 07:36 PM (#5)

For some reason, when i execute the code below, it only echo's the first record in the table, not all of them:

<?php

try 

{

$conn = new PDO("mysql:dbname=users;host=localhost", "register", "mysql" );

$sql = $conn->prepare("SELECT * FROM users");

$sql->execute();

$result = $sql -> fetch(); 
 
echo $result ["FirstName"] . " " . $result ["LastName"]; 

$conn = null;

}

catch(PDOException $e)
{
echo $e->getMessage();
$conn = null;
}

?>


0


User is offline TheMaster 

  • *-c0de master-*
  • Group: Members
  • Posts: 748
  • Joined: 24-May 10
  • LocationAustralia
  • Expertise:HTML,CSS,PHP,Java

Posted 17 August 2012 - 07:53 PM (#6)

You need to change the fetch() line to:

while ($result = $sql -> fetch()) {
echo $result ["FirstName"] . " " . $result ["LastName"];
}

0


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users


Enter your sign in name and password


Sign in options
  Or sign in with these services