Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 121
0 Users 2 Guests Online

Hide Email

NOTE: Remove All PHP Tags
First you want to open up your phpMyAdmin and run this query:
Code

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:
Code

Email: <input type='text' name='email' size='30' maxlength='55' value='$user[email]'><br>


Add After:
Code

Would You Like Your Email To Be Shown?:
<select name="ehidden">
<option selected="selected" value="no">No</option>
<option value="yes">Yes</option>
</select> <br />


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

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


Add After:
PHP Code
1
2
$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
2
$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
2
location = '$location'


With
PHP Code
1
2
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
2
Email: $user[email]<br>


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


=====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
Author:
Views:
2691
Rating:
Posted on Thursday 24th July 2008 at 02:46 PM
Dava
Dava
the problem is u have to change $profile[ehidden] to
$mytag[ehidden]
Posted on Tuesday 15th July 2008 at 08:37 PM
UrbanTwitch
UrbanTwitch
I got it working! :D
Posted on Tuesday 8th April 2008 at 02:30 AM
UrbanTwitch
UrbanTwitch
Does not work: http://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
Here is my forum topic.
Posted on Friday 1st June 2007 at 11:27 PM
SkillMaster
SkillMaster
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
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
Did you remember to change the default in the MYSQL Database?
Posted on Friday 1st June 2007 at 11:10 PM
MCP
MCP
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
Whats the Exact error?
Posted on Friday 1st June 2007 at 09:54 PM
MCP
MCP
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';