Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Storing details then using in a contact submission

Status
Not open for further replies.

noellees1

Programmer
Feb 2, 2004
383
GB
Hi,
I am trying to make a contact form for registerd clients
Therefore when they login i am storing their details in a session variable, i am then calling this session variable (their user_id) and trying to extract data from it, i am then trying to put this data into hidden fields on a contact form so that i can see their information
However, i have tried doing this and everytime the login, login_process and add pages all load suggesting that the data is extracted.
However once i go to insert it, it seems to refuse to work i get undefined in session errors. Below is my code, i think the problems are in the login_process and action.cfm pages.

----login.cfm-------
Code:
<HTML>
<HEAD>
<TITLE>LOGIN</TITLE>
</HEAD>
<BODY>
<form action="login_process.cfm" method="post">
   Username: <input type="text" name="user_name" value=""><BR>
   Password: <input type="password" name="user_pass" value=""><BR>
   <input type="submit" name="login_user" value="Log In"><BR>
</form>
</BODY>
</HTML>

-------login_process.cfm------
Code:
<!--- Get all records from the database that match this users credentials --->
<cfquery name="qVerify" datasource="daniel">
    SELECT             user_name, user_pass, permlevel, user_id
    FROM                tblAdmins
    WHERE              user_name = '#form.user_name#'
                     AND user_pass = '#form.user_pass#'
</cfquery>

<cfset session.permlevel = qVerify.permlevel>
<cfset session.user_id = #qverify.user_id#>
<cfif qVerify.RecordCount>
    <!--- This user has logged in correctly, change the value of the session.allowin value --->
    <cfset session.allowin = "True">
    <!--- Now welcome user and redirect to "members_only.cfm" --->
    <script>
         alert("Welcome user, you have been successfully logged in!");
         self.location="manager/members_only.cfm"
    </script>
< cfelse>
    <!--- this user did not log in correctly, alert and redirect to the login page --->
    <script>
        alert("Your credentials could not be verified, please try again!!!");
        self.location="Javascript:history.go(-1)";
    </script>
</cfif>

--------members_only.cfm------
Code:
<HTML>
<HEAD>
<TITLE> DSP Computer Services - Super Admin </TITLE>
</HEAD>
<BODY>
<cfif session.permlevel LT '3'> 
<CFLOCATION url="../admins/members_only.cfm">
<cfabort> 
</cfif> 
<p><a href="/clients/contact/add.cfm">Contact Section </a></p>
</BODY>
</HTML>

Now i click on the contact section link to go to the contact area
------add.cfm-------
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<html>
<head>
<CFQUERY NAME="GetRecords" DATASOURCE="daniel">
   SELECT          *
   FROM             tblAdmins
   WHERE user_id = #session.user_id#
</CFQUERY>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Add a Support Ticket</title>
</head>

<body>
Welcome <cfoutput>#GetRecords.user_name#</cfoutput>
<p>To add a support ticket fill in the form below and we will strive to get back to you within 24hrs
  
</p>
<form name="insertsupport" method="post" action="action.cfm">
  <p>
    <input name="description" type="text" id="description"> 
  Ticket Description/Subject</p>
  <p>
    <select name="urgency" size="1" id="urgency">
      <option value="4">Urgent</option>
      <option value="3">High</option>
      <option value="2">Medium</option>
      <option value="1">Low</option>
    </select> 
    Urgency</p>
  <p>
    <textarea name="message" cols="40" rows="8" id="message"></textarea>
Your problem... Please describe in as much detail as is possible </p>
  <p>
    <input name="Submit" type="submit" id="Submit" value="Add Ticket">
    <input type="reset" name="Reset" value="Start Over">
    <br>
  </p>
  <p>An email will be sent to the email you specified as your own when you set up your account with DSP Computer Services</p>
  <p>
    <input name="user_name" type="hidden" id="user_name" value="<cfoutput>#GetRecords.user_name#</cfoutput>">
    <input name="hiddenField" type="hidden" value="<cfoutput>#GetRecords.firstname#</cfoutput>">
    <input name="hiddenField" type="hidden" value="<cfoutput>#GetRecords.lastname#</cfoutput>">
    <input name="hiddenField" type="hidden" value="<cfoutput>#GetRecords.email#</cfoutput>">
  </p>
</form>
<!--- Variables Sent to action are description, urgency, message, user_name, firstname, lastname, email. --->
<p>&nbsp;</p>
</body>
</html>

this is the main processing page

------action.cfm------
Code:
<HTML>
    <HEAD>
       <CFOUTPUT>
           <TITLE>Your Tickets Been Successfully Added</TITLE>
       </CFOUTPUT>
    </HEAD>

    <BODY>

    <!--- First let's insert this data into our database for safe keeping and later usage. --->
     <CFINSERT DATASOURCE="daniel" TABLENAME="contact" FORMFIELDS="description, urgency, message, user_name, firstname, lastname,email">

     <!--- Now let's send a copy of this submission by email to ourselves --->
     <CFMAIL FROM="#form.email#" TO="daniel@spanoweb.com" SUBJECT="Support Ticket Added" SERVER="mail.spanoweb.com" PORT="25">
      There has been a submission in the support tickets, here's what they had to say:

      Sender name: #form.firstname# #form.lastName#
      Sender email: #form.email#
      Sender IP: #REMOTE_ADDR#
      Urgency: #urgency#
	  Description: #description#
	  Username: #user_name#
	  

      Message: #Message#
      Message Sent: #DateFormat(now(), 'mmmm dd, yyyy')# #TimeFormat(Now(), 'hh:mm:ss tt')#
      
    </CFMAIL>

     <!--- Now Let's Send An Email To The Person Submitting This Form, Thanking Them For The Form Submission --->
     <CFMAIL FROM="daniel@spano.co.uk" TO="#form.email#" SUBJECT="Support Ticket Added" SERVER="mail.spanoweb.com" PORT="25">
      Dear #form.firstname# #form.Lastname#,
           Thank you for submitting Our Contact Form. We will contact you back within 24 hours. We've also
      sent you a copy of what you submitted below.

      Thanks again,
      Daniel
      DSP Computer Services

      Submission Receipt:
      ===========================================================
      Sender name: #form.firstname# #form.lastName#
      Sender email: #form.email#
      Sender IP: #REMOTE_ADDR#

      Message: #Message#
      Message Sent: #DateFormat(now(), 'mmmm dd, yyyy')# #TimeFormat(Now(), 'hh:mm:ss tt')#
      
    </CFMAIL>

     <!--- Now we actually have to display something on the page to let the user know that his submission was successful --->
     <CFOUTPUT>

     Thank you #form.firstname# #form.lastname#, we have successfully received your request and it's been sent to the coresponding
     support personnel.  Expect to hear from us within 24 hours.  A copy of this form submission was also sent to the email address you specified as being
     yours when you signed up, if this is incorrect we urge you contact webmaster@spano.co.uk as no corrospondance will reach us.<BR>
     <BR>
     Thanks,<BR>
     Daniel<BR>
     DSP Computer Service
     </CFOUTPUT> 

    </BODY>
</HTML>


The database has the following two tables in it

contact > contact_ref, entered, description, urgency, message, user_name, firstname, lastname, email

tblAdmins > user_id, user_name, user_pass,permlevel, firstname, lastname,email, message, time

Cheers
Daniel


The way web design should be
 
Talk about thick [ponder]
I just realised i wasnt actually passing the data
<input name="user_name" type="hidden" id="user_name" value="<cfoutput>#GetRecords.user_name#</cfoutput>">
<input name="hiddenField" type="hidden" value="<cfoutput>#GetRecords.firstname#</cfoutput>">
<input name="hiddenField" type="hidden" value="<cfoutput>#GetRecords.lastname#</cfoutput>">
<input name="hiddenField" type="hidden" value="<cfoutput>#GetRecords.email#</cfoutput>">
With that
I then went back over it changed these into the correct field
Sorted
Sorry for the huge post managed to sort it in the end


The way web design should be
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top