techiefreak05 Posted August 16, 2006 Share Posted August 16, 2006 Hi I have an "account editor" on my site and it works.. here is the code for my "update email" form:[code]<?php if($_POST['updateI']){$username = $_SESSION['username'];$new_email = mysql_real_escape_string(trim($_POST['emailNew']));$sql = "UPDATE `users` SET `email` = '$new_email' WHERE `username` = '$username'"; $query = mysql_query($sql) or die(mysql_error()); } ?><?php$sql = "SELECT * FROM users WHERE username = '$_SESSION[username]' LIMIT 1";$query = mysql_query($sql);while($row = mysql_fetch_array($query)) {echo "<b>Current E-mail: '" .$row['email']. "'</b>";}?><form action="" method="post"> <table align="center" border="0" cellspacing="0" cellpadding="3"><tr><td ><font color=black>New E-mail:</font></td><td><input type="text" name="emailNew" maxlength="30"></td></tr><tr><td colspan="2" align="right"><input type="submit" name="updateI" value="-Update-"></td></tr></table> </form>[/code]now that works fine. and here is my update Name code:[code]<?php if($_POST['updateFNAME']){$username = $_SESSION['username'];$new_name = mysql_real_escape_string(trim($_POST['fnameNew']));$sql = "UPDATE `users` SET `fname` = '$new_name' WHERE `username` = '$username'"; $query = mysql_query($sql) or die(mysql_error()); } ?><?php$sql = "SELECT * FROM users WHERE username = '$_SESSION[username]' LIMIT 1";$query = mysql_query($sql);while($row = mysql_fetch_array($query)) {echo "<b>Current First Name: '" .$row['fname']. "'</b>";}?><form action="" method="post"> <table align="center" border="0" cellspacing="0" cellpadding="3"><tr><td ><font color=black>New First Name:</font></td><td><input type="text" name="fnameNew" maxlength="30"></td></tr><tr><td colspan="2" align="right"><input type="submit" name="updateFNAME" value="-Update-"></td></tr></table> </form>[/code]**NOW, heres my problem, I have a button that is supposed to change everything at once, cuz right now if you want to update any of those above, you need to press each single button for each item.. heres my code thats NOT WORK, that is suposed to combine bothe codes from above:[code]<?php if($_POST['updateALL']){$username = $_SESSION['username'];$new_name = mysql_real_escape_string(trim($_POST['fnameNew']));$new_email = mysql_real_escape_string(trim($_POST['emailNew']));$sql = "UPDATE `users` SET `fname` = '$new_name', `email` = '$new_email' WHERE `username` = '$username'"; $query = mysql_query($sql) or die(mysql_error()); } ?><form action="" method="post"> <table align="center" border="0" cellspacing="0" cellpadding="3"><tr><td colspan="2" align="right"><input type="submit" name="updateALL" value="-Save All-"></td></tr></table> </form></center>[/code]How can I change that to update all the fields at once?? Quote Link to comment Share on other sites More sharing options...
stickman Posted August 16, 2006 Share Posted August 16, 2006 This line:<input type="text" name="fnameNew" maxlength="30">And this line:<input type="text" name="emailNew" maxlength="30">Both have to be within the <form> tags for the update all form or the the values $_POST['fnameNew'] and $_POST['emailNew'] will both be empty. Quote Link to comment Share on other sites More sharing options...
techiefreak05 Posted August 16, 2006 Author Share Posted August 16, 2006 wont ading those lines add text boxes?? i dont want that, i just want tthe update all button to update all the inromation at once, i only want one text box for each piece of information Quote Link to comment Share on other sites More sharing options...
nethnet Posted August 16, 2006 Share Posted August 16, 2006 A submit button only sends data within that form. There is no data in your form and therefore nothing is being sent. Quote Link to comment Share on other sites More sharing options...
stickman Posted August 16, 2006 Share Posted August 16, 2006 [quote author=techiefreak05 link=topic=104456.msg416640#msg416640 date=1155708798]wont ading those lines add text boxes?? i dont want that, i just want tthe update all button to update all the inromation at once, i only want one text box for each piece of information[/quote]Yeah. You should just create one form with three different submit buttons with three different names. If you have three different forms, then you'll have to have six different text boxes (in your case). Quote Link to comment Share on other sites More sharing options...
techiefreak05 Posted August 16, 2006 Author Share Posted August 16, 2006 Hey I got it! . heres what i ended up with:[code]<center> <?php if($_POST['updateI']){$username = $_SESSION['username'];$new_email = mysql_real_escape_string(trim($_POST['emailNew']));$sql = "UPDATE `users` SET `email` = '$new_email' WHERE `username` = '$username'"; $query = mysql_query($sql) or die(mysql_error()); } ?><?php$sql = "SELECT * FROM users WHERE username = '$_SESSION[username]' LIMIT 1";$query = mysql_query($sql);while($row = mysql_fetch_array($query)) {echo "<b>Current E-mail: '" .$row['email']. "'</b>";}?><form action="" method="post"> <table align="center" border="0" cellspacing="0" cellpadding="3"><tr><td ><font color=black>New E-mail:</font></td><td><input type="text" name="emailNew" maxlength="30"></td></tr><tr><td colspan="2" align="right"><input type="submit" name="updateI" value="-Update-"></td></tr></table><! - END EMAIL - !><hr width=35%><! - UPDATE FNAME - !><?php if($_POST['updateFNAME']){$username = $_SESSION['username'];$new_name = mysql_real_escape_string(trim($_POST['fnameNew']));$sql = "UPDATE `users` SET `fname` = '$new_name' WHERE `username` = '$username'"; $query = mysql_query($sql) or die(mysql_error()); } ?><?php$sql = "SELECT * FROM users WHERE username = '$_SESSION[username]' LIMIT 1";$query = mysql_query($sql);while($row = mysql_fetch_array($query)) {echo "<b>Current First Name: '" .$row['fname']. "'</b>";}?> <table align="center" border="0" cellspacing="0" cellpadding="3"><tr><td ><font color=black>New First Name:</font></td><td><input type="text" name="fnameNew" maxlength="30"></td></tr><tr><td colspan="2" align="right"><input type="submit" name="updateFNAME" value="-Update-"></td></tr></table><table align="center" border="0" cellspacing="0" cellpadding="3"><tr><td colspan="2" align="right"><input type="submit" name="updateALL" value="-Save All-"></td></tr></table> </form></center><!- END FNAME - !><! - UPDATE ALL - !><?php if($_POST['updateALL']){$username = $_SESSION['username'];$new_name = mysql_real_escape_string(trim($_POST['fnameNew']));$new_email = mysql_real_escape_string(trim($_POST['emailNew']));$sql = "UPDATE `users` SET `fname` = '$new_name', `email` = '$new_email' WHERE `username` = '$username'"; $query = mysql_query($sql) or die(mysql_error()); } ?><!- END ALL - !>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.