dbo Posted January 2, 2007 Share Posted January 2, 2007 You seem to have pasted my code in on top of yours. Instead place my code in instead of what you originally pasted. That's why we are seeing the form twice. Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151237 Share on other sites More sharing options...
forumnz Posted January 2, 2007 Author Share Posted January 2, 2007 Now nothing shows up? Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151238 Share on other sites More sharing options...
dbo Posted January 2, 2007 Share Posted January 2, 2007 That's b/c of the error validation at the top that checks to make sure you're logged in. The sessionvariable username isn't set to anything, log in then direct to that page. Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151239 Share on other sites More sharing options...
forumnz Posted January 2, 2007 Author Share Posted January 2, 2007 Ok i got that..Lol now it says Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /usr/local/psa/home/vhosts/freshlook.co.nz/httpdocs/thing/area/edit.php on line 25 Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151240 Share on other sites More sharing options...
dbo Posted January 2, 2007 Share Posted January 2, 2007 Can you paste your newest code? Also do you have phpMyAdmin? Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151241 Share on other sites More sharing options...
forumnz Posted January 2, 2007 Author Share Posted January 2, 2007 Yes I do have phpMyAdmin.Code.[code]<?php session_start(); $con = mysql_connect("localhost","####","####");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("my_db", $con); $valid = false; if( isset($_SESSION['username']) ) { //do whatever appropriate validation is necessary on id //if we encounter errors abort? $id = $_SESSION['username']; //No errors... proceed //connect to database $query = "SELECT email FROM members WHERE userid = $id"; $result = mysql_query($query); $row = mysql_fetch_row($result); $email = ""; if( $row ) { $valid = true; $email = $row[0]; } else { //Invalid username... handle error appropriately $valid = false; } //disconnect from database } else { //ERROR - Not logged in.... //Redirect to login page? $valid = false; } if( !$valid ) { //Errors, redirect.... }?>[/code] Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151242 Share on other sites More sharing options...
dbo Posted January 2, 2007 Share Posted January 2, 2007 Right after $query = "....";put:echo $query;Then log into phpMyAdmin and paste the output of our query into phpMyAdmin and see what happens. Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151243 Share on other sites More sharing options...
forumnz Posted January 2, 2007 Author Share Posted January 2, 2007 Ok i did that, now it comes up with another error...SELECT username FROM members WHERE userid = testuser Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151246 Share on other sites More sharing options...
dbo Posted January 2, 2007 Share Posted January 2, 2007 That's not an error, that's output based on the echo command that I had you put in. That's the actual query being sent to the database.Put // in front of the echo command I just had you put in (comment it out).And then change this: $query = "SELECT email FROM usertable WHERE userid = $id";to this:$query = "SELECT email FROM usertable WHERE userid = '$id'"; Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151247 Share on other sites More sharing options...
forumnz Posted January 2, 2007 Author Share Posted January 2, 2007 Ok now its blank screen. Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151251 Share on other sites More sharing options...
dbo Posted January 2, 2007 Share Posted January 2, 2007 Login... Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151252 Share on other sites More sharing options...
dbo Posted January 2, 2007 Share Posted January 2, 2007 Can you give me the link to your login page and a test user/pass to play with so that I can tinker with? PM it? Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151253 Share on other sites More sharing options...
forumnz Posted January 2, 2007 Author Share Posted January 2, 2007 Sure... Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151254 Share on other sites More sharing options...
forumnz Posted January 2, 2007 Author Share Posted January 2, 2007 Sent.. Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151255 Share on other sites More sharing options...
dbo Posted January 2, 2007 Share Posted January 2, 2007 It doesn't appear to like that username/password. Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151256 Share on other sites More sharing options...
forumnz Posted January 2, 2007 Author Share Posted January 2, 2007 sorry try now. Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151258 Share on other sites More sharing options...
dbo Posted January 2, 2007 Share Posted January 2, 2007 Worked.Okay, uncomment the echo $query thing again.Should look like this:echo $query;And right after $result = mysql_query($query);put:if( mysql_errno() ){ echo "\n\nERROR: " . mysql_error();}Then please paste me the new code. Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151260 Share on other sites More sharing options...
forumnz Posted January 2, 2007 Author Share Posted January 2, 2007 Here you go:[code]<?php session_start(); $con = mysql_connect("localhost","####","####");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("my_db", $con); $valid = false; if( isset($_SESSION['username']) ) { //do whatever appropriate validation is necessary on id //if we encounter errors abort? $id = $_SESSION['username']; //No errors... proceed //connect to database $query = "SELECT username FROM members WHERE userid = '$id'";echo $query; $result = mysql_query($query); if( mysql_errno() ){ echo "\n\nERROR: " . mysql_error();} $row = mysql_fetch_row($result); $email = ""; if( $row ) { $valid = true; $email = $row[0]; } else { //Invalid username... handle error appropriately $valid = false; } //disconnect from database } else { //ERROR - Not logged in.... //Redirect to login page? $valid = false; } if( !$valid ) { //Errors, redirect.... }?>[/code] Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151261 Share on other sites More sharing options...
dbo Posted January 2, 2007 Share Posted January 2, 2007 ERROR: Unknown column 'userid' in 'where clause'It doesn't appear to know what userid is. Are you sure that is what you named it in your database? Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151264 Share on other sites More sharing options...
forumnz Posted January 2, 2007 Author Share Posted January 2, 2007 I named it 'id'. Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151265 Share on other sites More sharing options...
dbo Posted January 2, 2007 Share Posted January 2, 2007 ok so change userid to just id Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151266 Share on other sites More sharing options...
forumnz Posted January 2, 2007 Author Share Posted January 2, 2007 I just fixed that prob though... i changed"SELECT username FROM members WHERE userid = '$id'"to"SELECT username FROM members WHERE id = '$id'" Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151268 Share on other sites More sharing options...
dbo Posted January 2, 2007 Share Posted January 2, 2007 Do you have MSN or AOL IM clients? Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151269 Share on other sites More sharing options...
forumnz Posted January 2, 2007 Author Share Posted January 2, 2007 Yes MSN Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151270 Share on other sites More sharing options...
dbo Posted January 2, 2007 Share Posted January 2, 2007 PM me your username.Paste that in overwriting everything in your edit.php file and resave it.[code]<?php session_start(); $con = mysql_connect("localhost","####","####");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("my_db", $con); $valid = false; if( isset($_SESSION['username']) ) { //do whatever appropriate validation is necessary on id //if we encounter errors abort? $id = $_SESSION['username']; //No errors... proceed //connect to database $query = "SELECT username FROM members WHERE id = '$id'";//echo $query; $result = mysql_query($query); if( mysql_errno() ){ echo "\n\nERROR: " . mysql_error();} $row = mysql_fetch_row($result); $email = ""; if( $row ) { $valid = true; $email = $row[0]; } else { //Invalid username... handle error appropriately $valid = false; } //disconnect from database } else { //ERROR - Not logged in.... //Redirect to login page? $valid = false; } if( !$valid ) { //Errors, redirect.... }?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title></head><body><p>Edit Profile</p><form id="form1" name="form1" method="post" action="edit.php"><p>Password : <input name="password" type="text" id="password" /> <br /> Confirm Password : <input name="password" type="text" id="password" /></p><p>Email Address : <?php echo "<input name=\"email\" type=\"text\" id=\"email\" value=\"$email\" />\n"; ?></p><p> <label> <input type="submit" name="Submit" value="Go!" /> </label></p></form><p> </p></body></html>[/code] Link to comment https://forums.phpfreaks.com/topic/32517-i-want-to-make-a-single-page-that-users/page/2/#findComment-151271 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.