bajangerry Posted November 28, 2008 Share Posted November 28, 2008 I bet this is easy but I still don't get it! I have a page that lists data from a MySQL database and has a link on each row that allows you to open another page an edit that row's data. What I want to know is how I can get back to the original page with the list after the submit button has been selected. Am sure it is easy but I can't get my head around it :-s Quote Link to comment https://forums.phpfreaks.com/topic/134660-return-to-another-page-after-submit-button-selected-and-data-updated/ Share on other sites More sharing options...
revraz Posted November 28, 2008 Share Posted November 28, 2008 What does your submit button do now? Quote Link to comment https://forums.phpfreaks.com/topic/134660-return-to-another-page-after-submit-button-selected-and-data-updated/#findComment-701145 Share on other sites More sharing options...
bajangerry Posted November 28, 2008 Author Share Posted November 28, 2008 Submit button updates database with changes and reloads page, see code below: <? include "lib/config.php"; top(); $url = $_GET['a']; if (($_POST['Submit'])){ $accountcode=$_POST['accountcode']; $name=$_POST['name']; $update = "UPDATE accountcode SET accountcode = '$accountcode', name = '$name' WHERE accountcode= '$accountcode'"; $result = mysql_query($update) or die("SQL Update failed, please try again"); flush(); } ?> <? $query = "SELECT * FROM accountcode WHERE accountcode = $url"; $result = mysql_query($query); ?> <html> <head> <title>SMDR reporting</title> <style type="text/css"> <!-- table { background-color:#FFF; width:100%; border-collapse:collapse; } /* and of course a default one */ td { background-color:#FFF; border:1px solid black; padding:5px; } --> </style> </head> <html> <body> <?php while($row = mysql_fetch_object($result)) { $rowno += 1; ?> <form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>"> <h3 align="center">Update Account Code Details </h3> <table align="center"> <tr valign="baseline"> <td width="99" align="right" nowrap>Account Code:</td> <td width="194"><input type="text" name="accountcode" value="<?php echo ($row->accountcode); ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Name:</td> <td><input type="text" name="name" value="<?php echo ($row->name) ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td><input type="submit" value="Submit" name="Submit"></td> <input type="hidden" name="AccNo" value="<?php echo ($row->accountcode); ?>"> </tr> </table> </form> <?php }?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/134660-return-to-another-page-after-submit-button-selected-and-data-updated/#findComment-701147 Share on other sites More sharing options...
budimir Posted November 28, 2008 Share Posted November 28, 2008 You can use header("Location:name_of_the_page_you_want_get_back_to.php"); Quote Link to comment https://forums.phpfreaks.com/topic/134660-return-to-another-page-after-submit-button-selected-and-data-updated/#findComment-701267 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.