PHP - Viewing Profile Information Through The Url.
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. 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> Trying to figure out a way to do pdf files other than flash based since apple has screwed that up with the iPad. so what i've thought about so far is embed the pdf but very small and then maybe clickable full size pdf viewer?? I don't really know how I would get that to work with php??? Anyone have any good solutions for this? Thanks Paul 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!"; 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 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 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? 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 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? 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>"; } this is my query code Code: [Select] <?php $wsi_query = "(SELECT * FROM (SELECT a.no_Yards AS 'yards', a.Day_Swam AS 'date', a.Season AS 'season', (SELECT sum(no_yards) FROM swimming WHERE Season = '$ws') AS 'totalyards', (SELECT AVG(no_Yards) FROM swimming WHERE Season = '$ws') AS 'avg', (SELECT count(*) FROM swimming WHERE Season ='$ws') AS 'timelaps', (SELECT 1 + count(*) FROM swimming b WHERE b.no_Yards > a.no_Yards AND Season = '$ws') AS hrank, (SELECT 1 + count(*) FROM swimming b WHERE b.no_Yards < a.no_Yards AND Season = '$ws') AS lrank FROM swimming AS a) AS x WHERE Season = '$ws' )"; $wsi_result = mysql_query($wsi_query) or die("Query failed ($wsi_query) - " . mysql_error()); $wsi_row = mysql_fetch_assoc($wsi_result); ?> what it should do is output both the min and the max values like this Code: [Select] <?php while ($mm_wsi_row = mysql_fetch_assoc($wsi_result)){ if ($mm_wsi_row['hrank'] == 1){ if ($mm_wsi_row['date'] == "0000-00-00"){$dayswam = "";}else{$dayswam = $mm_wsi_row['date'];} echo "<tr>"; echo "<td style='background-color:#F90'>Max Length:</td>"; echo "<td>" . number_format($mm_wsi_row['yards']) . "</td>"; echo "<td>" . $dayswam . "</td>"; echo "</tr>"; } if($mm_wsi_row['lrank'] == 1){ if ($mm_wsi_row['date'] == "0000-00-00"){$dayswam = "";}else{$dayswam = $mm_wsi_row['date'];} echo"<tr>"; echo "<td style='background-color:#F90'>Min Length:</td>"; echo "<td style='background-color:#FF9'>". number_format($mm_wsi_row['yards']) . "</td>"; echo "<td style='background-color:#FF9'>" . $dayswam . "</td>"; echo "</tr>"; } ?> the problem is that it doesn't work right all the time for some it just shows the min while others it just shows max I've tested the query in MySQL workbench so i know that that is working right but idk why it works right for some and doesn't work for others Hi all, This is probably a very basic question, but it's the first time I've had to deal with it and I can't find a direct answer anywhere online. I have blocked direct access to a file that a user has uploaded in the Apache configuration and in the .htaccess file, so that the file is only accessible through a viewing (PHP) script, which will determine whether the access is allowed or not depending on several factors. What is the actual code I need to give access? Thanks! I know that I can fairly easily pull my data from the database and view it in a browser. I can also 'polish' it with some HTML or put it into a table. Can I get an item from a given VARIABLE to appear inside of an INPUT box, so that it looks the same as when it was initially submitted? Can it be done with a multiple choice SELECT dropdown, so that the item chosen is viewable again? Hello First of all thanks for your help in advance. I build a members website and can use HTML but seem to be going round in circles with php. So Ive made a page that allows users to input there details and register this DOES Work and adds the data to a mysql data base. However I would like when they click register it sends them a email to confirm there info and at the same time send myself one so I can check there details. this is the link http://www.asian-travel-club.co.uk/php/files/register.htm Once this is done I would like to be able to see on a admin page that has a username and password to allow me to active and deactive there members. I know this would need a button added this is where I get lost. the link to the admin page ive made is http://www.asian-travel-club.co.uk/php/files/admin/ Then once i actived them they will recive an auto activtion email . I dont seem to be able to see data from the Database on mysql but i can interact with it. As one you register if you try to log in it say that the username and passwodr is incorrect. I TAKE IT IS BECAUSE THE USER DOES NOT HAVE PERMISSION> how do i do this? Any way if you go to forot password page it allows you to enter data and on submittion it chz the database and then sends you an email with your username and password attached. This is the link to the password recover page. http://www.asian-travel-club.co.uk/php/files/password_recover.php this is what is in my config.php <?php define('DB_SERVER', ''); // database server/host define('DB_USER', ''); // database username define('DB_PASS', ''); // database password define('DB_NAME', ''); // database name ?> Please help if you can what is a code to decrypt md5 password for viewing by member? I having been searching through the forum and other websites for information on reading a file (an image file) located above my root directory. I would like to store images outside the root directory and then use PHP to call those images for registered users. Basically I want to create a secure web gallery. I am using GoDaddy Deluxe shared hosting, and have managed to create a webroot directory and place files above it. I have found several scripts for reading files using the readfile() function, however when I actually implement the script to find the file and read its contents, it does not seem to find the file. I know my directory path is correct, as I can call an echo function inside a test.php file located in the same folder as the images (above my root). I would love some incite as to where I went wrong, or if there is a specific GoDaddy work around that needs to be implemented. Also, if I am going about this the wrong way, please let me know if there is a more effective way of going about this! Thank you so much! |