Click to See Complete Forum and Search --> : save form data when submitted but not complete


cjc1055
11-07-2005, 01:37 PM
forget it.. dumb question, figure it out already

tegraphix
11-07-2005, 02:08 PM
If you're still interested in a rework:
<?

if (isset($_POST['submit'])) {

include 'connect.php';

$name = $_POST['name'];
$practice = $_POST['practice'];
$account = $_POST['account'];
$received = $_POST['received'];
$transferred = $_POST['transferred'];
$reason = $_POST['reason'];

if ($received == "something") {
$received1 = "selected";
} elseif ($received == "whatever") {
$received2 = "selected";
}

if ($transferred == "something") {
$transferred1 = "selected";
} elseif ($transferred == "whatever") {
$transferred2 = "selected";
}

if (!empty($name) && !empty($practice) && !empty($account) && !empty($received) && !empty($transferred) && !empty($reason)) {

$query = "insert into phone VALUES (DEFAULT, '$name', '$practice', '$account', '$received', '$transferred', '$reason')";
$result = odbc_exec($conn,$query);
echo "<p align=\"center\"><strong>New Contact Added Successfully</strong></p>";
echo "<p align=\"center\">Click <a href=\"index.php\">here</a> to return to the view calls screen</a></p>";
} else {
echo "<p align=\"center\"><font color=\"red\"><strong>You need to fill out all the required fields, No entry made</strong></font><p>";
}

odbc_close($conn);
}
?>

<div align="center">
<form method="post">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="100">Patient Name</td>
<td><input name="name" type="text" size="31" maxlength="30" id="name" value="<? echo $name; ?>"></td>
</tr>
<tr>
<td width="100">Practice</td>
<td><input name="practice" type="text" size="15" maxlength="15" id="practice" value="<? echo $practice; ?>"></td>
</tr>
<tr>
<td width="100">Patient Account Number</td>
<td><input name="account" type="text" size="15" maxlength="15" id="account" value="<? echo $account; ?>"></td>
</tr>
<tr>
<td width="100">Received by</td>
<td><select name="received" size="1">
<option><strong>Please select a contact</strong></option>
<option></option>
<option value="something" <? echo $received1; ?>>something</option>
<option value="whatever" <? echo $received2; ?>>whatever</option>
</select></td>
</tr>
<tr>
<td width="100">Transferred to or worked</td>
<td><select name="transferred" size="1">
<option><strong>Please select a contact</strong></option>
<option></option>
<option value="something" <? echo $transferred1; ?>>something</option>
<option value="whatever" <? echo $transferred2; ?>>whatever</option>
</select></td>
</tr>
<tr>
<td width="100">Reason for call / Notes</td>
<td><input name="reason" type="text" size="50" maxlength="50" id="reason" value="<? echo $reason; ?>"></td>
</tr>
</table>
<input type="submit" name="submit" value="Submit">
</form>
<a href="index.php">View Calls</a>
</div>