Need help with refreshing the page..
what my page does: it pulls data from a db and displays the information at the same time and on the same page a text field is offered to add to the record/field...
the above code works but after hitting the submit but it does reload the page to display what was added in the record...basically its not refreshing with the new data that was entered..
Code: Select all
<?php
session_start();
$host1 = "hostname";
$database1 = "databasename";
$database1 = "password";
$database1 = "db";
mysql_connect($host1, $database1, $database1);
@mysql_select_db($database_name) or die("Not able to connect to database" );
$query1 = "select fname, lname, userfix from dbt_customer_table where dbcust_id = 19";
$results1 = mysql_query($query1) or die(mysql_error());
$row = mysql_fetch_array($results1);
mysql_close();
$userfname_web = $row['fname'];
$userlname_web = $row['lname'];
$userfix_web = $row['userfix'];
//echo "<html>";
echo "<body>";
echo "<table width='500' border='1' align='center'>";
echo "<tr>";
echo "<td colspan='4'>user info:</td>";
echo "</tr>";
echo "<tr>";
echo "<td width='82'>First name:</td>"; //first name
echo "<td width='138'>$userfname_web</td>";
echo "<td width='73'>Last Name:</td>"; //lastname
echo "<td width='179'>$userlname_web</td>";
echo "</tr>";
echo "<tr>";
echo "<td colspan='4'> </td>";
echo "</tr>";
echo "</table>";
echo "<table width='500' border='1' align='center'>";
echo "<tr>";
echo "<td width='512'>data pulled from the database</td>";
echo "</tr>";
echo "<tr>";
echo "<td>$userfix_web</td>"; //show what was saved to the db
echo "</tr>";
echo '<FORM NAME="ContactForm" ACTION="' . $_SERVER['PHP_SELF'] . '" METHOD="POST">';
echo "<tr>";
echo "<td><INPUT TYPE=HIDDEN NAME='Action' VALUE='Register'></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Add to the database</td>"; // add to db
echo "</tr>";
echo "<tr>";
echo "<td height='54'> <textarea name='appendfield' cols='50' rows='5' id='appendfield'></textarea> </td>";
echo "</tr>";
echo "</table>";
echo "<table width='500' border='1' align='center'>";
echo "<tr>";
echo "<td width='376' height='24'><div align='right'>";
echo "<input name='resetbutton' type='reset' value='Reset'>";
echo "</div></td>";
echo "<td width='193'>";
echo "<input name='appendbutton' type='submit' value='Append'>";
echo "</td>";
echo "</form>";
echo "</tr>";
echo "</table>";
echo " </p><p> </p>";
echo "</body>";
echo "</html>";
if (!isset($_POST['Action'])) $_POST['Action'] = '';
if (!isset($_SESSION['FormProcessed'])) $_SESSION['FormProcessed'] = 0;
if(isset($appendbutton) && !empty($appendfield))
{ if ($_SESSION['FormProcessed'] == 1)
{ exit('You have been registered.</BODY></HTML>');
}
mysql_connect($host1, $database1, $database1);
@mysql_select_db($database_name) or die("Not able to connect to database" );
$Separate_line = "<BR><HR>"; //line devider
$append_value = $Separate_line."".$appendfield; //value to be added
$query1 = "update dbt_customer_table set dbprob_userfix = concat(dbprob_userfix, '$append_value') where dbcust_id = '19'";
mysql_query($query1) or die(mysql_error());
mysql_close();
$_SESSION['FormProcessed'] = 1;
exit('You have been registered.</BODY></HTML>');
}
$_SESSION['FormProcessed'] = 0;
?>