Hide Email


NOTE: Remove All PHP Tags
First you want to open up your phpMyAdmin and run this query:
PHP Code
  1. ALTER TABLE `members` ADD `ehidden` CHAR( 3 ) NOT NULL DEFAULT 'no';


Okay, you have your Database setup, Now you want to make it so your members can pick Yes or No

In your editprofile.php Find:
PHP Code
  1. Email: <input type='text' name='email' size='30' maxlength='55' value='$user[email]'><br>


Add After:
PHP Code
  1. Would You Like Your Email To Be Shown?:
  2. <select name="ehidden">
  3. <option selected="selected" value="no">No</option>
  4. <option value="yes">Yes</option>
  5. </select>


This is the dropdown so users can pick yes or no.

Next you want to find:
PHP Code
  1. $email = addslashes(htmlspecialchars($_POST[email]));


Add After:
PHP Code
  1. $ehidden = htmlspecialchars($_POST[ehidden]);

This will submit the answer to the database to be stored and if they have FF and the developer toolbar make it so they can't change the value.

Next, Find the line that has:
PHP Code
  1. $update = mysql_query("UPDATE members SET email = '$email', sex = '$sex', age = '$age', location = '$location' where username = '$logged[username]'");


In that line Replace:
PHP Code
  1. location = '$location'


With
PHP Code
  1. location = '$location', ehidden = '$ehidden'

Thats so the info will be stored and you will not get an error.

=====SAVE AND CLOSE=====

Now for the members.php file

In that file find:
PHP Code
  1. Email: $user[email]<br>


Replace With:
PHP Code
  1. <?
  2. ";//End the echo
  3. if($profile[ehidden] == no){//if its not hidden
  4. echo "Email: $profile[email]";//echo the email
  5. }else{//if it is
  6. echo("Email: <i>Hidden</i>");//Dont echo it
  7. } //End else if
  8. echo "
  9. ?>


=====SAVE AND CLOSE=====

You are now finished if you get any errors please post them below and i shall try to help you out
ShadowMage's Avatar
Author:
Views:
2,974
Rating:
Posted on Thursday 24th July 2008 at 02:46 PM
Dava
Dava's Avatar
the problem is u have to change $profile[ehidden] to
$mytag[ehidden]
Posted on Tuesday 15th July 2008 at 08:37 PM
UrbanTwitch
UrbanTwitch's Avatar
I got it working! :D
Posted on Tuesday 8th April 2008 at 02:30 AM
UrbanTwitch
UrbanTwitch's Avatar
Does not work: https://sodadome.com/members.php?user=Dan

As you can see the thing is messed up.
Posted on Saturday 2nd June 2007 at 12:50 AM
MCP
MCP's Avatar
Here is my forum topic.
Posted on Friday 1st June 2007 at 11:27 PM
SkillMaster
SkillMaster's Avatar
Also please post your codes in a new thread in the forums. to seek more assistance.
Posted on Friday 1st June 2007 at 11:26 PM
SkillMaster
SkillMaster's Avatar
Could you please post your members.php code as well i'm thinking that is where the error is.
Posted on Friday 1st June 2007 at 11:25 PM
Diablosblizz
Diablosblizz's Avatar
Did you remember to change the default in the MYSQL Database?
Posted on Friday 1st June 2007 at 11:10 PM
MCP
MCP's Avatar
There is no visible error. It just does not update the SQL DB. Example.

In this case it is the email viewable yes, or no.
Default I set to yes. So to test it I went to my editprofile.php and changed mine to no. Then clicked update, viewed my profile still there. Editprofile.php again and it still says Yes is selected.
Posted on Friday 1st June 2007 at 10:03 PM
ShadowMage
ShadowMage's Avatar
Whats the Exact error?
Posted on Friday 1st June 2007 at 09:54 PM
MCP
MCP's Avatar
The query I submitted is
PHP Code
  1. ALTER TABLE `members` ADD `ehidden` CHAR( 3 ) NOT NULL DEFAULT 'no';


Which I edited to
PHP Code
  1. ALTER TABLE `members` ADD `ehidden` CHAR( 3 ) NOT NULL DEFAULT 'yes';