<% Option Explicit %>
<!--#include file="common.asp" -->
<%

'Set the response buffer to true as we maybe redirecting
Response.Buffer = True



'Dimension variables
Dim intMessageID 	'Holds the messageID number
Dim strName 		'Holds the Users name
Dim strCountry 		'Holds the users country
Dim strEmailAddress 	'Holds the Users e-mail address
Dim strHomepage 	'Holds the Users homepage
Dim strComments 	'Holds the Users comments
Dim dtmEntryDate 	'Holds the date the commnets where made
Dim id 
Dim SSN 
Dim DID
Dim LN 
Dim FN
Dim MN
Dim PH
Dim EM
Dim ADR
Dim SX 
Dim DOB 
Dim DIVID 




'If the session variable is False or does not exsist then redirect the user to the unauthorised user page
If Session("blnIsUserGood") = False or IsNull(Session("blnIsUserGood")) = True then
	
	'Reset Server Variables
	Set rsCommon = Nothing	
	adoCon.Close
	Set adoCon = Nothing
	
	'Redirect to unathorised user page
	Response.Redirect"unauthorised_user_page.htm"
End If




'Read in message number to be amended as long as it is a number entered
If IsNumeric(Request.QueryString("amend")) Then	
	intMessageID = (Request.QueryString("amend"))
End If

	
'Initalise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT * FROM GROUP1_CUSTOMER"
strSQL = strSQL & " WHERE C_SSN ='" & (intMessageID)&"'"
	
'Query the database
rsCommon.Open strSQL, adoCon


%>
<html> 
<head>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Amend Agent Details</TITLE>

<script  language="JavaScript">
<!-- Hide from older browsers...

//Function to check form is filled in correctly before submitting
function CheckForm () {

	//Check for a name
	if (document.frmAmnedComments.name.value==""){
		alert("Please enter your name");
		document.frmAmnedComments.name.focus();
		return false;
	}
	
	//Check for a country
	if (document.frmAmnedComments.country.value==""){
		alert("Please enter the country you are from");
		document.frmAmnedComments.country.focus();
		return false;
	}
	
	//Check for comments
	if (document.frmAmnedComments.comments.value==""){
		alert("Please enter your comments");
		document.frmAmnedComments.comments.focus();
		return false;
	}
	
	return true
}

// -->
</script>

</head>
<body bgcolor="#FFFFFF">
<div align="center"> 
  <h1>Amend Agent Details</h1>
  <a href="admin_menu.asp" target="_self">Return to the Guestbook Admin Menu</a><br>
  <br>
</div><%

	
'If there are no rcords in the database display an error message
If rsCommon.EOF Then
	
	'Tell the user there are no records to show
	Response.Write "There are no records with the message number " & intMessageID & " in the guestbook database"
	Response.Write "<br>Please check back later"
	Response.End
	
'Display the guestbook entry
Else
      		

   	'Read in the values form the database      	
        SSN = rsCommon("C_SSN")
        LN = rsCommon("C_LNAME")
	FN = rsCommon("C_FNAME")
	MN = rsCommon("C_MNAME")
	PH = rsCommon("C_PHONE")
        EM = rsCommon("C_EMAIL")
	ADR = rsCommon("C_ADDRESS")
	DOB = rsCommon("C_ADDRESS")
	SX = rsCommon("C_SEX")

  	'Reset Server Variables
	rsCommon.Close
	Set rsCommon = Nothing	
	adoCon.Close
	Set adoCon = Nothing
End If
%>
<br>
<form name="frmAmnedComments" method="post" action="amend_agents.asp?PagePosition=<% = Server.URLEncode(Request.QueryString("PagePosition")) %>" onSubmit="return CheckForm();">
  <table width="640" border="0" align="center" height="233">
    <tr> 
      <td align="right" width="24%" height="14">SSN:</td>
      <td height="14" width="76%"><% = SSN %>
        <input type="hidden" name="SSN" value="<% = SSN %>">
      </td>
    </tr>

   
    <tr> 
      <td align="right" width="24%" height="14">LAST Name:</td>
      <td height="14" width="76%"> 
        <input type="text" name="lname" size="30" maxlength="50" value="<% = LN %>">
      </td>
    </tr>

    <tr> 
      <td align="right" width="24%" height="14">FIRST Name:</td>
      <td height="14" width="76%"> 
        <input type="text" name="fname" size="30" maxlength="50" value="<% = FN %>">
      </td>
    </tr>

    <tr> 
      <td align="right" width="24%" height="14">MIDDLE Name:</td>
      <td height="14" width="76%"> 
        <input type="text" name="mname" size="30" maxlength="50" value="<% = MN %>">
      </td>
    </tr>

    <tr> 
      <td align="right" width="24%" height="14">PHONE:</td>
      <td height="14" width="76%"> 
        <input type="text" name="ph" size="30" maxlength="50" value="<% = PH %>">
      </td>
    </tr>


    <tr> 
      <td align="right" width="24%" height="14">EMAIL:</td>
      <td height="14" width="76%"> 
        <input type="text" name="em" size="30" maxlength="50" value="<% = EM %>">
      </td>
    </tr>

   <tr> 
      <td align="right" width="24%" height="14">ADDRESS:</td>
      <td height="14" width="76%"> 
        <input type="text" name="adr" size="30" maxlength="50" value="<% = ADR %>">
      </td>
    </tr>

   <tr> 
      <td align="right" width="24%" height="14">DIVISION ID:</td>
      <td height="14" width="76%"> 
        <input type="text" name="divid" size="30" maxlength="50" value="<% = NP %>">
      </td>
    </tr>

    <tr> 
      <td align="right" width="24%" height="14">SEX :</td>
      <td height="14" width="76%"> 
        <input type="text" name="sx" size="30" maxlength="50" value="<% = CM %>">
      </td>
    </tr>

   <tr> 
      <td align="right" width="24%" height="14">DOBX :</td>
      <td height="14" width="76%"> 
        <input type="text" name="dob" size="30" maxlength="50" value="<% = CM %>">
      </td>
    </tr>

    
    <tr> 
      <td valign="top" align="right" height="32" width="24%">&nbsp; </td>
      <td height="32" width="76%"> 
        <p> 
          <input type="submit" name="Submit" value="Amend Agent">
        </p>
      </td>
    </tr>
  </table>
</form>

<form name="frmAmnedComments" method="post" action="delete_customer.asp">
  <input type="submit" name="delete" value="Delete cutomer">
</form>

<div align="center"></div>
</body>
</html>