Jump to content

Return to another page after Submit button selected and data updated.


bajangerry

Recommended Posts

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

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.