corkg Posted June 14, 2007 Share Posted June 14, 2007 Hi I have this code (below) it is a notepad when I submit the data it does not bring up the latest data that i have just submitted. <?php session_start(); include_once "includes/db_connect.php"; include_once"includes/functions.php"; logincheck(); $username=$_SESSION['username']; $query=mysql_query("SELECT * FROM users WHERE username='$username'"); $fetch=mysql_fetch_object($query); $query1=mysql_query("SELECT * FROM user_info WHERE username='$username'"); $user=mysql_fetch_object($query1); if (($_POST['change_notes']) && ($_POST['notes'])){ $notes=strip_tags($_POST['notes']); mysql_query("UPDATE users SET notes='$notes' WHERE username='$username'"); echo "Your notes have been updated"; } ?> <html> <body> <center> <br> <table width="713" border="1" class="thinline" rules="none" cellpadding="0" cellspacing="0" bordercolor=black bgcolor=""> <tr> <td width="709" height="21" class="header"> <div align="center"><font color="#FFFFFF">Note Pad</font> </div></td> </tr> <tr> <td ><table width="100%" height="383" border="0" cellpadding="2" cellspacing="2"> <tr> <td><form action="" method="POST"> <br> <center><textarea name="notes" cols="100" rows="15" id="notes"><?php echo "$fetch->notes"; ?></textarea></center> <br> <br> <center><input name="change_notes" type="submit" id="change_notes" value="submit"> </center><br> </form></td> </tr> </table></td> </tr> </table> <br> <p> </p> </center><p> <?php include_once"includes/footer.php"; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/55540-solved-update-when-submiting/ Share on other sites More sharing options...
MasterACE14 Posted June 14, 2007 Share Posted June 14, 2007 let me get this straight. it is a webpage notepad for users of your website. and they just out in notes and stuff and press a button which puts it in your database? and you can't get it to display the data that has been updated?? Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/55540-solved-update-when-submiting/#findComment-274449 Share on other sites More sharing options...
corkg Posted June 14, 2007 Author Share Posted June 14, 2007 Yeah. When you submit it saves but says It has been updated, but you have to refresh before you can see it. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/55540-solved-update-when-submiting/#findComment-274967 Share on other sites More sharing options...
corkg Posted June 15, 2007 Author Share Posted June 15, 2007 It works fine saving but does not refresh so that you can view what you have just saved. Quote Link to comment https://forums.phpfreaks.com/topic/55540-solved-update-when-submiting/#findComment-275218 Share on other sites More sharing options...
corkg Posted June 15, 2007 Author Share Posted June 15, 2007 Please Help Quote Link to comment https://forums.phpfreaks.com/topic/55540-solved-update-when-submiting/#findComment-275255 Share on other sites More sharing options...
chocopi Posted June 15, 2007 Share Posted June 15, 2007 after it is updated put in a redirect, but redirect to that page header("Location: youpage.php"); Hope that helps ~ Chocopi Quote Link to comment https://forums.phpfreaks.com/topic/55540-solved-update-when-submiting/#findComment-275266 Share on other sites More sharing options...
corkg Posted June 15, 2007 Author Share Posted June 15, 2007 I have got it working but can't get it to submit if there is nothing in the field <?php session_start(); include_once "includes/db_connect.php"; include_once"includes/functions.php"; logincheck(); $username=$_SESSION['username']; if (($_POST['change_notes']) && ($_POST['notes'])){ $notes=strip_tags($_POST['notes']); mysql_query("UPDATE users SET notes='$notes' WHERE username='$username'"); ($_POST['change_notes']) && ($_POST['notes']); echo "Your notes have been updated"; } ?> <html> <body> <center> <br> <table width="713" border="1" class="thinline" rules="none" cellpadding="0" cellspacing="0" bordercolor=black bgcolor=""> <tr> <td width="709" height="21" class="header"><div align="center"><font color="#FFFFFF">Note Pad</font> </div></td> </tr> <tr> <td ><table width="100%" height="383" border="0" cellpadding="2" cellspacing="2"> <tr> <td><form action="" method="POST"> <br> <center> <textarea name="notes" cols="100" rows="15" id="notes" ><?php $query=mysql_query("SELECT * FROM users WHERE username='$username'"); $fetch=mysql_fetch_object($query); $query1=mysql_query("SELECT * FROM user_info WHERE username='$username'"); $user=mysql_fetch_object($query1); echo "$fetch->notes"; ?> </textarea> </center> <br> <br> <center> <input name="change_notes" type="submit" id="change_notes" value="submit"> </center> <br> </form></td> </tr> </table></td> </tr> </table> <br> <p> </p> </center> <p> </p> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/55540-solved-update-when-submiting/#findComment-275279 Share on other sites More sharing options...
chocopi Posted June 15, 2007 Share Posted June 15, 2007 isnt that a good thing ? you dont really want for people to submit empty fields, do you ??? Quote Link to comment https://forums.phpfreaks.com/topic/55540-solved-update-when-submiting/#findComment-275292 Share on other sites More sharing options...
corkg Posted June 15, 2007 Author Share Posted June 15, 2007 But it is a notepad for users they want to be able to delete everything in it. Quote Link to comment https://forums.phpfreaks.com/topic/55540-solved-update-when-submiting/#findComment-275484 Share on other sites More sharing options...
corkg Posted June 15, 2007 Author Share Posted June 15, 2007 I have this problem in other parts of the site so please can anyone help me out. Please Quote Link to comment https://forums.phpfreaks.com/topic/55540-solved-update-when-submiting/#findComment-275582 Share on other sites More sharing options...
corkg Posted June 16, 2007 Author Share Posted June 16, 2007 Hello? Quote Link to comment https://forums.phpfreaks.com/topic/55540-solved-update-when-submiting/#findComment-275743 Share on other sites More sharing options...
raila Posted June 16, 2007 Share Posted June 16, 2007 can you use this? : if(empty($_POST['note']) { fwrite("to note file", "empty"); } this will write the word "empty" to the file. I know that's not what you're looking fore but it is the only way i know to solve it. Quote Link to comment https://forums.phpfreaks.com/topic/55540-solved-update-when-submiting/#findComment-275764 Share on other sites More sharing options...
corkg Posted June 16, 2007 Author Share Posted June 16, 2007 I have fixed it using the code below logincheck(); $username=$_SESSION['username']; if(($_POST['change_notes']) && ($notes==NULL)){ mysql_query("UPDATE users SET notes='' WHERE username='$username'");} if (($_POST['change_notes'])&&($_POST['notes'])){ $notes=($_POST['notes']); mysql_query("UPDATE users SET notes='$notes' WHERE username='$username'"); echo "Your notes have been updated"; Quote Link to comment https://forums.phpfreaks.com/topic/55540-solved-update-when-submiting/#findComment-275767 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.