Welcome Guest [Log In] [Register]
Add Reply
Jon's small changes; Small changes, not huge addons.
Topic Started: Mar 21 2008, 09:23 PM (314 Views)
Jon

Okay, first is a searchable text field in the user profile area to view other user's profiles.

The file that we want to open for this is viewinfo.php

Near the top, you'll see this:

Quote:
 

<?

/* Requested Username error checking */

$req_user = trim($_GET['user']);

if(!$req_user || strlen($req_user) == 0 ||

!eregi("^([0-9a-z])+$", $req_user) ||

!$database->usernameTaken($req_user)){

die("Username not registered");


Change it to:

Quote:
 

<?
$req_user = trim($_GET['user']);
if(!$req_user || strlen($req_user) == 0 ||
!eregi("^([0-9a-z])+$", $req_user) ||
!$database->usernameTaken($req_user)){
die("User doesn't exist. If you are sure this account exists, please check your spelling or contact the website administrator.");


This just changes the error message we get if we put an invalid username into the text box which we're about to create now.

Now, to add the searchable text box, in viewinfo.php, find this section: (it's near the bottom)

Quote:
 

/* If logged in user viewing own account, give link to edit */

if(strcmp($session->username,$req_user) == 0){

echo "<br><a href=\"useredit.php\">Edit Account Information</a><br>";

}



/* Link back to main */

echo "<br>Back To [<a href=\"main.php\">Main</a>]<br>";



?>


Add the following underneath the closing php tag:

Quote:
 

<form name="input" action="userinfo.php?="
method="get">
Search for a user:
<input type="text" name="user">
<input type="submit" value="Submit">
</form>


And there it is. Now if you search for a valid user, it will display their profile. If you search for an invalid user, you'll get an error message saying that the user doesn't exist.

Small, but useful. :)
Offline Profile Quote Post Goto Top
 
Lamez

neat, I might have to use that
Offline Profile Quote Post Goto Top
 
Admin
Administrator
thanks, I will be using this
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Other · Next Topic »
Add Reply