Contact Page, add user fields
Printed From: ProductCart E-Commerce Solutions
Category: ProductCart
Forum Name: Customizing ProductCart
Forum Description: Exchange messages with other users that are customizing ProductCart.
URL: https://forum.productcart.com/forum_posts.asp?TID=2648
Printed Date: 29-September-2024 at 12:21am Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
Topic: Contact Page, add user fields
Posted By: mthierfelder
Subject: Contact Page, add user fields
Date Posted: 15-April-2009 at 12:11am
I am trying to add "Company" and "Phone Number" as user filled in forms to the contact page. I had it working, then we switched servers and its not working in that no email ever gets sent.
I'm not an ASP whiz by any means, I just copied some of the logic for other fields.
I did add eng_Contact_11 and eng_Contact_12 to languages.asp as "Your Company" and "Your Phone". Then of course added the two fields to the contact.asp page like so:
<tr> <td><p> <%response.write dictLanguage.Item(Session("language")&"_Contact_11")%> </p></td> <td><p> <input type="text" name="FromPhone" size="35" maxlength="70" value="<%=pcf_FillFormField ("FromPhone", pcv_isPhoneRequired) %>"> <% pcs_RequiredImageTag "FromPhone", pcv_isPhoneRequired %> </p></td> </tr> <tr> <td><p> <%response.write dictLanguage.Item(Session("language")&"_Contact_12")%> </p></td> <td><p> <input type="text" name="FromCompany" size="35" maxlength="70" value="<%=pcf_FillFormField ("FromCompany", pcv_isCompanyRequired) %>"> <% pcs_RequiredImageTag "FromCompany", pcv_isCompanyRequired %> </p></td> </tr>
Please offer pointers if you can, here is the code snippet I'm using (the red code is what I modified/added) on the contact.asp page:
'///////////////////////////////////////////////////// '// Check for Validation Errors '///////////////////////////////////////////////////// If pcv_intErr>0 Then response.redirect pcStrPageName&"?msg="&pcv_strGenericPageError else CustName=Session("pcSFFromName") CustEmail=Session("pcSFFromEmail") CustPhone=Session("pcSFFromPhone") CustCompany=Session("pcsFFromCompany") MsgTitle=dictLanguage.Item(Session("language")&"_Contact_9") & Session("pcSFMsgTitle") MsgTitle=replace(MsgTitle,"''","'") '// Add variables to body MsgBody=MsgBody & dictLanguage.Item(Session("language")&"_Contact_6") & CustName & vbcrlf MsgBody=MsgBody & dictLanguage.Item(Session("language")&"_Contact_7") & CustEmail & vbcrlf '//Added fields to the contact page MsgBody=MsgBody & dictLanguage.Item(Session("language")&"_Contact_11") & CustPhone & vbcrlf MsgBody=MsgBody & dictLanguage.Item(Session("language")&"_Contact_12") & CustCompany & vbcrlf '// IF customer is logged in, add more information if pIdCustomer>0 then '// Generate link to customer edit page SPath1=Request.ServerVariables("PATH_INFO") mycount1=0 do while mycount1<2 if mid(SPath1,len(SPath1),1)="/" then mycount1=mycount1+1 end if if mycount1<2 then SPath1=mid(SPath1,1,len(SPath1)-1) end if loop SPathInfo="http://" & Request.ServerVariables("HTTP_HOST") & SPath1 if Right(SPathInfo,1)="/" then else SPathInfo=SPathInfo & "/" end if dURL=SPathInfo & scAdminFolderName & "/login_1.asp?redirectUrl=" & Server.URLEnCode(SPathInfo & scAdminFolderName & "/modcusta.asp?idcustomer=" & pIdCustomer) MsgBody=MsgBody & dictLanguage.Item(Session("language")&"_Contact_8") & dURL & vbcrlf & vbcrlf end if '// END IF customer is logged in MsgBody=MsgBody & dictLanguage.Item(Session("language")&"_Contact_5") & vbcrlf & vbcrlf MsgBody=MsgBody & Session("pcSFMsgBody") MsgBody=replace(MsgBody,"''","'") call sendmail (CustName,CustEmail,scFrmEmail,CustPhone,CustCompany,MsgTitle,MsgBody) pcv_intSuccess=1 End If
End If
if pIdCustomer>0 AND msg="" then call openDb() query="SELECT name,lastName,email FROM customers WHERE idCustomer=" &pIdCustomer set rs=Server.CreateObject("ADODB.Recordset") set rs=conntemp.execute(query) if err.number <> 0 then set rs=nothing call closeDb() response.redirect "techErr.asp?error="& Server.Urlencode("Error on contact.asp: "&Err.Description) end if Session("pcSFFromName")=rs("name") & " " & rs("lastName") Session("pcSFFromEmail")=rs("email") Session("pcSFMsgTitle")="" Session("pcSFMsgBody")="" set rs=nothing call closeDB() end if
|
Replies:
Posted By: Hamish
Date Posted: 15-April-2009 at 4:38am
Hi, Unless you have also changed includes/sendmail.asp you will need to revert that line to it's original text as it only takes 5 parameters.
call sendmail (CustName,CustEmail,scFrmEmail,MsgTitle,MsgBody)
The phone and company name have already been incorporated into the message body.
------------- Editing ProductCart Code?
See http://wiki.earlyimpact.com/developers/editcode" rel="nofollow - WIKI Guidelines for Editing ProductCart's ASP Source Code
|
Posted By: Hamish
Date Posted: 15-April-2009 at 4:44am
If you had modified sendmail as well and that's not the problem, check that ANY emails are being sent. You can do this from the control panel "settings > Email Settings : Test your settings". I would also advise checking "Help > Troubleshooting utility" whenever a major change such as switching servers has occurred (along with other testing).
------------- Editing ProductCart Code?
See http://wiki.earlyimpact.com/developers/editcode" rel="nofollow - WIKI Guidelines for Editing ProductCart's ASP Source Code
|
Posted By: mthierfelder
Date Posted: 15-April-2009 at 11:08am
I had not modified sendmail. I took a look at it and am not seeing the variables that are present in contact.asp. For instance contact.asp calls the message MsgText, but sendmail calls it BodyText. Also, I don't see any reference in sendmail.asp to CustName, or CustEmail. Could you be more specific as to how I add in the two new fields to sendmail? We are using CDOSYS for our mailer...this is the block:
Function sendMail(fromName, from, rcpt, subject, body)
if scEmailComObj="CDOSYS" then Dim mail Dim iConf Dim Flds 'on error resume next Set mail = CreateObject("CDO.Message") 'calls CDO message COM object Set iConf = CreateObject("CDO.Configuration") 'calls CDO configuration COM object Set Flds = iConf.Fields Flds( "http://schemas.microsoft.com/cdo/configuration/sendusing") = 1 'tells cdo we're using the local smtp service, use "2" if not local Flds("http://schemas.microsoft.com/cdo/configuration/smtpserver")=scSMTP Flds("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 Flds("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 20 Flds("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "c:\inetpub\mailroot\pickup" 'verify that this path is correct Flds.Update 'updates CDO's configuration database 'if smtp authentication is required '================================== if scSMTPAuthentication="Y" then Flds("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 ' cdoBasic Flds("http://schemas.microsoft.com/cdo/configuration/sendusername") = scSMTPUID Flds("http://schemas.microsoft.com/cdo/configuration/sendpassword") = scSMTPPWD Flds.Update 'updates CDO's configuration database end if '================================== Set mail.Configuration = iConf 'sets the configuration for the message mail.To = rcpt mail.From = from mail.Subject = subject If session("News_MsgType")="1" Then HTMLBody=HTML mail.HTMLBody = body Else TextBody=Plain mail.TextBody = body End If mail.Send 'commands CDO to send the message if err then pcv_errMsg = err.Description end if set mail=nothing End If
|
Posted By: Hamish
Date Posted: 15-April-2009 at 11:23am
Hi,
The parameters passed are positional, so the value of "msgText" is passed to Sendmail into variable "body".
You don't need to, in fact should not, change the sendmail code. The phone number and company name will appear in the text of the message due to the other changes you have done.
------------- Editing ProductCart Code?
See http://wiki.earlyimpact.com/developers/editcode" rel="nofollow - WIKI Guidelines for Editing ProductCart's ASP Source Code
|
Posted By: mthierfelder
Date Posted: 15-April-2009 at 11:38am
Ok, so if I understand correctly you are saying that messages should be sending given the changes I have made, and the company and phone should be passed in that email? because the messages are not being sent right now.
I have tested the sendmail in the admin and it is working. The default contact.asp page does work and sends mail but still having trouble getting the two new fields going.
|
Posted By: Hamish
Date Posted: 15-April-2009 at 11:42am
Hi, Just a thought, did you add other lines of code, such as setting the pcv_isPhoneRequired and calling pcs_ValidateTextField for the two new fields?
------------- Editing ProductCart Code?
See http://wiki.earlyimpact.com/developers/editcode" rel="nofollow - WIKI Guidelines for Editing ProductCart's ASP Source Code
|
Posted By: mthierfelder
Date Posted: 15-April-2009 at 11:50am
Do you mean like this?:
pcv_isNameRequired=True pcv_isEmailRequired=True pcv_isTitleRequired=True pcv_isBodyRequired=True 'New fields added to contact form pcv_isCompanyRequired=False pcv_isPhoneRequired=False
if request.form("updatemode")="1" then
'//set error to zero pcv_intErr=0
pcs_ValidateEmailField "FromEmail", pcv_isEmailRequired, 0 pcs_ValidateTextField "FromName", pcv_isNameRequired, 0 pcs_ValidateTextField "MsgTitle", pcv_isTitleRequired, 0 pcs_ValidateTextField "MsgBody", pcv_isBodyRequired, 0 'New fields added to contact form pcs_ValidateTextField "FromPhone", pcv_isPhoneRequired, 0 pcs_ValidateTextField "FromCompany", pcv_isCompanyRequired, 0
|
Posted By: mthierfelder
Date Posted: 15-April-2009 at 12:22pm
I figured it out. On this line:
call sendmail (CustName,CustEmail,scFrmEmail,MsgTitle,MsgBody)
I had added CustPhone,CustCompany which didn't work, I think because sendmail didn't know what to do with those two things since it only has the original 5 variables.
Anyway thanks for your support.
|
Posted By: Hamish
Date Posted: 15-April-2009 at 12:24pm
That's just what I said to do in my first post :-)
------------- Editing ProductCart Code?
See http://wiki.earlyimpact.com/developers/editcode" rel="nofollow - WIKI Guidelines for Editing ProductCart's ASP Source Code
|
Posted By: RobertZ
Date Posted: 21-April-2009 at 11:54pm
Another handy thing is changing the scFrmEmail to (eg) scRMAEmail.
Then Adding a line to include/emailsetting.asp
private const scRMAEmail=" mailto:Whereever@youwant.it - Whereever@youwant.it "
(NO NOT CHANGE OR DELETE scFrmEmail in this file)
Then you can get this email to go whereever you want rather than the main PC admin email address.
Which fixes the issue of having everything going to one main PC email (Which is a pain). We have set up
main PC admin email : sales@
Helpdesk one : helpdesk@
contact form : contact@
RMA form : RMA@
Rob
|
|