I have a script that pulls data from a db. I need a user to be able to update the form info and then have the from refresh or post back to it self with the updated info. I can't seem to get this to work. Any ideas?
Thanks
How about shoiwn us what you've got?
A typical page would be as follows:
<?php
if(count($_POST)>0) {
//do form processing
if($success) {
//probably redirect
}
}
?>
<!--HTML stuff-->
<form action="" method="post">
<!--form fields here, e.g. :-->
<input type="text" name="firstname" value="<?=(isset($_POST['firstname'])?$_POST['firstname']:''?>" />
</form>
I wonder if I can combine the two forms so I get the form to post to it self. I don't know.
**********Page 1******
<html>
<body>
<head><link rel=stylesheet type=text/css href=css/default.css>
</head>
<form action = "followupdate.php" method ="POST"></head>
<h1><p align=center>The Corporation</p></h1>
<h3><p align=center>Guest History </p></h3>
<h3><p align=center></center></p></h3>
<p align =center>
<a href="guestmain.php"> Main </a>
<?echo $row[11]?><a href="pethree.php"> P/E<a href="contacteditfour.php"> Status Change </a></center>
<br>
<hr>
<?
include "conn.php";
session_start();
$tpoint = $_POST['tpoint'];
$tpointdate = $_POST['tpointdate'];
$note = $_POST['note'];
$notedate = $_POST['notedate'];
$mysql = "SELECT id from cust where lname = '$lname' and community= '$community'";
$result= mysql_query($mysql) or die ("Can't connect");
$row = mysql_fetch_row($result);
$id = $row[0];
$mysql1 = "SELECT fname, lname,address,city,state,zip,hphone,cphone,wphone, email from cust where lname = '$lname' and community= '$community' and id = '$id'";
$result1= mysql_query($mysql1) or die ("Can't connect");
echo "<th> Guest</th>";echo "<th> Address</th>";echo "<th> Home</th>";echo "<th> Cell</th>";echo "<th> Work</th>";echo "<th> Email</th>";
echo "<table border=\"0\">";
$j = true;
while ($row = mysql_fetch_row($result1))
{
if($j)
$j= false;
else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result1);$i++) {
if ($j) {
echo "<td bgcolor=\"#CCFF99\">";
}
if (!$j) {
echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";
}
}
echo "</table>";
?>
<?
$mysql2 = "SELECT status, level, adulthousehold,childhousehold,nameage from cust where lname = '$lname' and community= '$community'and id = '$id'";
$result2= mysql_query($mysql2) or die ("Can't connect");
echo "<th> Status</th>";;echo "<th> L</th>";;echo "<th> A C Names</th>";
echo "<table border=\"0\">";
$j = true;
while ($row = mysql_fetch_row($result2))
{
if($j)
$j= false;
else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result2);$i++) {
if ($j) {
echo "<td bgcolor=\"#CCFF99\">";
}
if (!$j) {
echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";
}
}
echo "</table>";
?>
<?
$mysql3 = "SELECT realname,realcomp,realadd,realphone from realtor where id = '$id'";
$result3= mysql_query($mysql3) or die ("Can't connect");
echo "<th> Realtor</th>";
echo "<table border=\"0\">";
$j = true;
while ($row = mysql_fetch_row($result3))
{
if($j)
$j= false;
else
$j=true;
echo "<tr>";
for ($i=0;$i<mysql_num_fields($result3);$i++) {
if ($j) {
echo "<td bgcolor=\"#CCFF99\">";
}
if (!$j) {
echo "<td bgcolor=\"#FFFFCC\">";
}
echo $row[$i];
echo "</td>";
}
}
echo "</table>";
?>
<hr>
<br>
<br>
<br>
<p align = "center">
Touch Point <select name ="tpoint"><option value = ""><option value = "Postcard ">Post Card<option value="Email Lead">Email Lead<option value ="Call Lead">Call Lead<option value ="Personal Note">Personal Note<option value ="Letter">Letter<option value ="Flyer">Flyer<option value ="Child Note">Child Note<option value ="Walk In">Walk In<option value ="Guest Call">Guest Call In</select> Demo <select name ="demo"><option value = ""><option value = "Model Demo">Model Demo <option value = "Site Demo">Site Demo<option value = "Model Visit">Model Visit<option value = "P/E">P/E </align></select>
<br>
<br>
<p align = "center"> Notes:</p></center><p align = "center"><textarea rows="8" cols= "80" name ="note"></textarea></center>
<p><input type=Submit name=Submit style="font-size:15" value="Save"> <p>
</body>
</html>
************************Form is processed below*************
<html>
<form enctype = "multipart/form-data" method= "POST" >
<head><link rel=stylesheet type=text/css href=css/default.css></head>
<?
header("Location:contactfirst.php");
include "conn.php";
session_start();
session_register("community","lname","id","tpoint");
$community=$_POST['community'];
$tpoint = $_POST['tpoint'];
if (empty($tpoint))
{
$query = "insert into followup ( id,lname, note) values ('$id','$lname','$note')";
$result = mysql_query($query) or die ("Could not insert");
} else {
$query = "insert into followup ( id,lname, tpoint,tpdate,tpcount,note) values ('$id','$lname','$tpoint',now(),'1','$note')";
$result = mysql_query($query) or die ("Could not insert");
}
?>
</body>
</form>
</html>