Jump to content

[SOLVED] members page


Recommended Posts

i have this code for a members page,

and when someone enters an invalid URL with an id that doesn't exist it should echo a message, but it doesn't work, it just says email: hidden.

 

 

any ideas

 

<?php
if ($_SESSION['is_valid'] == true){
if (isset($_GET['id'])) {
if ((int) $_GET['id'] > 0) {
$userid = $_GET['id'];
$sql = "SELECT * FROM $user WHERE `user_id`='{$userid}' LIMIT 0,1;";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
$userprofname = $row['user_name'];
$profemail = $row['user_email'];
echo "$userprofname<br>";
$show_email = $row['show_email'];
if ($show_email == 1)
{ 
echo 'Email:<a href="mailto:'.$profemail.'">    Email Me</a>';
}
elseif ($show_email == 0)
{
echo "Email:   Hidden";
}
exit();
}
else {
echo "Invalid user! <br />";
echo "<a href=\"members.php\">Return to Members</a>";
exit();
}
}
//No ID passed to page, display user list:
$query = "SELECT user_id, user_name FROM $user";
$result = mysql_query($query) or die("Error:" . mysql_error());
if (mysql_num_rows($result) > 0) {
echo "User List:<br />";
while ($row = mysql_fetch_assoc($result)) {
  echo '<a href="?id=' . $row['user_id'] . '">' . $row['user_name'] . '</a><br />';
}
}
}
else
{
echo "Please login to view this page.";
}
?>

Link to comment
Share on other sites

ok, i tried this , but it still does the same

 

<?php
require_once 'includes/header.php';
require_once 'includes/db_connect.php';
?><div class="bg"></div>
<div class="clock"><?php echo gmdate('l, jS F Y');?> <span id="txt"></span></div> 
<div class="member">
<?php
if ($_SESSION['is_valid'] == true){
if (isset($_GET['id'])) {
if ((int) $_GET['id'] > 0) {
$userid = $_GET['id'];
$sql = "SELECT * FROM $user WHERE `user_id`='{$userid}' LIMIT 0,1;";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
$userprofname = $row['user_name'];
$profemail = $row['user_email'];
echo "$userprofname<br>";
$show_email = $row['show_email'];
if ($show_email == 1)
{ 
echo 'Email:<a href="mailto:'.$profemail.'">    Email Me</a>';
}
elseif ($show_email == 0)
{
echo "Email:   Hidden";
}
exit();
}
}
//No ID passed to page, display user list:
$query = "SELECT user_id, user_name FROM $user";
$result = mysql_query($query) or die("Error:" . mysql_error());
if (mysql_num_rows($result) < 1) {
     echo 'This ID does not exist in the database';
  echo "<a href=\"members.php\">Return to Members</a>";
}if (mysql_num_rows($result) > 0) {
echo "User List:<br />";
while ($row = mysql_fetch_assoc($result)) {
  echo '<a href="?id=' . $row['user_id'] . '">' . $row['user_name'] . '</a><br />';
}
}
}
else
{
echo "Please login to view this page.";
}
?>
</div>
<?php
mysql_close();
require_once 'nav_bar.php';
require_once 'includes/footer.php';
?>

Link to comment
Share on other sites

Try this again after the $result = mysql_query($sql);

 

 

if (!empty($_POST['email'])) {

  $e = escape_data($_POST['email']);

  } else {

  echo '<p><font color="red"

  size="+1">The email address you have entered is incorrect!</font></p';

  $e = FALSE;

 

 

Link to comment
Share on other sites

ok, so it is now working with this code,

<?php
require_once 'includes/header.php';
require_once 'includes/db_connect.php';
?><div class="bg"></div>
<div class="clock"><?php echo gmdate('l, jS F Y');?> <span id="txt"></span></div> 
<div class="member">
<?php
if ($_SESSION['is_valid'] == true){
if (isset($_GET['id'])) {
if ((int) $_GET['id'] > 0) {
$userid = $_GET['id'];
$sql = "SELECT * FROM $user WHERE `user_id`='{$userid}' LIMIT 0,1;";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
$userprofname = $row['user_name'];
$profemail = $row['user_email'];
echo "$userprofname<br>";
$show_email = $row['show_email'];
if (mysql_num_rows($result) < 1) {
     echo 'This ID does not exist in the database';
}
if ($show_email == 1)
{ 
echo 'Email:<a href="mailto:'.$profemail.'">    Email Me</a>';
}
elseif ($show_email == 0)
{
echo "Email:   Hidden";
}
exit();
}
else {
echo "Unknown User ID! <br />";
echo "<a href=\"members.php\">Return to Members Page</a>";
exit();
}
}
//No ID passed to page, display user list:
$query = "SELECT user_id, user_name FROM $user";
$result = mysql_query($query) or die("Error:" . mysql_error());
if (mysql_num_rows($result) > 0) {
echo "User List:<br />";
while ($row = mysql_fetch_assoc($result)) {
  echo '<a href="?id=' . $row['user_id'] . '">' . $row['user_name'] . '</a><br />';
}
}
}
else
{
echo "Please login to view this page.";
}
?>
</div>
<?php
mysql_close();
require_once 'nav_bar.php';
require_once 'includes/footer.php';
?>

 

but it is still showing the Email: Hidden

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.