Thought it might be easier to get a full view of the code. I've read the section on sessions at php.net a few times, and I get the idea...I just fail to see how to incorporate it here. I've colored the main sections to make things easier.
[size=2]<html>
<head>
<title>Title</title>
</head>
<body>
<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td colspan="2" height="63"><br /></td>
</tr>
<tr>
<td width="20%" valign="top">
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
</ul>
</td>
<td valign="top" width="80%">
[color=green]<?php[/color]
[color=orange]$login = "
<div id=\"login\">
<p>Hello, Welcome.</p>
<form method=\"post\" action=\"$_SERVER[PHP_SELF]\">
<input type=\"hidden\" name=\"check_login\" value=\"checked_in\" />
Username: <input type=\"text\" name=\"username\" size=\"25\" /><br />
Password: <input type=\"text\" name=\"password\" size=\"25\" />
<input type=\"submit\" name=\"submit\" value=\"Go\" />
</form>
</div>";[/color]
[color=blue]$the_form = "
<h2>Form</h2>
<form method=\"post\" action=\"$_SERVER[PHP_SELF]\">
<input type=\"hidden\" name=\"check\" value=\"checked\" />
<input type=\"hidden\" name=\"check_login\" value=\"checked_in\" />
<table class=\"form\" width=\"100%\" cellspacing=\"7\" border=\"0\">
<tr>
<td colspan=\"2\"><h3>Contact Informaton:</h3></td>
</tr>
<tr>
<td width=\"50%\">First Name:</td>
<td><input type=\"text\" name=\"fname\" value=\"$_POST[fname]\" size=\"25\" /></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type=\"text\" name=\"lname\" value=\"$_POST[lname]\" size=\"25\" maxlength=\"35\" /></td>
</tr>
<tr>
<td>Email Address:</td>
<td><input type=\"text\" name=\"email\" value=\"$_POST[email]\" size=\"25\" maxlength=\"35\" /></td>
</tr>
<tr>
<td>Telephone Number:</td>
<td><input type=\"text\" name=\"phone\" size=\"25\" /></td>
</tr>
<tr>
<td class=\"section-header\" colspan=\"2\"><h3>Please Specify:</h3></td>
</tr>
<tr>
<td>Administration</td>
<td><input type=\"radio\" name=\"level\" value=\"Admin\" /></td>
</tr>
<tr>
<td>Part Time</td>
<td><input type=\"radio\" name=\"level\" value=\"part\" /></td>
</tr>
<tr>
<td>Full Time</td>
<td><input type=\"radio\" name=\"level\" value=\"full\" /></td>
</tr>
<td ccolspan=\"2\"><h3>At which office are you located?</h3></td>
</tr>
<tr>
<td>County</td>
<td><input type=\"radio\" name=\"location\" value=\"county\" /></td>
</tr>
<tr>
<td>Local</td>
<td><input type=\"radio\" name=\"location\" value=\"local\" /></td>
</tr>
<tr>
<td>Munice</td>
<td><input type=\"radio\" name=\"location\" value=\"munice\" /></td>
</tr>
<tr>
<td colspan=\"2\"><h3>Please check the problem(s) you are having:</h3></td>
</tr>
<tr>
<td>Problem 1</td>
<td><input type=\"checkbox\" name=\"Problem 1\" value=\"yes\" /></td>
</tr>
<tr>
<td>Problem 2</td>
<td><input type=\"checkbox\" name=\"Problem 2\" value=\"yes\" /></td>
</tr>
<tr>
<td>Problem 3</td>
<td><input type=\"checkbox\" name=\"Problem 3\" value=\"yes\" /></td>
</tr>
<tr>
<td>Other</td>
<td><input type=\"checkbox\" name=\"problemNotSpecified\" value=\"yes\" /></td>
</tr>
<tr>
<td colspan=\"2\"><h3>Connection?</h3></td>
</tr>
<tr>
<td>Yes</td>
<td><input type=\"radio\" name=\"Connect\" value=\"yes_Connect\" /></td>
</tr>
<tr>
<td>No</td>
<td><input type=\"radio\" name=\"no_Connect\" value=\"no_Connect\" /></td>
</tr>
<tr>
<td colspan=\"2\"><h3>Send or receive emails?</h3></td>
</tr>
<tr>
<td>Yes</td>
<td><input type=\"radio\" name=\"Another\" value=\"anotherval\" /></td>
</tr>
<tr>
<td>No</td>
<td><input type=\"radio\" name=\"Send\" value=\"send\" /></td>
</tr>
<tr>
<td colspan=\"2\"><h3>Can you see?</h3></td>
</tr>
<tr>
<td>Yes</td>
<td><input type=\"radio\" name=\"see\" value=\"yes_see\" /></td>
</tr>
<tr>
<td>No</td>
<td><input type=\"radio\" name=\"see\" value=\"no_see\" /></td>
</tr>
<tr>
<td colspan=\"2\"><h3>Describe any additional problems or concerns:</h3></td>
</tr>
<tr>
<td><br /></td>
<td><textarea name=\"description\" cols=\"50\" rows=\"9\"></textarea></td>
</tr>
<tr>
<td colspan=\"2\"><input type=\"submit\" name=\"submit\" value=\"SUBMIT\" />
<input type=\"reset\" name=\"reset\" value=\"RESET FORM\" /></td>
</tr>
<tr>
<td id=\"footer\" colspan=\"2\">©2003 See Doctor</td>
</tr>
</table>
</form>";[/color]
[color=red]if (!$_POST[check_login]) {
echo "$login";
exit;
}
if ($_POST[check_login]) {
[color=grey]if ((!$_POST[username]) && (!$_POST[password])) {[/color]
echo "<p class='error'>Please enter your username and password!</p>";
echo "$login";
exit;
} else {
$dbname = "db";
$table = "table";
$connection = @mysql_connect("localhost", "user", "pass") or die(mysql_error());
$db = @mysql_select_db($dbname, $connection) or die(mysql_error());
$sql = "SELECT id FROM $table WHERE username = '".$_POST['username']."' AND
password = '".$_POST['password']."'";
$result = @mysql_query($sql, $connection) or die(mysql_error());
if (mysql_num_rows($result) != 1) {
echo "<p class='error'>Incorrect login, please enter your username and password.</p>";
echo "$login";
} else if(mysql_num_rows($result) == 1) {
if (!$_POST[check]) {
echo "$the_form";
} else if ($_POST['check']) {
if (!$_POST[fname]) {
$fname_error = "<p class='error'>Please enter your first name.</p><br />";
$transmission = "stop";
}
if (!$_POST[lname]) {
$lname_error = "<p class='error'>Please enter your last name.</p><br />";
$transmission = "stop";
}
if (!$_POST[email]) {
$email_error = "<p class='error'>Please enter your email address.</p><br />";
$transmission = "stop";
}
if ($transmission != "stop") {
$recipients = "sue@yoursite.com";
$subject = "See Doctor Ticket";
$mailheaders = "From: billybob@yoursite.com <> \n";
$mailheaders .= "Reply-To: $_POST[email]\n\n";
$contents = "CONTENTS OF SEE TICKET\n";
$contents .= "First Name: $_POST[fname]\n";
$contents .= "Last Name: $_POST[lname]\n";
$contents .= "Email: $_POST[email]\n";
$contents .= "Phone: $_POST[phone]\n";
$contents .= "Position:$_POST[level]\n";
$contents .= "Location:$_POST[location]\n";
$contents .= "Problem 1: $_POST[Problem 1]\n";
$contents .= "Problem 2: $_POST[Problem 2]\n";
$contents .= "Problem 3: $_POST[Problem 3]\n";
$contents .= "Other Problem: $_POST[problemNotSpecified]\n";
$contents .= "List One: $_POST[listone]\n";
$contents .= "See 1: $_POST[see 1]\n";
$contents .= "See: $_POST[see]\n";
$contents .= "Problem Description: " . stripslashes($_POST[description]);
mail($recipients, $subject, $contents, $mailheaders);
echo "<div class='error-correction'>";
echo "<p>Thank you. Your message has been sent to our technicians. We will be with you shortly.</p>";
echo "<a class='error-anchor' href='index.html'>Main Page</a> | ";
echo "<a class='error-anchor' href='http://www.other.com/'>Other</a>";
echo "</div>";
}
else if ($transmission == "stop") {
echo "<h2>Form Error Notification</h2>";
echo "<p class='error'>$fname_error</p>";
echo "<p class='error'>$lname_error</p>";
echo "<p class='error'>$email_error</p>";
echo "$the_form";
}
$receiver = $_POST['email'];
$subject = "From the See Doctor";
$message = "Thank you for contacting us!\n" .
"Your message has been sent to our people\n" .
"and will be processed as soon as possible.\n" .
"Have a nice day!";
mail($receiver, $subject, $message,
"From: webmaster@$SERVER_NAME\r\n"
."Reply-To: webmaster@$SERVER_NAME\r\n"
."X-Mailer: PHP/" . phpversion());
}
}
}
}[/color]
[color=green]?>[/color]
</td>
</tr>
</table>
</body>
</html>[/size]
-----------------------------------------------------------------
The Problem: After logging in (which is no problem), the main form ($the_form) appears -> After the user fills out the main form and clicks submit, it heads back to the login form- the condition it gets caught on is grey above.
That about sums it up. If this can be made to work, and it's not a worthless chunk of code then have at it. It's my first attempt at PHP so I'm sure it's riddled with holes.
Any help, much much appreciated!