PHP - Edit Profile Help
Hi. I am working on a website that has restriction level. An admin, a staff, and ordinary user. In my admin page when I click the button "View Users" it shows all the listed users in a table, from admin to ordinary users. And on each entry is an option to either "Delete" or "Edit" the users account.
Now I have a problem with editing user profile because it appears blank fields. Not like in the admin side wherein if I click "Edit" the fields are filled with the users info. How do I do this in the staff's page. Here is the view users code from the admin's page: Code: [Select] if (@$_GET['action'] == "View Users") { print "<font size=6 color=yellow><center>View User's Records</center><br></font>"; $result = mysql_query ("SELECT * FROM users order by user_lvl, lname asc"); $rows = mysql_num_rows($result); if ($rows!=0) { print "<table border=1 align=center cellspacing=10>"; print " <tr bgcolor=yellow align=center> <td>First Name</td> <td>Last Name</td> <td>Email</td> <td>Username</td> <td>Password</td> <td>Phone Number</td> <td>User Privilege</td> <td>Options</td> </tr>"; for ($i=0; $i< $rows; $i++) { $row = mysql_fetch_row ($result); print "<tr bgcolor= white align=center>"; print "<td>$row[0]</td>"; print "<td>$row[1]</td>"; print "<td>$row[2]</td>"; print "<td>$row[3]</td>"; print "<td>$row[4]</td>"; print "<td>$row[5]</td>"; print "<td>$row[6]</td>"; print "<td>[ <a href=admin_main.php?action=Delete&username=$row[3]>Delete</a> ]"; print "[ <a href=admin_main.php?action=Edit&username=$row[3]>Edit</a> ]"; print "</td>"; print "</tr>"; } print "</table>"; print "<font size=1 color=yellow>Number of entries found: $rows"; } else { print "No records found!"; } mysql_free_result ($result); } Now here is the code when I click "Edit" from the "View Users" table: Code: [Select] if (@$_GET['action'] == "Edit") { $result = mysql_query ("Select * from users where username='$_GET[username]'"); $row = mysql_fetch_row ($result); print "<font size=6 color=yellow><center>Edit Records </center></font>"; print "<form method = get> <table border = 1 align=center> <tr> <td><font color=yellow>First Name:</font></td> <td><input type=text name=fname value=$row[0] ></td></tr> <tr> <td><font color=yellow>Last Name:</font></td> <td><input type=text name=lname value=$row[1]></td></tr> <tr> <td><font color=yellow>Email Address: </font></td> <td><input type=text name=email value=$row[2] </td></tr> <tr> <td><font color=yellow>Username: </font></td> <td><input type = text name = username value=$row[3] ></td></tr> <tr> <td><font color=yellow>Password:</font></td> <td><input type=text name=password value=$row[4]></td></tr> <tr> <td><font color=yellow>Contact Number:</font></td> <td><input type = text name = phone_number value=$row[5]></td></tr> <tr> <td><font color=yellow>User Privilege:</font></td> <td><input type = txt name = user_lvl value=$row[6]></td></tr> <tr><td><input type=submit value='Update Users' Submit name=action></td></tr> </table> </form> "; } if (@$_GET['action']=="Update Users") { $result = mysql_query ("UPDATE users SET fname='$_GET[fname]', lname='$_GET[lname]', email='$_GET[email]', username='$_GET[username]', password='$_GET[password]', phone_number='$_GET[phone_number]', user_lvl='$_GET[user_lvl]' where username= '$_GET[username]'"); print "<font size=6 color=yellow><center><blink>Record of User successfully updated!</blink></center></font>"; } Similar TutorialsHi all, I am currently facing a problem, if you look at 'viewprofile.jpg' attachment, you can see that there is an uploaded profile picture. However when I click to edit the profile, the picture is missing (editprofile.jpg), I am just wondering what went wrong? Can someone guide me in troubleshooting this problem? Code: [Select] <?php if (isset($_POST['submit'])) { // Validate and move the uploaded picture file, if necessary if (!empty($new_picture)) { if ((($new_picture_type == 'image/gif') || ($new_picture_type == 'image/jpeg') || ($new_picture_type == 'image/pjpeg') || ($new_picture_type == 'image/png')) && ($new_picture_size > 0) && ($new_picture_size <= CT_MAXFILESIZE)) { //0 indicates a success, other values indicate failure if ($_FILES['file']['error'] == 0) { // Move the file to the target upload folder $target = CT_UPLOADPATH . basename($new_picture); if (move_uploaded_file($_FILES['new_picture']['tmp_name'], $target)) { // The new picture file move was successful, now make sure any old picture is deleted if (!empty($old_picture) && ($old_picture != $new_picture)) { @unlink(CT_UPLOADPATH . $old_picture); } } else { // The new picture file move failed, so delete the temporary file and set the error flag @unlink($_FILES['new_picture']['tmp_name']); $error = true; echo '<p class="error">Sorry, there was a problem uploading your picture.</p>'; } } } else { // The new picture file is not valid, so delete the temporary file and set the error flag @unlink($_FILES['new_picture']['tmp_name']); $error = true; echo '<p class="error">Your picture must be a GIF, JPEG, or PNG image file no greater than ' . (CT_MAXFILESIZE / 1024). '</p>'; } } // Grab the profile data from the POST $name = mysqli_real_escape_string($dbc, trim($_POST['name'])); $nric = mysqli_real_escape_string($dbc, trim($_POST['nric'])); $gender = mysqli_real_escape_string($dbc, trim($_POST['gender'])); $old_picture = mysqli_real_escape_string($dbc, trim($_POST['old_picture'])); $new_picture = mysqli_real_escape_string($dbc, trim($_FILES['new_picture']['name'])); $new_picture_type = $_FILES['new_picture']['type']; $new_picture_size = $_FILES['new_picture']['size']; list($new_picture_width, $new_picture_height) = getimagesize($_FILES['new_picture']['tmp_name']); $error = false; // Update the profile data in the database if (!$error) { if (!empty($name) && !empty($nric) && !empty($gender)) { $query = "UPDATE tutor_profile SET name = '$name', nric = '$nric', gender = '$gender' WHERE tutor_id = '" . $_GET['tutor_id'] . "'"; mysqli_query($dbc, $query) or die(mysqli_error($dbc)); // Confirm success with the user echo '<p>Your profile has been successfully updated. Would you like to <a href="viewprofile.php?tutor_id=' . $_GET['tutor_id'] . '">view your profile</a>?</p>'; mysqli_close($dbc); exit(); } else { echo '<p class="error">You must enter all of the profile data (the picture is optional).</p>'; } } } // End of check for form submission else { // Grab the profile data from the database $query = "SELECT name, nric, gender FROM tutor_profile WHERE tutor_id = '" . $_GET['tutor_id'] . "'"; $data = mysqli_query($dbc, $query) or die(mysqli_error($dbc)); // The user row was found so display the user data if (mysqli_num_rows($data) == 1) { $row = mysqli_fetch_array($data); if ($row != NULL) { $name = $row['name']; $nric = $row['nric']; $gender = $row['gender']; } else { echo '<p class="error">There was a problem accessing your profile.</p>'; } } } mysqli_close($dbc); ?> <form enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo CT_MAXFILESIZE; ?>" /> <ul id="tabSet_ep"> <li><a href="#panel1">Personal Profile</a></li> <li><a href="#panel2">Qualifications</a></li> <li><a href="#panel3">Tutor\'s Comments/Commitment</a></li> <li><a href="#panel4">Tutoring Levels/Subjects</a></li> </ul> <!--Personal Profile--> <div id="panel1"> <label for="new_picture">Pictu </label> <input type="file" id="new_picture" name="new_picture" /> <?php if (!empty($old_picture)) { echo '<img class="profile" src="' . CT_UPLOADPATH . $old_picture . '" alt="Profile Picture" />'; } ?><br /> <label for="firstname">First name:</label> <input type="text" id="firstname" name="firstname" value="<?php if (!empty($name)) echo $name; ?>" /><br /> <label for="lastname">Last name:</label> <input type="text" id="lastname" name="lastname" value="<?php if (!empty($nric)) echo $nric; ?>" /><br /> <label for="gender">Gender:</label> <select id="gender" name="gender"> <option value="M" <?php if (!empty($gender) && $gender == 'M') echo 'selected = "selected"'; ?>>Male</option> <option value="F" <?php if (!empty($gender) && $gender == 'F') echo 'selected = "selected"'; ?>>Female</option> </select><br /> </div> <input type="submit" value="Save Profile" name="submit" /> </form> Hi I am trying to develop an editprofile.php page to allow users to change their details. So far i have written Code: [Select] <?php $result = mysql_query("SELECT username FROM users WHERE username = {$_SESSION['MM_Username']}"); $num_rows = mysql_num_rows($result); if($num_rows > 0) { while ($row = mysql_fetch_array($result)) { $username = $row['username']; } } ?> and then tried to test it by using Code: [Select] <div><?php echo $username ?></div> but nothing is being echo'ed out. What am i doing wrong? I was looking at various tutorials on the net to help me create an edit profile page for my site but the ones I tried wouldn't work... What changes would I have to make to this: (register.php) <?php include ('header.php'); ?></center> <div class=content> <?php if(!empty($_POST['username']) && !empty($_POST['password'])) { $username = mysql_real_escape_string($_POST['username']); $password = md5(mysql_real_escape_string($_POST['password'])); $email = mysql_real_escape_string($_POST['email']); $location = mysql_real_escape_string($_POST['location']); $website = mysql_real_escape_string($_POST['website']); $about = mysql_real_escape_string($_POST['about']); $checkusername = mysql_query("SELECT * FROM users WHERE Username = '".$username."'"); if(mysql_num_rows($checkusername) == 1) { echo "<b>Error</b>"; echo "Sorry, that username is taken. Please go back and try again.</p>"; } else { $registerquery = mysql_query("INSERT INTO users (Username, Password, EmailAddress, Location, Website, About) VALUES('".$username."', '".$password."', '".$email."', '".$location."', '".$website."', '".$about."')"); if($registerquery) { echo "<b>Success!</b>"; echo "Your account was successfully created. Please click<a href=\"index.php\"> here </a>to login."; } else { echo "<b>Error</b>"; echo "<p>Sorry, your registration failed. Please go back and try again.</p>"; } } } else { ?> <b>Register</b> <br><br> Please enter your details below to register. <br><br> <form method="post" action="register.php" name="registerform" id="registerform"> <table width=700px border=0 cellspacing=10><tr><td valign=top><table border=0> <b>Required Information:</b><br><br> <tr><td> <b>Username:</b> </td><td> <input type="text" name="username" id="username" /> </td></tr><tr><td> <b>Password:</b> </td><td> <input type="password" name="password" id="password" /> </td></tr><tr><td> <b>Email Address:</b> </td><td> <input type="text" name="email" id="email" /> </td></tr></table></td><td valign=top> <table border=0> <b>Optional Information:</b><br><br> <tr><td> <b>Location:</b> </td><td> <input type="text" name="location" id="location"> </td></tr><tr><td> <b>Your Website:</b> </td><td> <input type="text" name="website" id="website"> </tr></td><tr><td valign=top> <b>Short About:</b> </td><td> <textarea name="about" id="about" rows="10" cols="20"></textarea> </td></tr></td> </table> </td></tr> </table> <input type="submit" name="register" id="register" value="Register" class=btn /> </form> <?php } ?> </div> <?php include ('footer.php'); ?> an edit profile page? I use this as the template because its damn near the same script, just with a few alterations... I know the obvious things the bit I struggle with is selecting the database then inserting new information?...I keep getting my variables/queries messed up when I rewrite it to create a edit profile page. Cheers, Hi everyone, i have currently have a registration and login page working, i have now included a profile/edit profile page once the user is logged in. However im having a problem, once the user logs in the account page welcomes them by there username using the following code <h2>Welcome, <?php echo $_SESSION['username']; ?></h2> Which is fine, however when users edit there profile there details arent stored into there userid within the mysql database. for example this is my edit profile page and this is what it does within the mysql database: It doesn't save that info to the current user and im not sure how to get it to do it, heres my code: <?PHP //Database Information $dbhost = "localhost"; $dbname = "blank"; $dbuser = "blank"; $dbpass = "password"; //Connect to database mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); $real_name = $_POST['real_name']; $location = $_POST['location']; $mobile_number = $_POST['mobile_number']; $instant_messaging = $_POST['instant_messaging']; $query = "REPLACE INTO users (real_name, location, mobile_number, instant_messaging) VALUES('$real_name', '$location', '$mobile_number', '$instant_messaging')"; mysql_query($query) or die(mysql_error()); mysql_close(); ?> I can see why it doesn't work as it just inserts it into the users database but I'm not sure how to associate it with the current logged in user. Any help would be great, Lee I need help with this script...... i get the error... 'Undefined index: username in C:\wampnew\www\login and register\profile.php on line 28!' <?php require("include/connect.php"); if(!isset($_GET['id'])) { echo("Please enter a members profile to view."); die(); } elseif($_GET['id'] == "") { echo("Please enter a members profile to view."); die(); } $pid = mysql_real_escape_string(preg_replace("@[^a-z0-9]@i","",$_GET['id'])); $check = mysql_num_rows(mysql_query("SELECT id FROM tut_users WHERE id='{$pid}'")); if($check !="1") { echo("Member does not exist."); require("footer.php"); die(); } $sql = mysql_query("SELECT * FROM tut_users WHERE id='{$pid}'") or die(mysql_error()); $fetch = mysql_fetch_assoc($sql) or die(mysql_error()); $username = mysql_real_escape_string(preg_replace("@[^a-z0-9]@i","",$fetch['username'])); echo("Member Profile Of: {$username} <br /> " ); ?> Could someone please help me thanks... Here's a function I use for displaying a member's profile using $_GET Code: [Select] <?php function view_profile ($username) { include_once "connect.php"; $query = "SELECT * FROM fans WHERE username = '$username'"; $result = mysql_query($query); $row = mysql_fetch_array($result); $count = mysql_num_rows($result); while ($row = mysql_fetch_array($result)) { $username = $row["username"]; $name = $row["name"]; $email = $row["email"]; $region = $row["region"]; $country = $row["country"]; $gender = $row["gender"]; $status = $row["status"]; $subscription = $row["subscription"]; $time_registered = $row["time_registered"]; $date_registered = $row["date_registered"]; $birthdate = $row["birthdate"]; $age = $row["age"]; $last_time = $row["last_time"]; $last_date = $row["last_date"]; $default_photo = $row["default_photo"]; $about_me = $row["about_me"]; echo $name; echo $email; echo $status; echo $username; } } ?> The only problem is, its not echoing the member's information when the function gets called. I used a variable called "$count" and echoed that to see if it was getting any results, and it is, it's just the while loop isn't working and i don't know why as I used an identical function like this for another script. Any suggestions? Hi all, Please I need an urgent help, I'm working on a project : www.playnetwork.com/record I want it such that when you click on the the artist link (menu) it will pull out the artists' records such as Name, Albums, Height etc. from a database Please help me out I'm kind off rookie to php Thanks i dont know why it doesnt update the db..someone help?? $connection=mysql_connect("$server", "$username", "$password") or die("Could not establish connection"); mysql_select_db($database_name, $connection) or die ("Could not select database"); $strEditProfile = "UPDATE tblemployee SET EmployeeName='".$_POST["edit_thename"]."', Address1 = '".$_POST[edit_address1]."', Address2 = '".$_POST[edit_address2]."', DesignationID = '".$_POST[edit_des]."', Postcode = '".$_POST[edit_postcode]."', State = '".$_POST[edit_state]."', Country = '".$_POST[edit_country]."', Tel1 = '".$_POST[edit_contact]."' WHERE EEmail='".$_POST["edit_email"]."'"; $resEditProfile = mysql_query($strEditProfile); if($resEditProfile) echo "<img src=\"images/valid.jpg\" /> Profile updated!"; else echo "><img src=\"images/warning.jpg\">Error!"; Hello, first of all i'm new here and i kinda like the community... so here i go with my question... When i register and then click on the link to get me to the log in file i have set the link for my member profile to be member.php?p=$_SESSION['id'] .. which works until now.. and lets say for instance my ID is 25... when i type on the browser member.php?p=553524 i will still be on the same page... so what i want to do is to check which id is typed and then throw them to the correct account profile or if the ID does not exist then throw them to a member-not-exist.php file.. I think i can do the how to check the id if it does exist but for the other one? Thanks in advance. Hi guys, Im trying to get my members_profile.php to display the users profile.... I.e members_profile.php?boxerman will display my information. I've been at it for hours but no luck... This is what im trying to code: <?php include ("connect.php") $username = $_GET['username']; $user = mysql_query("SELECT * FROM user WHERE username = '$username'"); $user=mysql_fetch_assoc($user); echo "<h1>User Info</h1>"; echo "<b>Username:".$user['username']."<br>"; echo "<br>"; echo '<form name="backlistfrm" method="post" action="members.php">'; echo '<input type="submit" value="Back to The List">'; echo '</form>'; echo "<br>"; ?> It displays nothing when going to members_profile.php?boxerman Any advice as to why? Regards, B-Man Ok so everything is working the way it is supposed to work Except 2 small problems that have been driving me batty for the last 2 weeks.. for some strange reason the MSN and Email won't display correctly.. When they display it ends up like this (( JerseyJoe(at)hotmail(dot)com instead of JerseyJoe@hotmail.com )) I really need some help with this folks.. so Please answer asap..thanks <?php // $Id$ $cs_lang = cs_translate('users'); $users_id = $_GET['id']; settype($users_id,'integer'); $cs_user = cs_sql_select(__FILE__,'users','*',"users_id = '" . $users_id . "'"); if(empty($cs_user['users_active'])) { $data['head']['action'] = $cs_lang['profile']; $data['head']['body_text'] = $cs_lang['not_active_text']; echo cs_subtemplate(__FILE__,$data,'users','head'); $data['lang']['not_active'] = $cs_lang['not_active']; echo cs_subtemplate(__FILE__,$data,'users','not_active'); } elseif(!empty($cs_user['users_delete'])) { $data['head']['action'] = $cs_lang['profile']; $data['head']['body_text'] = $cs_lang['delete_text']; echo cs_subtemplate(__FILE__,$data,'users','head'); $data['lang']['delete'] = $cs_lang['delete']; echo cs_subtemplate(__FILE__,$data,'users','delete'); } else { $data['head']['action'] = $cs_lang['profile']; $data['head']['body_text'] = cs_addons('users','view',$users_id,'users'); echo cs_subtemplate(__FILE__,$data,'users','head'); $old_nick = cs_sql_select(__FILE__,'usernicks','users_nick','users_id = ' . $users_id,'users_changetime DESC',0,1); $data['if']['old_nick'] = false; if(!empty($old_nick)) { $data['if']['old_nick'] = true; $data['users']['old_nick'] = $old_nick['users_nick']; } $data['users']['id'] = $cs_user['users_id']; $data['if']['buddies_active'] = (empty($account['access_buddys']) OR $account['access_buddys'] < 2) ? false : true; $hidden = explode(',',$cs_user['users_hidden']); #$allow = $users_id == $account['users_id'] OR $account['access_users'] > 4 ? 1 : 0; $allow = 0; if($users_id == $account['users_id'] OR $account['access_users'] > 4) { $allow = 1; } $data['if']['own_profile'] = $users_id == $account['users_id'] ? true : false; $data['url']['picture'] = cs_url('users','picture'); $data['url']['profile'] = cs_url('users','profile'); $data['users']['nick'] = cs_secure($cs_user['users_nick']); $data['url']['message_create'] = cs_url('messages','create','to_id=' . $cs_user['users_id']); if(empty($cs_user['users_picture'])) { $data['users']['picture'] = $cs_lang['nopic']; } else { $place = 'uploads/users/' . $cs_user['users_picture']; $size = getimagesize($cs_main['def_path'] . '/' . $place); $data['users']['picture'] = cs_html_img($place,$size[1],$size[0]); } $content = cs_secure($cs_user['users_name']); if(in_array('users_name',$hidden)) { $content = empty($allow) ? '--' : cs_html_italic(1) . $content . cs_html_italic(0); } $data['users']['name'] = empty($cs_user['users_name']) ? '--' : $content; $content = cs_secure($cs_user['users_surname']); if(in_array('users_surname',$hidden)) { $content = empty($allow) ? '--' : cs_html_italic(1) . $content . cs_html_italic(0); } $data['users']['surname'] = empty($cs_user['users_surname']) ? '--' : $content; $data['lang']['sex'] = $cs_lang['sex']; if(empty($cs_user['users_sex'])) { $data['users']['sex'] = '--'; } if($cs_user['users_sex'] == 'male') { $data['users']['sex'] = $cs_lang['male']; } if($cs_user['users_sex'] == 'female') { $data['users']['sex'] = $cs_lang['female']; } $data['lang']['birth_age'] = $cs_lang['birth_age']; if (!empty($cs_user['users_age'])) { $content = cs_date('date',$cs_user['users_age']); $birth = explode ('-', $cs_user['users_age']); $age = cs_datereal('Y') - $birth[0]; if(cs_datereal('m')<=$birth[1]) { $age--; } if(cs_datereal('d')>=$birth[2] AND cs_datereal('m')==$birth[1]) { $age++; } $content .= ' (' . $age . ')'; } if(in_array('users_age',$hidden)) { $content = empty($allow) ? '--' : cs_html_italic(1) . $content . cs_html_italic(0); } $data['users']['age'] = empty($cs_user['users_age']) ? '--' : $content; $content = empty($cs_user['users_height']) ? '--' : $cs_user['users_height'] . ''; if(in_array('users_height',$hidden)) { $content = empty($allow) ? '--' : cs_html_italic(1) . $content . cs_html_italic(0); } $data['users']['height'] = empty($cs_user['users_height']) ? '--' : $content; $content = cs_secure($cs_user['users_adress']); if(in_array('users_adress',$hidden)) { $content = empty($allow) ? '--' : cs_html_italic(1) . $content . cs_html_italic(0); } $data['users']['adress'] = empty($cs_user['users_adress']) ? '--' : $content; $data['lang']['postal_place'] = $cs_lang['postal_place']; if(empty($cs_user['users_postalcode']) AND empty($cs_user['users_place'])) { $data['users']['postal_place'] = '--'; } else { $content = cs_secure($cs_user['users_postalcode']) . ' - ' . cs_secure($cs_user['users_place']); if(in_array('users_place',$hidden)) { $content = empty($allow) ? '--' : cs_html_italic(1) . $content . cs_html_italic(0); } $data['users']['postal_place'] = $content; } if(empty($cs_user['users_country'])) { $data['users']['country'] = '-'; } else { $url = 'symbols/countries/' . $cs_user['users_country'] . '.png'; $data['users']['country'] = cs_html_img($url,11,16); include_once('lang/' . $account['users_lang'] . '/countries.php'); $country = $cs_user['users_country']; $data['users']['country'] .= ' ' . $cs_country[$country]; } $data['users']['registered'] = cs_date('unix',$cs_user['users_register'],1); $data['users']['laston'] = !empty($cs_users['users_invisible']) ? '--' : cs_date('unix',$cs_user['users_laston'],1); $content = cs_html_mail($cs_user['users_email']); if(in_array('users_email',$hidden)) { $content = empty($allow) ? '--' : cs_html_italic(1) . $content . cs_html_italic(0); } $data['users']['email'] = empty($cs_user['users_email']) ? '--' : $content; $cs_user['users_url'] = cs_secure($cs_user['users_url']); $content = cs_html_link('http://' . $cs_user['users_url'],$cs_user['users_url']); if(in_array('users_url',$hidden)) { $content = empty($allow) ? '--' : cs_html_italic(1) . $content . cs_html_italic(0); } $data['users']['url'] = empty($cs_user['users_url']) ? '--' : $content; $cs_icqstart = 'http://web.icq.com/whitepages/online?icq='; $content = cs_html_link('http://www.icq.com/' . $cs_user['users_icq'],$cs_user['users_icq']); $content .= ' ' . cs_html_img($cs_icqstart . $cs_user['users_icq'] . '&img=22','16','15'); if(in_array('users_icq',$hidden)) { $content = empty($allow) ? '--' : cs_html_italic(1) . $content . cs_html_italic(0); } $data['users']['icq'] = empty($cs_user['users_icq']) ? '--' : $content; $cs_user['users_msn'] = cs_secure($cs_user['users_msn']); # $content = cs_html_link('http://members.msn.com/' . $cs_user['users_msn'],$cs_user['users_msn']); $content = cs_html_msnmail($cs_user['users_msn']); if(in_array('users_msn',$hidden)) { $content = empty($allow) ? '--' : cs_html_italic(1) . $content . cs_html_italic(0); } $data['users']['msn'] = empty($cs_user['users_msn']) ? '--' : $content; $cs_user['users_skype'] = cs_secure($cs_user['users_skype']); $content = cs_html_link('skype:' . $cs_user['users_skype'] . '?userinfo', $cs_user['users_skype']); $skype_url = 'http://mystatus.skype.com/smallicon/' . $cs_user['users_skype']; $content .= ' ' . cs_html_img($skype_url,'16','16'); if(in_array('users_skype',$hidden)) { $content = empty($allow) ? '--' : cs_html_italic(1) . $content . cs_html_italic(0); } $data['users']['skype'] = empty($cs_user['users_skype']) ? '--' : $content; $content = cs_secure($cs_user['users_phone']); if(in_array('users_phone',$hidden)) { $content = empty($allow) ? '--' : cs_html_italic(1) . $content . cs_html_italic(0); } $data['users']['phone'] = empty($cs_user['users_phone']) ? '--' : $content; $content = cs_secure($cs_user['users_mobile']); if(in_array('users_mobile',$hidden)) { $content = empty($allow) ? '--' : cs_html_italic(1) . $content . cs_html_italic(0); } $data['users']['mobile'] = empty($cs_user['users_mobile']) ? '--' : $content; $data['users']['info'] = empty($cs_user['users_info']) ? ' ' : cs_secure($cs_user['users_info'],1,1); /* Users View Update */ /* $users_view['users_view'] = $cs_user['users_view'] + 1; $users_cells = array_keys($users_view); $users_save = array_values($users_view); cs_sql_update(__FILE__,'users',$users_cells,$users_save,$cs_user['users_id']); $data['users']['view'] = $users_view['users_view'];*/ echo cs_subtemplate(__FILE__,$data,'users','view'); } Basically I'm a member of an "online dating site". The website tracks who views your profile and displays recent viewers prominently on the home page. One of the ways to get more people to pay attention to your profile (for dates *wink*) is to view peoples profiles and hope they view yours in return and initiate a conversation. Now to my question. I've been able to log into the site successfully with cURL and grab the page contents and implode on unique nodes with php. How can I crawl through users profiles with this. Like I'm a tad stumped on how link crawling works. Any guides that have helped you out in the past would be appreciated. I've used google tons on this subject, and have come up empty. I don't think my keywords are appropriate for genre of question query haha. Thanks ahead of time. Hello, I'm a new member and i want to say a compliment to the php coders. Well, in the profile page i want to insert to box. The first can be modified by the user and by the staff And the second can be inserted comments only by the staff.. We don't have a profile page to modify the date but, is possible insert only that? How can i do that? Naturally the staff comments can be modifed by the staff area. Thanks Hello all, i require some assistance in a bit of PHP/MySql code. I have a website setup with register/login scripts already wrote, i also have a basic members page for now, that has there user ID assigned to it for example members.php?id=$id, which is there ID from the database. I have a members list which shows all members with links to there profiles, now i when i mouse over the link, it will says members.php?id=1 and so on, which is correct but when clicking on any of the members to go to there profile it is my own details that is shown on there profile instead of theres. members.php <?php session_start(); mysql_connect("localhost","root") or die(mysql_error()); mysql_select_db("hireacoder") or die(mysql_error()); $user = $SESSION['username']; $sql = mysql_query("SELECT * FROM users WHERE username='$user'"); $row = mysql_fetch_assoc($sql); echo $row['username']; echo'<br>'; echo $row['fname']; echo'<br>'; echo $row['lname']; echo'<a href="users.php">Users</a>'; ?> users.php <?php session_start(); mysql_connect("localhost","root") or die(mysql_error()); mysql_select_db("hireacoder") or die(mysql_error()); echo "<table border='0'> <tr> <th>UserName</th> </tr>"; $sql = mysql_query("SELECT * FROM users ORDER BY ID"); while($row = mysql_fetch_assoc($sql)) { $id = $row['id']; $username = $row['username']; echo" <tr> <td> <a href='members.php?id=$id'>".$username."</a> </td> </tr>"; } echo "</table>"; ?> Now i know what the problem is, the query is getting the details from the DB with the username = the session user which is me and that is why my details show up on all profiles, but i dont know any other way to do it, any help with be very apprciated thanks you. Hi, I recently implemented a code to display user profile information. Well, it displays the username and password fine, but the edit function doesn't seem to be working. I edit the information, click submit, get a success message but the username and password didn't change. myprofile.php Code: [Select] <?php session_start(); include('config.php'); $sql = mysql_query( "SELECT * FROM users WHERE id='".$_SESSION['id']."'" ); echo "<h2>Profile</h2> <form method='post' action='editprofile.php'> <table>"; $row = mysql_fetch_array($sql); echo "<tr><th>Name: </th><td>".$row['username']."</td></tr> <tr><th>Password: </th><td><input type='password' value='".$row['password']."' disabled='true' /></td></tr>"; echo "</table><br /> <input type='submit' value='edit profile' /> </form>"; ?> editprofile.php Code: [Select] <?php include('config.php'); if(isset($_POST['btnedit'])){ $username = $_POST['username']; $password = $_POST['password']; $sql = mysql_query( "UPDATE users SET username='".$username."', password='".$password."' WHERE id='".$_SESSION['id']."'" ); if($sql){ echo "<script>alert('profile updated');window.location='myprofile.php'</script>"; }else{ echo "<script>alert('updating profile failed!');</script>"; } } $sql = mysql_query( "SELECT * FROM users WHERE id='".$_SESSION['id']."'" ); $row = mysql_fetch_array($sql); echo "<h2>Edit profile</h2> <form method='post'> <table> <tr><th>registered:</th><td><input type='text' name='username' value='".$row['username']."'/></td></tr> <tr><th>password:</th><td><input type='password' name='password' value='".$row['password']."'/></td></tr> </table><br /> <input type='submit' name='btnedit' value='update' /> </form>"; ?> i have a php application with user registration. i have to show each user , and user related pages as a sub-folder i.e for a user 'cooluser', if he logs-in, it should show www.mysite.com/cooluser/index.php my problem is, i cannot create a directory for each user, because, in each user there are 30 pages, showing the user profile information I tried friendly urls, but, it needs to have sub -folder. the partial content comes from mysql database. is there any solution/ advise? Hi all, I am still trying to figure what went wrong. It doesn't work over here. The error shown was the {else} command else { echo '<p class="error">There was a problem accessing your profile.</p>'; } I have attached my 4 sql tables for reference. Appreciate any advices.... Code: [Select] <?php $query3 = "SELECT ols.subject_level_id, sl.level_id, sl.subject_id, tl.level_name AS level_name, ts.subject_name AS subject_name " . "FROM tutor_overall_level_subject AS ols " . "INNER JOIN tutor_subject_level AS sl USING (subject_level_id) " . "INNER JOIN tutor_level AS tl USING (level_id) " . "INNER JOIN tutor_subject AS ts USING (subject_id) " . "WHERE ols.tutor_id = '" . $_GET['tutor_id'] . "'"; $data3 = mysqli_query($dbc, $query3) or die(mysqli_error($dbc)); if (mysqli_num_rows($data3) == 1) { echo '<div id="panel4">'; echo'<table><tr>'; // Start your table outside the loop... and your first row $count = 0; // Start your counter while($row3 = mysqli_fetch_array($data3)) { /* Check to see whether or not this is a *new* row If it is, then end the previous and start the next and restart the counter. */ if ($count % 5 == 0) { echo "</tr><tr>"; $count = 0; } echo '<td class="label">' . $row3['level_name'] . '</td><td>' . $row3['subject_name'] . '</td>'; $count++; //Increment the count } echo '</tr></table><br/>'; //Close your last row and your table, outside the loop echo '</div>'; //End of panel 4 } //End of if (mysqli_num_rows($data3) == 1) else { echo '<p class="error">There was a problem accessing your profile.</p>'; } ?> Hello. Say i want to view another user profile. I click on user name and i see the profile page. So how can i link user name to his profile? I have tried linking it to $id (this is where user id is stored in the database), but no luck. Thank you. ok, so I have found this code to edit profiles online, only problem is that the data is not being posted to the database, there are no errors, just basically refreshes the page. could you take a look and see if you can help me? Code: [Select] <?php } //action: edit user ----------------------------------------------------------------------------- if (isset($_GET['edit']) && isset($_GET['id'])) { $userid = (int) $_GET['id']; if ($userid == 0) { die("Invalid ID provided."); } //execution when completed the edit user form and pressed submit button --------------------- if (isset($_POST['editUser'])) { //validate data ------------------------------------------------------------------------ //check empty fields //passwords won't be checked, as they are not required foreach ($_POST as $k=>$v) { if ($v == "" && !in_array($k,$notRequired)) { $error[$k] = "<strong>This field is empty</strong>"; } } //escape string $name = mysql_real_escape_string($_POST['name']); $phone = mysql_real_escape_string($_POST['phone']); $address = mysql_real_escape_string($_POST['address']); $city = mysql_real_escape_string($_POST['city']); $state = mysql_real_escape_string($_POST['state']); $zip = mysql_real_escape_string($_POST['zip']); $cell = mysql_real_escape_string($_POST['cell']); $email = mysql_real_escape_string($_POST['email']); $username = mysql_real_escape_string($_POST['username']); $badges = mysql_real_escape_string($_POST['badges']); $rank = mysql_real_escape_string($_POST['rank']); $accounttype = mysql_real_escape_string($_POST['accounttype']); //check email validation, the function is available at config.php if (!check_email($_POST['email'])) { $error['email'] .= " <strong>Email is not valid!</strong>"; } //check email exists in database $res = mysql_query("SELECT email FROM members WHERE email='".$email."' AND userid != '".$userid."'"); if (mysql_num_rows($res) == 1) { $error['email'] .= " <strong>Email already existst in database!</strong>"; } //check username exists in database $res = mysql_query("SELECT username FROM members WHERE username='".$username."' AND username != '".$username."'"); if (mysql_num_rows($res) == 1) { $error['username'] .= " <strong>Username already existst in database!</strong>"; } //check both passwords are the same when password fields are not empty //end validate data --------------------------------------------------------------------- //save to database when no errors are detected ------------------------------------------ if (count($error) == 0) { $query = "UPDATE members SET username='".$username."', email='".$email."',name='".$name."', phone='".$phone."',address='".$address."', city='".$city."',state='".$state."', zip='".$zip."',cell='".$cell."', accounttype='".$accounttype."',badges='".$badges."', rank='".$rank."' "; $query .= "username='".$username."', email='".$email."',name='".$name."', phone='".$phone."',address='".$address."', city='".$city."',state='".$state."', zip='".$zip."',cell='".$cell."', accounttype='".$accounttype."',badges='".$badges."', rank='".$rank."' WHERE userid='".$userid."'"; //update username session if you edit yourself if ($userid == $_SESSION['auth_admin_userid']) { $_SESSION['auth_admin_username'] = $username; } if (mysql_query($query)) { echo "<p><strong>User has been edited and saved to the database.</strong></p>"; } else { echo "<strong>User has NOT been edited and saved into the database. ".mysql_error()."</strong>"; } } } //get user from the database and put data into $_POST variables. $rs = mysql_query("SELECT name, username, phone, address, city, state, zip, cell, email, badges, rank, accounttype FROM members WHERE userid = ".$userid.""); if (mysql_num_rows($rs) == 0) { die("User does not exists!"); } $row = mysql_fetch_assoc($rs); $_POST['name'] = $row['name']; $_POST['username'] = $row['username']; $_POST['phone'] = $row['phone']; $_POST['address'] = $row['address']; $_POST['city'] = $row['city']; $_POST['state'] = $row['state']; $_POST['zip'] = $row['zip']; $_POST['cell'] = $row['cell']; $_POST['email'] = $row['email']; $_POST['badges'] = $row['badges']; $_POST['rank'] = $row['rank']; $_POST['accounttype'] = $row['accounttype']; //if is admin, then $_POST['admin'] exists ?> <div id="TabbedPanels1" class="TabbedPanels"> <ul class="TabbedPanelsTabGroup"> <li class="TabbedPanelsTab" tabindex="0">My Info</li> <li class="TabbedPanelsTab" tabindex="0">Merit Badges</li> <li class="TabbedPanelsTab" tabindex="0">Scout Rank</li> </ul> <div class="TabbedPanelsContentGroup"> <div class="TabbedPanelsContent"> <form action="admin.php?edit&id=<?php echo $userid;?>" method="post"> <table align="center" cellpadding="8" cellspacing="8"> <tr> <td><div align="right">Name:</div></td> <td> <p><input type="text" name="name" value='<?php echo $_POST['name'];?>' /> <?php echo(isset($error['name']))?$error['name']:"";?></p></td> </tr> <tr> <td>Phone Number:</td> <td><input type="text" name="phone" value='<?php echo $_POST['phone'];?>' /> <?php echo(isset($error['phone']))?$error['phone']:"";?></td> </tr> <tr> <td><div align="right">Address:</div></td> <td><input type="text" name="address" value='<?php echo $_POST['address'];?>' /> <?php echo(isset($error['address']))?$error['address']:"";?></td> </tr> <tr> <td><div align="right">City:</div></td> <td><input type="text" name="city" value='<?php echo $_POST['city'];?>' /> <?php echo(isset($error['city']))?$error['city']:"";?></td> </tr> <tr> <td><div align="right">State:</div></td> <td><input type="text" name="state" value='<?php echo $_POST['state'];?>' /> <?php echo(isset($error['state']))?$error['state']:"";?></td> </tr> <tr> <td><div align="right">Zip Code:</div></td> <td><input type="text" name="zip" value='<?php echo $_POST['zip'];?>' /> <?php echo(isset($error['zip']))?$error['zip']:"";?></td> </tr> <tr> <td><div align="right">Email:</div></td> <td> <p> <input type="text" name="email" value='<?php echo $_POST['email'];?>' /> <?php echo(isset($error['email']))?$error['email']:"";?></p></td> </tr> <tr> <td><div align="right">Cell Phone:</div></td> <td><input type="text" name="cell" value='<?php echo $_POST['cell'];?>' /> <?php echo(isset($error['cell']))?$error['cell']:"";?></td> </tr> <tr> <td class="aaaaaaa" align="right">Username:</td> <td><label for="username"></label> <input type="text" name="username" value='<?php echo $_POST['username'];?>' /> <?php echo(isset($error['username']))?$error['username']:"";?></p> </td> </tr> </table> <p> </p> <input name="submit" type="submit" value="Save" /> </form> </div> <div class="TabbedPanelsContent"> <label for="badges"></label> <input name="badges" type="text" id="badges" value="<?php echo "$badges"; ?>" /> </div> <div class="TabbedPanelsContent"> <input name="badges2" type="text" id="badges2" value="<?php echo $rank; ?>" /> </div> </div> </div> <script type="text/javascript"> var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1"); </script> <?php } ?> |