PHP - 'myspace' Style Profile Pages
Hi..
I would like to allow users to create profile pages on my website. So for example... If I wanted to create a profile page called "Zugzwangle"... it would be stored at "www.website.com/Zugzwangle"... in the same such way that MySpace stores profiles. How does this work? I'm at a loss for where to start with this one.. Any hints, or suggestions for where to start looking would be greatly appreciated!! Thanks Similar TutorialsI'm trying to set up a very simple (WIP) members page that you can click registered users to see their profile page that will display basic information. I'm having trouble with the sessions and retrieving this info from my database. I'm very new to this so it's all pretty amateur. I've been looking at this code for several hours trying to fix things but I start to make some progress, then change stuff, and go backwards. I had a members page that displayed the registered users in my database, but after a while of altering to try to get the profiles to work, I messed it up :mad:. I have basic login and register pages. I need some seperate eyes to take a look. Any help is so much appreciated. Thanks! members.php Code: [Select] <?php session_start(); require 'mysql-connect.php'; $auser=$_SESSION['user']; if(isset($auser)){ $Members = mysql_query("SELECT * FROM user WHERE username='$username'") or die(mysql_error()); $numRowsMembers = mysql_num_rows($Members); ?> <table border="1"> <?php for($count = 1; $count <= $numRowsMembers; $count++) { $name = mysql_fetch_array($Members); ?> <tr> <?php echo '<td><a href="member_profile.php?username=' . $name['username'] . '">' . $name['username'] . '</a></td>'; } } ?> </tr> </table> member_profile.php Code: [Select] <?php session_start(); require 'mysql-connect.php'; $auser=$_SESSION['user']; if(isset($auser)){ $username = $_GET['username']; $user = mysql_query("SELECT * FROM user WHERE username = '$username'"); echo $user; $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>"; } ?> my login handler Code: [Select] <?php include 'mysql-connect.php'; $username = $_POST['user']; $password = $_POST['pass']; $query1 = mysql_query("SELECT * FROM user WHERE username='$username'"); $result = mysql_num_rows($query1); if($result == 0) { echo '<h1>Error!</h1>The username you specified does not exist!'; } else { $checkuser = mysql_query("SELECT * FROM user WHERE username='$username'"); $row = mysql_fetch_array($checkuser); $password2 = $row['password']; //$status = $row['status']; if ($password == $password2) { echo "Hi $username."; include("index.php"); } else { echo '<h1>Error!</h1>The username and password combination you entered does not match the ones we have in the database.'; } } ?> mysql-connect.php Code: [Select] <?php $host = "localhost"; $username = "root"; $password = ""; $database = "ug54"; $link = mysql_connect($host, $username, $password);//Connects to database with host, username, and password $select = mysql_select_db($database); ?> and my simple database Code: [Select] CREATE TABLE IF NOT EXISTS `user` ( `id` int(4) unsigned NOT NULL AUTO_INCREMENT, `username` varchar(32) NOT NULL, `password` varchar(32) NOT NULL, `firstname` varchar(20) NOT NULL, `lastname` varchar(20) NOT NULL, `email` varchar(30) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ; -- -- Dumping data for table `user` -- INSERT INTO `user` (`id`, `username`, `password`, `firstname`, `lastname`, `email`) VALUES (1, '', '', '', '', '0'), (2, 'abc', '123', '', '', '0'), (3, 'a', 'b', 'c', 'd', '0'), (4, 'hfg', 'rgfdg', 'gdfg', 'dfgdf', '0'), (5, '999', '999', '999', '999', '999'); Hi 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> 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... 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 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!"; 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'); } 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>"; } 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? 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? 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 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 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>'; } ?> i get a message saying i cannot be authorised - i have keys, tokens, passwords, users etc but do not know how to implement them or update this script. any help for a super novice would be great! Code: [Select] <html><head><title>Title</title> <?php if (!isset($_POST['submit'])) { // if page is not submitted to itself //echo the form } else { $username = $_POST["username"]; $password = $_POST["password"]; $image = $_POST["image"]; ////// ////// ////// If you are using file uploads from your form, use the following block ////// NOTE: this particular example code uses file uploads from the input form ////// ////// $filename = $_FILES["image"]['name']; $tmpfilename = $_FILES["image"]['tmp_name']; $fileparts = explode(".", $filename); /* get file extension */ $ext = $fileparts[count($fileparts) - 1]; $newfilename = substr($tmpfilename, 0, strlen($tmpfilename) - strlen($ext)) . "." .$ext; //echo $newfilename; /* * this next line creates a "corrected" file ending in .gif/.png/.jpg so * the post headers are correct when CURL makes the request */ copy($tmpfilename, $newfilename); ////// ////// ////// Else If you are using canned files local to your server, use the following block ////// NOTE: you MUST use full path to image! ////// // // /* windows, notice FORWARD SLASHES */ // $newfilename = "c:/www/path/to/image.jpg"; // // // /* *nix */ // $newfilename = "/www/path/to/image.jpg"; // // The twitter API address $url = 'http://twitter.com/account/update_profile_image.xml'; $curl_handle = curl_init(); curl_setopt($curl_handle, CURLOPT_URL, "$url"); curl_setopt($curl_handle, CURLOPT_POST, 1); curl_setopt($curl_handle, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($curl_handle, CURLOPT_POSTFIELDS, array("image" => "@$newfilename")); curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password"); $buffer = curl_exec($curl_handle); curl_close($curl_handle); echo $buffer; // if you want to delete the local temp image from uploading, uncomment this next line: // unlink($newfilename); } ?> </head> <body> <form enctype="multipart/form-data" method="post" action="<?php echo $PHP_SELF;?>"> Username:<input type="text" size="12" maxlength="12" name="username"><br /> Password:<input type="password" size="12" maxlength="36" name="password"><br /> <input type="file" name="image"> <input type="submit" value="submit" name="submit"><br /> </form><br /> </body> </html> I'm trying to create a profile page that an unregistered user can view when he enters in the username into the url (e.g. http://localhost/username) Just recently got my mode_rewrite going (tried and tested), but I don't get the users information coming up in the page. Am I going about this the right way? This is what the page shows: The requested page was: Notice: Undefined variable: name_id in C:\x\xampp\htdocs\pages\profile.php on line 27 Notice: Undefined variable: name in C:\x\xampp\htdocs\pages\profile.php on line 28 Notice: Undefined variable: password in C:\x\xampp\htdocs\pages\profile.php on line 29 profile.php <?php include 'db.inc.php'; $db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or die ('Unable to connect. Check your connection parameters.'); mysql_select_db(MYSQL_DB, $db) or die(mysql_error($db)); $query = 'SELECT name_id, name, password FROM user WHERE name = "' . mysql_real_escape_string($_GET['name'], $db) . '"'; $result = mysql_query($query, $db) or die(mysql_error()); ?> <html> <head> <title> <?php echo $name; ?> </title> </head> <body> <p> The requested page was: <?php echo $name_id; echo $name; echo $password; ?> </p> </body> </html> I've been messing around with this for awhile so I'm going to hit the sack. 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. Hi, I have to ask about profile page for each user like facebook and netlog. As u can see in netlog it is like this http://en.netlog.com/ElegantLeo and i have a site http://cyprussaver.com/merchant.php?id=64 and here each merchant profile can be viewed like this but i need to show them like this http://cyprussaver.com/rocksman please guide me what i have to do in order to achieve this result. Thanks, Hanan ALi Hello, currently, I got myself a site where you have your own profile and your own 'profile image'. I allow people to upload their own image, and checking my folder, it indeed uploads it correctly. Now the issue starts when you try to delete your image, again - when deleted the image is deleted in the folder.. However, when then uploading a NEW image, it simply displays the old one (While the new one is actually in the folder!?) I figured that if you would close the website, and then load it again - it works correctly (figured this means the old image is still loaded in your temp files or something?) Now I was wondering if you could actually somehow *force* the user to re-download this image when you upload a new one. Thanks for your 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 |