coldasice 0 Report post Posted December 21, 2007 (edited) <?phpsession_start(); include "database.php";include "edit.inc.php";if (!$_SESSION["valid_user"]){// User not logged in, redirect to login pageHeader("Location: main.php");}if(isset($_POST['submit'])){$email = $_POST['email'];$msn = $_POST['msn'];$info = $_POST['info'];$updateemail = "UPDATE users SET email = '$email', msn = '$msn', info = '$info'WHERE username = '$username'"; mysql_query($updateemail) or die("culd not edit your info"); echo "info updated";}// Display logout linkecho "<p><a href=\"member.php\">Click here to go back to info page!</a></p>";echo "$email";echo "$msn";echo "$info";$username = $_SESSION["username"];$query = mysql_query("SELECT * FROM users WHERE username='$username'");$all = mysql_fetch_array($query);$email = $all['email'];$msn = $all['msn'];$info = $all['info'];echo " <table width=\"100%\" border=0 cellpadding=1 cellspacing=0> <form name=login action='$PHP_SELF' method=post> <tr> <td width=80>Email: </td> <td width='160'><input tabindex=1 type=text name=username value='$email' style='width:150;'></td> </tr> <tr> <td>MSN: </td> <td><input type=text name=password value='$msn' style='width:150'></td> </tr> <tr> <td>Info: </td> <td><textarea rows=\"10\" cols=\"45\" name=\"'info'\" id=\"'info'\">$info</textarea></td> </tr> ";echo " </tr> <tr> <td> <td colspan=\"3\"> <table border=0 cellspacing=0 cellpadding=0 width=100%> <tr> <td width=50%> <input type=\"submit\" name=\"submit\" id=\"submit\" value=\"submit\" /> </form> </table>";? Edited December 21, 2007 by coldasice (see edit history) Share this post Link to post Share on other sites
sonesay 7 Report post Posted December 21, 2007 try moving $username above before your update query like this $username = $_SESSION["username"];$updateemail = "UPDATE users SET email = '$email', msn = '$msn', info = '$info'WHERE username = '$username'"; Share this post Link to post Share on other sites
coldasice 0 Report post Posted December 21, 2007 try moving $username above before your update query like this WHERE username = '$username'"; linenums:0'>$username = $_SESSION["username"];$updateemail = "UPDATE users SET email = '$email', msn = '$msn', info = '$info'WHERE username = '$username'"; this just delete the whole row in my user name so all go blank Share this post Link to post Share on other sites
sonesay 7 Report post Posted December 21, 2007 this just delete the whole row in my user name so all go blank post your other code too include "database.php";include "edit.inc.php";and also include your database table layout Share this post Link to post Share on other sites
coldasice 0 Report post Posted December 21, 2007 <?/** * Connect to the mysql database. */$conn = mysql_connect("localhost", "root", "cold") or die(mysql_error());mysql_select_db('new', $conn) or die(mysql_error());?> thats my database..inc is not a script i was just testing out to see what happened if i made the last part a function ;=)basilcy the sameit deletes all ;O Share this post Link to post Share on other sites
sonesay 7 Report post Posted December 21, 2007 try this $username = $_SESSION["username"];if(isset($_POST['submit'])){ $email = $_POST['email']; $msn = $_POST['msn']; $info = $_POST['info']; $updateemail = "UPDATE users SET email = '$email', msn = '$msn', info = '$info' WHERE username = '$username'"; mysql_query($updateemail) or die("culd not edit your info"); echo "info updated";}// Display logout linkecho "<p><a href=\"member.php\">Click here to go back to info page!</a></p>";echo "$email";echo "$msn";echo "$info"; $username = $_SESSION["username"]; before the if statement Share this post Link to post Share on other sites
coldasice 0 Report post Posted December 21, 2007 try this $email = $_POST['email']; $msn = $_POST['msn']; $info = $_POST['info']; $updateemail = "UPDATE users SET email = '$email', msn = '$msn', info = '$info' WHERE username = '$username'"; mysql_query($updateemail) or die("culd not edit your info"); echo "info updated";}// Display logout linkecho "<p><a href=\"member.php\">Click here to go back to info page!</a></p>";echo "$email";echo "$msn";echo "$info"; linenums:0'>$username = $_SESSION["username"];if(isset($_POST['submit'])){ $email = $_POST['email']; $msn = $_POST['msn']; $info = $_POST['info']; $updateemail = "UPDATE users SET email = '$email', msn = '$msn', info = '$info' WHERE username = '$username'"; mysql_query($updateemail) or die("culd not edit your info"); echo "info updated";}// Display logout linkecho "<p><a href=\"member.php\">Click here to go back to info page!</a></p>";echo "$email";echo "$msn";echo "$info";$username = $_SESSION["username"]; before the if statement still dont work it still deletes the whole username row ;/ Share this post Link to post Share on other sites
sonesay 7 Report post Posted December 22, 2007 (edited) what do you mean delete? I only see an update statement and a select statement for displaying. If you get empty fields maybe the mysql database table is empty.maybe try move the echo after the query is done $username = $_SESSION["username"];$query = mysql_query("SELECT * FROM users WHERE username='$username'");$all = mysql_fetch_array($query);$email = $all['email'];$msn = $all['msn'];$info = $all['info'];echo "$email";echo "$msn";echo "$info"; Edited December 22, 2007 by sonesay (see edit history) Share this post Link to post Share on other sites
coldasice 0 Report post Posted December 22, 2007 what do you mean delete? I only see an update statement and a select statement for displaying. If you get empty fields maybe the mysql database table is empty.maybe try move the echo after the query is done $all = mysql_fetch_array($query);$email = $all['email'];$msn = $all['msn'];$info = $all['info'];echo "$email";echo "$msn";echo "$info"; linenums:0'>$username = $_SESSION["username"];$query = mysql_query("SELECT * FROM users WHERE username='$username'");$all = mysql_fetch_array($query);$email = $all['email'];$msn = $all['msn'];$info = $all['info'];echo "$email";echo "$msn";echo "$info"; well as far as i register.. the update querry dont do *BLEEP*.......and i moved echo.. dosnt work ;O Share this post Link to post Share on other sites
sonesay 7 Report post Posted December 22, 2007 (edited) the query update looks ok to me. The only reasons it wont update is if there is no record to update, If there is error because of wrong field names etc the error should return.I would check and make sure $username is assigned when used in your query, and check your database it self. say if you want to update user 'bob' check if 'bob' exist in users and 'bob' is assigned properly to $username before doing query, maybe output it just to test on the screen. I cant think of any other reasons why it will not work if its not givng back any errors.Also try to remember to assign your variables before attempting to use it. It wont work if you try and use $username and you actually assign it futher down the code because it will be blank when you are calling it before. Edited December 22, 2007 by sonesay (see edit history) Share this post Link to post Share on other sites
coldasice 0 Report post Posted December 22, 2007 (edited) the query update looks ok to me. The only reasons it wont update is if there is no record to update, If there is error because of wrong field names etc the error should return.I would check and make sure $username is assigned when used in your query, and check your database it self. say if you want to update user 'bob' check if 'bob' exist in users and 'bob' is assigned properly to $username before doing query, maybe output it just to test on the screen. I cant think of any other reasons why it will not work if its not givng back any errors.Also try to remember to assign your variables before attempting to use it. It wont work if you try and use $username and you actually assign it futher down the code because it will be blank when you are calling it before. well i replaced $username with my username... coldasice... as in db.. and it still wouldnt work well all i can say is that update dosnt work <?phpsession_start(); include "database.php";include "edit.inc.php";if (!$_SESSION["valid_user"]){// User not logged in, redirect to login pageHeader("Location: main.php");}$username = $_SESSION["username"];if(isset($_POST['submit'])){$email2 = $_POST['email'];$msn2 = $_POST['msn'];$info2 = $_POST['info'];$updateemail = "UPDATE users SET email = '$email2', msn = '$msn2', info = '$info2' WHERE username = '$username'"; mysql_query($updateemail) or die("culd not edit your info"); echo "info updated";}echo "$username";echo "$email";$query = mysql_query("SELECT * FROM users WHERE username='$username'");$all = mysql_fetch_array($query);$email = $all['email'];$msn = $all['msn'];$info = $all['info'];echo " <table width=\"100%\" border=0 cellpadding=1 cellspacing=0> <form name=login action='$PHP_SELF' method=post> <tr> <td width=80>Email: </td> <td width='160'><input tabindex=1 type=text name=username value='$email' style='width:150;'></td> </tr> <tr> <td>MSN: </td> <td><input type=text name=password value='$msn' style='width:150'></td> </tr> <tr> <td>Info: </td> <td><textarea rows=\"10\" cols=\"45\" name=\"'info'\" id=\"'info'\">$info</textarea></td> </tr> ";echo " </tr> <tr> <td> <td colspan=\"3\"> <table border=0 cellspacing=0 cellpadding=0 width=100%> <tr> <td width=50%> <input type=\"submit\" name=\"submit\" id=\"submit\" value=\"submit\" /> </form> </table>";echo "<p><a href=\"member.php\">Click here to go back to info page!</a></p>";?> this is my current codeyes phpmyadmin.. is what i use evry time i press submit..well.. i go pms.. and insert email = asdasdasd info = asdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdsadasdasdaand then i go to edit.php.. and all is there.. then i press submit... boom.. all emty.. it emptyes.. my damn row where the user name is inserted...................now my guess is that its somthing wrong with update Edited December 22, 2007 by coldasice (see edit history) Share this post Link to post Share on other sites
jlhaslip 4 Report post Posted December 22, 2007 $username = $_SESSION["username"];have you tried single quotes here?Basic debugging would suggest that you display (print) the data in the query before and after the query, along with the results of the query after the select. This will confirm the values the query is using, and the results it is getting.And does the select work correctly in phpmyadmin? Share this post Link to post Share on other sites
sonesay 7 Report post Posted December 22, 2007 (edited) i need some bigger glasses <td width=80>Email: </td><td width='160'><input tabindex=1 type=text name=username value='$email' style='width:150;'></td></tr><tr><td>MSN: </td><td><input type=text name=password value='$msn' style='width:150'></td></tr><tr><td>Info: </td><td><textarea rows=\"10\" cols=\"45\" name=\"'info'\" id=\"'info'\">$info</textarea></td> change the name='' to the corret names <td width='160'><input tabindex=1 type=text name='email' value='$email' style='width:150;'></td></tr><tr><td>MSN: </td><td><input type=text name='msn' value='$msn' style='width:150'></td></tr><tr><td>Info: </td><td><textarea rows=\"10\" cols=\"45\" name='info' >$info</textarea></td> man this is what happens when you ignore the obvious Edited December 22, 2007 by sonesay (see edit history) Share this post Link to post Share on other sites
coldasice 0 Report post Posted December 22, 2007 (edited) $username = $_SESSION["username"];have you tried single quotes here? Basic debugging would suggest that you display (print) the data in the query before and after the query, along with the results of the query after the select. This will confirm the values the query is using, and the results it is getting. And does the select work correctly in phpmyadmin? thanks for ur respons.. but.. lol ;O that dont help =D and yeah.. its a part of a learning login.. so basicly my username is in the session thanks for trying and its solved here is code =D and thank to you sonesay. for helping me =D this happende bcouse i made the thig from scratch.. but..... i got some kind of error.. but i dont remember what error it was... so i found some boxes on net.. and copyed source and edited it to fit what i wanted.. and just so you know be4 u posted.. i solved this.. i got fed up.. and saw trough code. and saw it.. <?phpsession_start(); include "database.php";if (!$_SESSION["valid_user"]){// User not logged in, redirect to login pageHeader("Location: main.php");}$username = $_SESSION["username"];if(isset($_POST['submit'])){$email2 = $_POST['email'];$msn2 = $_POST['msn'];$info2 = $_POST['info'];$updateemail = "UPDATE users SET email='$email2', msn='$msn2', info='$info2' WHERE username='$username'"; mysql_query($updateemail) or die("culd not edit your info"); echo "info updated";}$query = mysql_query("SELECT * FROM users WHERE username='$username'");$all = mysql_fetch_array($query);$email = $all['email'];$msn = $all['msn'];$info = $all['info'];echo " <table width=\"100%\" border=0 cellpadding=1 cellspacing=0> <form name=login action='$PHP_SELF' method=post> <tr> <td width=80>Email: </td> <td width='160'><input tabindex=1 type=text name=email value='$email' style='width:150;'></td> </tr> <tr> <td>MSN: </td> <td><input type=text name=msn value='$msn' style='width:150'></td> </tr> <tr> <td>Info: </td> <td><textarea rows='10' cols='45' name='info' id='info'>$info</textarea></td> </tr> </tr> <tr> <td> <td colspan=\"3\"> <table border=0 cellspacing=0 cellpadding=0 width=100%> <tr> <td width=50%> <input type=\"submit\" name=\"submit\" id=\"submit\" value=\"submit\" /> </form> </table>";echo "<p><a href=\"member.php\">Click here to go back to info page!</a></p>";?> [sOLVED] Edited December 22, 2007 by coldasice (see edit history) Share this post Link to post Share on other sites