Posted on Saturday 2nd June 2007 at 12:49 AM
Ok Here is the problem. Imputting all the changes as shown on the 'Hide Email' tutorial. But the only problem I have is it does not update the DB. Example. Once I put it on I changed the default (via phpMyAdmin) to yes. Then I went to editprofile.php and chose it to say no. Updated the profile and went back to members.php and it does not hide it. Nor does it show no selected on editprofile.php
Below are the codes.
Members.php
Editprofile.php
Also are the queries I ran and changed.
Original (from tut)
Changed to
Any help is appreciated.
Below are the codes.
Members.php
PHP Code
<?php include('config.php'); // Query database $count_sql = 'SELECT * FROM members'; $count_result = mysql_query($count_sql); //gets the number $count = mysql_num_rows($count_result); $new = mysql_fetch_array(mysql_query("SELECT * FROM `members` ORDER BY `id` DESC LIMIT 0, 1")); // Gets the newest member echo "<strong>Newest member:</strong> " . $new[username]; // displays the newest member ?> <br> <br> <?php session_start(); //allows session include "config.php"; echo "<left>"; if(isset($_GET['user'])){ //if there trying to view a profile //gets the user name and makes it safe $username = addslashes($_GET[user]); //querys the db to find the username $getuser = mysql_query("SELECT * FROM `members` WHERE `username` = '$username'"); //checks see if the username exists in the db $usernum = mysql_num_rows($getuser); //if it don't exist if ($usernum == 0) { //don't exist echo ("User Not Found"); } //if it does exist then show there profile else { $user = mysql_fetch_array($getuser); echo " <b>$user[username]'s Profile</b><br><br> <b>Email:</b> $user[email]<br> <b>Location:</b> $user[location]<br> <b>Sex:</b> $user[sex]<br> <b>Age:</b> $user[age]<br> <b>About:</b> $user[about]<br> <b>Interests:</b> $user[interests]<br> <b>MSN:</b> $user[msn]<br> <b>Skype:</b> $user[skype]<br> <b>AIM:</b> $user[aim]<br> <b>deviantART:</b> $user[deviantart]<br> <b>Yahoo:</b> $user[yahoo]<br> "; $user_rank = change_levels($user[userlevel]); //change level } } else { //gets all the members from the database $getusers = mysql_query("SELECT * FROM `members` ORDER BY `id` ASC") or die(mysql_error()); //loops there name out while ($user = mysql_fetch_array($getusers)) { echo "<a href='members.php?user=$user[username]'>$user[username]</a><br>"; } } echo "<left>"; ?>
Editprofile.php
PHP Code
<?php session_start(); //allows session include "config.php"; echo "<left>"; //checks see if there logged in if($logged[id]) { if(isset($_GET['update'])){ $email = addslashes(htmlspecialchars($_POST[email])); $ehidden = htmlspecialchars($_POST[ehidden]); $location = addslashes(htmlspecialchars($_POST[location])); $age = (int)addslashes(htmlspecialchars($_POST[age])); $sex = addslashes(htmlspecialchars($_POST[sex])); $about = addslashes(htmlspecialchars($_POST[about])); $interests = addslashes(htmlspecialchars($_POST[interests])); $msn = addslashes(htmlspecialchars($_POST[msn])); $skype = addslashes(htmlspecialchars($_POST[skype])); $aim = addslashes(htmlspecialchars($_POST[aim])); $deviantart = addslashes(htmlspecialchars($_POST[deviantart])); $yahoo = addslashes(htmlspecialchars($_POST[yahoo])); //checks the sex if its ok if(($sex == "Male") || ($sex == "Female")){ //updates there profile in the db $update = mysql_query("UPDATE `members` SET `email` = '$email', `sex` = '$sex', `age` = '$age', location = '$location', ehidden = '$ehidden', `about` = '$about', `interests` = '$interests', `msn` = '$msn', `skype` = '$skype', `aim` = '$aim', `yahoo` = '$yahoo', `deviantart` = '$deviantart' WHERE `username` = '$logged[username]'"); echo "Profile updated!<br> <a href="login.php">Return to Member Area</a> or <a href="editprofile.php">Continue Editing</a>"; } //if the sex is invalid else { echo "Invalid sex input!"; } } else { $getuser = mysql_query("SELECT * FROM `members` WHERE `username` = '$logged[username]'"); $user = mysql_fetch_array($getuser); echo "<form action='editprofile.php?update' method='post'> <table width='350'> <tr> <td width='150'>Email:</td> <td width='200'><input type='text' name='email' size='30' maxlength='55' value='$user[email]'></td> </tr> <tr> <td>Show Email?</td> <td><select name='ehidden'> <option selected='selected' value='yes'>Yes</option> <option value='no'>No</option> </select></td> </tr> <tr> <td>Location:</td> <td><input type='text' name='location' size='30' maxlength='40' value='$user[location]'></td> </tr> <tr> <td>Age:</td> <td><input type='text' name='age' size='3' maxlength='3' value='$user[age]'></td> </tr> <tr> <td>Sex:</td> <td><select size='1' name='sex' value='$user[sex]'> <option value='Male' "; if($user[sex] == Male) { echo "selected"; } echo "> Male </option> <option value='Female' "; if($user[sex] == Female) { echo "selected"; } echo "> Female </option> </select></td> </tr> <tr> <td>About:</td> <td><textarea name='about' cols='23.5' rows='7' maxlength='700' >$user[about]</textarea></td> </tr> <tr> <td>Interests:</td> <td><input type='text' name='interests' size='30' maxlength='40' value='$user[interests]' /></td> </tr> <tr> <td>MSN:</td> <td><input type='text' name='msn' size='30' maxlength='40' value='$user[msn]' /></td> </tr> <tr> <td>Skype:</td> <td><input type='text' name='skype' size='30' maxlength='40' value='$user[skype]' /></td> </tr> <tr> <td>AIM:</td> <td><input type='text' name='aim' size='30' maxlength='40' value='$user[aim]' /></td> </tr> <tr> <td>deviantART:</td> <td><input type='text' name='deviantart' size='30' maxlength='40' value='$user[deviantart]' /></td> </tr> <tr> <td>Yahoo:</td> <td><input type='text' name='yahoo' size='30' maxlength='40' value='$user[yahoo]' /></td> </tr> <tr> <td colspan='2'><left> <input type='submit' value='Update'> </left></td> </tr> </table> </form>"; } } else { echo "You are not logged in."; } echo "<left>"; ?>
Also are the queries I ran and changed.
Original (from tut)
PHP Code
ALTER TABLE `members` ADD `ehidden` CHAR( 3 ) NOT NULL DEFAULT 'no';
Changed to
PHP Code
ALTER TABLE `members` ADD `ehidden` CHAR( 3 ) NOT NULL DEFAULT 'yes';
Any help is appreciated.