Link to home
Start Free TrialLog in
Avatar of Zac123
Zac123Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Element FIRST_NAME is undefined in form - creat new member form

Hello Experts,

i have a form that submits to paypal, once the user has paid via PP they are returned to my success page which has a 'New Member' registration form.
The form fields are mostly populated by the data that is sent back from PP. thinks like name, email etc etc.
this all works fine... but....

when the user clicks on the confirm buitton this should then complete the whole proccess by submitting the data thats in the form and therefore creating a new user to my site.

its all pretty simply stuff, but what happens is the form is not subbmitted correctly, i get this error:

Element FIRST_NAME is undefined in form

i have pasted the code below, can anyone see what i'm doing wrong or have to got any suggestions of what to try?
<input type="text" id="firstName" class="text" name="firstname" value=" #HTMLEditFormat(request.userBean.getfname())#<cfoutput>#Form.first_name#</cfoutput>" required="true" message="The 'First Name' field is required." maxlength="50"/>

Open in new window

Avatar of erikTsomik
erikTsomik
Flag of United States of America image

how that field beeing passed from PP, maybe you need to use url variable rather than form variable
Avatar of Zac123

ASKER

hmm, how can i find our how its being passed? ive used a cfdump to tell me what data is being passed.

if i were to use a url variable, how would this look in the code below?

<input type="text" id="firstName" class="text" name="firstname" value=" #HTMLEditFormat(request.userBean.getfname())##Form.first_name#" required="true" message="The 'First Name' field is required." maxlength="50"/>

Avatar of Zac123

ASKER

sorry that didnt past correctly because i didnt use the code tags:


<input type="text" id="firstName" class="text" name="firstname" value=" #HTMLEditFormat(request.userBean.getfname())#<cfoutput>#Form.first_name#</cfoutput>" required="true" message="The 'First Name' field is required." maxlength="50"/>
 

Open in new window

I am not sure if you can use reuired in regular <input  i always thought it is a property od CF tags
Avatar of Zac123

ASKER

ok we'll i'll try and take that out, but as to my other question, how would i use a URL variable and what would it look like in the code below:


<input type="text" id="firstName" class="text" name="firstname" 
value=" #HTMLEditFormat(request.userBean.getfname())#<cfoutput>#Form.first_name#</cfoutput>" required="true" message="The 'First Name' field is required." 
maxlength="50"/>

Open in new window

so on you previous page you have submitttion form so when it coming back you need to say

So once it get to your page then you can say
<input type="text" id="firstName" class="text" name="firstname"
value=" #HTMLEditFormat(request.userBean.getfname())##url.username#" required="true" message="The 'First Name' field is required."
maxlength="50"/>
Avatar of Zac123

ASKER

hang on a minuite you've lost me there. let me just explain what i have so far....

page 1, collects users info and submits to PP

PP page, the PP form is pre-populated with the data from page 1

page 2, the user complets the purchase on the PP page then is returned to page 2 where the form fields are pre-populated with the data sent back from PP.  i.e #Form.First_name# and so on.

the user then creates a password on page and clicks on submit. it is at this point that the error is thown up.




so you are saying...

i ned to add a cflocation.... to what page?
so the form 2 returns the values so you want to prepopulate the fileds with the returned values
Avatar of Zac123

ASKER

yes thats correct,

what is confusing though is that the form does appear to be prepopulated. its only when i click on submit that the error is thrown up.

take a look...

http://www.getfreeland.co.uk/getfreeland/index.cfm/join-now/

click on 'get access now'

then for the sandbox user name type:     zacwin_1215366055_ biz@msn.com

for the password type 12345678

complete the process until you are returned to the web-site then create a password and click on create profile. then you will see what is happening
If I click on the get access now nothing is happening
Avatar of Zac123

ASKER

try it in Fire Fox. i'm having some IE issues
still can not login
Email: Please enter a valid email address. UTF-8 email addresses are not currently supported. Emails must be in the format: username@domain.com
Avatar of gdemaria
The error says Element FIRST_NAME is undefined in form
but in your input tag you are naming it FIRSTNAME (with no _ )

So the page you're submitting to is expecting FIRST_NAME, but your passing it FIRSTNAME
Avatar of Zac123

ASKER

yes unfortunatly i cant chnage the FIRSTNAME to FIRST_NAME as i dont have access to the DB. i'm using a CMS, so i need to get over this somehow. how can i do this?
Avatar of Zac123

ASKER

basically PP are sending FIRST_NAME but my db is expecting FIRSTNAME.

its a problem i'm not sure how to overcome
ASKER CERTIFIED SOLUTION
Avatar of gdemaria
gdemaria
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Zac123

ASKER

thanks, i think thats the answer. i'm having trouble locating the SQL though. i'm using an opensource cms and i just cant find where the sql UPDATE or INSERT is. there is masses and masses of files. ive looked for clues in the page but cant see any.

i've posted the whole page below, can you see where i should look?
<cfsilent>
<cfif not isdefined('request.userBean')>
<cfset request.userBean=application.userManager.read(listFirst(getAuthUser(),"^")) />
</cfif>
<cfparam name="msg" default="Account Information (*Required)">
<cfparam name="request.categoryID" default="">
</cfsilent>
<cfoutput>
 
<h2><cfif getAuthUser() eq ''>Create Profile<cfelse>
Edit Profile for #listGetAt(getAuthUser(),2,'^')#</cfif></h2>
<div id="svEditProfile">
<cfif not(structIsEmpty(request.userBean.getErrors()) and request.doaction eq 'createprofile')>
 
<cfif not structIsEmpty(request.userBean.getErrors()) >
 <div id="editProfileMsg" class="required">#application.utility.displayErrors(request.userBean.getErrors())#</div>
<cfelse>
  <div id="editProfileMsg" class="required">#msg#</div>
</cfif>
	<!--- <a id="editSubscriptions" href="##">Edit Email Subscriptions</a> --->
	<form name="profile" id="profile" action="#application.configBean.getIndexFile()#?nocache=1" method="post" onsubmit="return validate(this);"  enctype="multipart/form-data">
	<fieldset>
	<legend>Contact Information</legend>
	<ul>
	<li>
	<label for="firstName">First Name<span class="required">*</span></label>
	<input type="text" id="firstName" class="text" name="first_name" value=" #HTMLEditFormat(request.userBean.getfname())#<cfoutput>#Form.first_name#</cfoutput>" required="true" message="The 'First Name' field is required." maxlength="50"/>
	</li>
	<li>
	<label for="lastName">Last Name<span class="required">*</span></label>
	<input type="text" id="lastName" class="text" name="lastname" value="<cfoutput>#Form.last_name#</cfoutput>" required="true" message="The 'Last Name' field is required." maxlength="50"/>
	</li>
	<li>
	<label for="usernametxt">Username<span class="required">*</span></label>
	<input name="username" id="usernametxt" type="text" value="<cfoutput>#Form.payer_email#</cfoutput>" class="text"  required="yes" message="The 'Username' field is required." maxlength="50">
	</li>	
	
	<!---<li>
	<label for="companytxt">Organization</label>
	<input name="company" id="companytxt" type="text" value="" class="text" maxlength="50"/>
	</li>--->
 
       
<cfif getAuthUser() eq ''>
	<li>
	<label for="emailtxt">Email<span class="required">*</span></label>
	<input name="email" id="emailtxt" validate="email" type="text" value="<cfoutput>#Form.payer_email#</cfoutput>" class="text"  required="true" message="The 'Email' field must be in a valid email format." maxlength="50">
	</li>
	<li>
	<label for="email2xt">Email Confirm<span class="required">*</span></label>
	<input name="email2" id="email2txt" type="text" value="<cfoutput>#Form.payer_email#</cfoutput>" class="text" validate="match" matchfield="email" required="true" message="The 'Email' and 'Email Confirm' fields must match." maxlength="50">
	<li>
	<label for="passwordtxt">Password<span class="required">*</span></label>
	<input name="passwordNoCache" validate="match" matchfield="password2" type="password" value="" class="text"  message="The 'Password' and 'Password Confirm' fields must match." maxlength="50">
	</li>
	<li>
	<label for="password2txt">Password Confirm<span class="required">*</span></label>
	<input  name="password2" id="password2txt" type="password" value="" required="true" class="text"  message="The 'Password Confirm' field is required." maxlength="50">
	</li>
<cfelse>
 	 <li>
	<label for="emailtxt">Email<span class="required">*</span></label>
	<input name="email" id="emailtxt" validate="email" type="text" value="#htmlEditFormat(request.userBean.getEmail())#" class="text"  required="true" message="The 'Email' field must be in a valid email format." maxlength="50">
	</li>
 
	<li>
	<label for="passwordtxt">Password</label>
	<input name="passwordNoCache" validate="match" matchfield="password2" type="password" value="" class="text"  message="The 'Password' and 'Password Confirm' fields must match." maxlength="50">
	</li>
	<li>
	<label for="password2txt">Password Confirm</label>
	<input  name="password2" id="password2txt" type="password" value="" required="false" class="text"  message="The 'Password Confirm' field is required." maxlength="50">
	</li>
 
</cfif>
 
</ul>
</fieldset>
 
<!---
<fieldset>
	<legend>Upload Your Photo</legend>
		<ul class="columns2">
			<li class="col">
				<p class="inputNote">Photo must be JPG format optimized for up to 150 pixels wide.</p>
					<input type="file" name="newFile" validate="regex" regex="(.+)(\.)(jpg|JPG)" message="Your logo must be a .JPG" value=""/>
			</li>
			<li class="col">
				<cfif len(request.userBean.getPhotoFileID())>
							<img src="#application.configBean.getContext()#/tasks/render/small/?fileid=#request.userBean.getPhotoFileID()#" alt="your photo" />
			<input type="checkbox" name="removePhotoFile" value="true"> Remove current logo 
			</cfif>
			</li>
		</ul>
</fieldset>
--->
 
<!--- extended attributes as defined in the class extendtion manager --->
<cfsilent>
<cfset extendSets=application.classExtensionManager.getSubTypeByName(request.userBean.gettype(),request.userBean.getsubtype(),request.siteid).getExtendSets(true) />
</cfsilent>
<cfif arrayLen(extendSets)>
<cfloop from="1" to="#arrayLen(extendSets)#" index="s">	
	<cfset extendSetBean=extendSets[s]/>
	<fieldset>
	<legend>#extendSetBean.getName()#</legend>
		<input name="extendSetID" type="hidden" value="#extendSetBean.getExtendSetID()#"/>
		<cfsilent>
		<cfset attributesArray=extendSetBean.getAttributes() />
		</cfsilent>
		<ul>
		<cfloop from="1" to="#arrayLen(attributesArray)#" index="a">	
		<cfset attributeBean=attributesArray[a]/>
		<cfset attributeValue=request.userBean.getExtendedAttribute(attributeBean.getAttributeID(),true)/>
			<li>
				<cfif not listFind("TextArea,MultiSelectBox",attributeBean.getType())>
					<label for="ext#attributeBean.getAttributeID()#"><cfif attributeBean.getRequired()><b>*</b></cfif>#attributeBean.getLabel()#<!--- <cfif len(attributeBean.gethint())><br/>#attributeBean.gethint()#</cfif> ---></label>
				<cfelse>
					<label for="ext#attributeBean.getAttributeID()#"><cfif attributeBean.getRequired()><b>*</b></cfif>#attributeBean.getLabel()#<cfif len(attributeBean.gethint())><br/>#attributeBean.gethint()#</cfif></label>
				</cfif>
		
			<cfif attributeBean.getType() neq 'TextArea'>		
				#attributeBean.render(attributeValue,true)#
				<cfif attributeBean.getType() neq "MultiSelectBox" and len(attributeBean.gethint())>
					<div class="inputBox rightCol" >
						<p class="fieldDescription">#attributeBean.gethint()#</p>
					</div>	
				</cfif>
				<cfif attributeBean.getType() eq "File" and len(attributeValue) and attributeValue neq 'useSavaDefault'>
					<div class="inputBox rightCol">
						<a href="#application.configBean.getContext()#/tasks/render/file/?fileID=#attributeValue#" target="_blank">[Download]</a> 
						<br/><input type="checkbox" name="extDelete#attributeBean.getAttributeID()#" value="true"/> 
						delete
					</div>
				</cfif>
			<cfelse>
			#attributeBean.render(attributeValue)#
			</cfif>	
			</li>
		</cfloop>
		</ul>
	</fieldset>
</cfloop>
</cfif>
 
<cfif getAuthUser() neq ''>
	<input name="submit" type="submit"  value="Update Profile" />
	<input type="hidden" name="userid" value="#listgetat(getAuthUser(),1,'^')#"/>
	<input type="hidden" name="doaction" value="updateprofile">
<cfelse>
	<input type="hidden" name="userid" value=""/>
	<input type="hidden" name="isPublic" value="1"/>
	<input type="hidden" name="inactive" value="0"/>
	<input name="submit" type="submit"  value="Create Profile"/>
	<input type="hidden" name="doaction" value="createprofile">
    <input type="hidden" name="groupid" value="F81EB252-1999-1A0D-62E94FB0B65504CB"/>
    
 
</cfif> 
 
<input type="hidden" name="siteid" value="#request.siteid#" />
<input type="hidden" name="returnURL" value="#request.returnURL#" />
<input type="hidden" name="display" value="editprofile">
 
 
</form>
</div>
 <script type="text/javascript">
<!--  
document.getElementById("profile").elements[0].focus();
-->
</script>
<cfelse>
<!--- This is where the script for a newly created account does if inactive is default to 1 for new accounts--->
<div id="editProfileMsg" class="required">Thank you for registering a new account. <br/>Your login information has been emailed to you.</div>
</cfif>
</cfoutput>

Open in new window

I see the problem - you have to play nicely with two external forces - PayPal and the CMS, both which use different names.  

Not sure which route is easier.  You could reverse the method we discussed and go with FIRST_NAME to be compatible with your CMS.   Then at the last minute pass FIRSTNAME to paypal.  But I suspect it is going to pass back FIRST_NAMe which you will then have to translate back to FIRSTNAME.   Oh boy.

To find your CMS sql ... there is an action "updateprofile" or "createprofile"  that you can look for.
Not sure if these have corredponding files someplace or what.  



Avatar of Zac123

ASKER

thanks, its actaully the otherway round, PP needs FIRST_NAME but the cms needs FIRSTNAME, but i dont suppose that makes any difference at this point.

ok i'll have a look for update/create profile.  

:-(
Avatar of Zac123

ASKER

a ha, i think i might have found something, can you take a look, there seems to be alot of it but it looks like it couild be it!  its not quite as i'm used to seeing, its a bit more complicated.
<cffunction name="create" returntype="void" access="public" output="false">
<cfargument name="userBean" type="any" />
 
 <cfquery  datasource="#variables.instance.configBean.getDatasource()#" username="#variables.instance.configBean.getDBUsername()#" password="#variables.instance.configBean.getDBPassword()#">
        INSERT INTO tusers  (UserID, RemoteID, s2, Fname, Lname, Password, PasswordCreated,
		Email, GroupName, Type, subType, ContactForm, LastUpdate, lastupdateby, lastupdatebyid,InActive, username,  perm, isPublic,
		company,jobtitle,subscribe,siteid,website,notes,mobilePhone,
		description,interests,photoFileID,keepPrivate,IMName,IMService,created,tags)
     VALUES(
         '#arguments.userBean.getuserid()#',
		 <cfqueryparam cfsqltype="cf_sql_varchar" null="#iif(arguments.userBean.getRemoteID() neq '',de('no'),de('yes'))#" value="#arguments.userBean.getRemoteID()#">,
		 #arguments.userBean.gets2()#, 
		 <cfqueryparam cfsqltype="cf_sql_varchar" null="#iif(arguments.userBean.getFname() neq '',de('no'),de('yes'))#" value="#arguments.userBean.getFname()#">,
		  <cfqueryparam cfsqltype="cf_sql_varchar" null="#iif(arguments.userBean.getLname() neq '',de('no'),de('yes'))#" value="#arguments.userBean.getLname()#">, 
         <cfqueryparam cfsqltype="cf_sql_varchar" null="#iif(arguments.userBean.getPassword() neq '',de('no'),de('yes'))#" value="#hash(arguments.userBean.getPassword())#">,
		 #createODBCDateTime(now())#,
		 <cfqueryparam cfsqltype="cf_sql_varchar" null="#iif(arguments.userBean.getEmail() neq '',de('no'),de('yes'))#" value="#arguments.userBean.getEmail()#">,
         <cfqueryparam cfsqltype="cf_sql_varchar" null="#iif(arguments.userBean.getGroupName() neq '',de('no'),de('yes'))#" value="#arguments.userBean.getGroupName()#">, 
         #arguments.userBean.getType()#,
		 <cfqueryparam cfsqltype="cf_sql_varchar" null="#iif(arguments.userBean.getSubType() neq '',de('no'),de('yes'))#" value="#arguments.userBean.getSubType()#">, 
        <cfqueryparam cfsqltype="cf_sql_longvarchar" null="#iif(arguments.userBean.getContactForm() neq '',de('no'),de('yes'))#" value="#arguments.userBean.getContactForm()#">,
		 #createodbcdatetime(now())#,
		 <cfqueryparam cfsqltype="cf_sql_varchar" null="#iif(arguments.userBean.getLastUpdateBy() neq '',de('no'),de('yes'))#" value="#arguments.userBean.getLastUpdateBy()#">,
		 <cfqueryparam cfsqltype="cf_sql_varchar" null="#iif(arguments.userBean.getLastUpdateById() neq '',de('no'),de('yes'))#" value="#arguments.userBean.getLastUpdateByID()#">,
		 #arguments.userBean.getInActive()#,
		 <cfqueryparam cfsqltype="cf_sql_varchar" null="#iif(arguments.userBean.getUsername() neq '',de('no'),de('yes'))#" value="#arguments.userBean.getUsername()#">,
		  #arguments.userBean.getperm()#,
		  #arguments.userBean.getispublic()#,
		   <cfqueryparam cfsqltype="cf_sql_varchar" null="#iif(arguments.userBean.getCompany() neq '',de('no'),de('yes'))#" value="#arguments.userBean.getCompany()#">,
		   <cfqueryparam cfsqltype="cf_sql_varchar" null="#iif(arguments.userBean.getJobTitle() neq '',de('no'),de('yes'))#" value="#arguments.userBean.getJobTitle()#">, 
		  #arguments.userBean.getsubscribe()#,
		   <cfqueryparam cfsqltype="cf_sql_varchar" null="#iif(arguments.userBean.getSiteID() neq '',de('no'),de('yes'))#" value="#arguments.userBean.getSiteID()#">,
		  <cfqueryparam cfsqltype="cf_sql_varchar" null="#iif(arguments.userBean.getWebsite() neq '',de('no'),de('yes'))#" value="#arguments.userBean.getWebsite()#">,
		 <cfqueryparam cfsqltype="cf_sql_longvarchar" null="#iif(arguments.userBean.getNotes() neq '',de('no'),de('yes'))#" value="#arguments.userBean.getNotes()#">,
		 <cfqueryparam cfsqltype="cf_sql_varchar" null="#iif(arguments.userBean.getMobilePhone() neq '',de('no'),de('yes'))#" value="#arguments.userBean.getMobilePhone()#">,
		  <cfqueryparam cfsqltype="cf_sql_varchar" null="#iif(arguments.userBean.getDescription() neq '',de('no'),de('yes'))#" value="#arguments.userBean.getDescription()#">,
		 <cfqueryparam cfsqltype="cf_sql_varchar" null="#iif(arguments.userBean.getInterests() neq '',de('no'),de('yes'))#" value="#arguments.userBean.getInterests()#">,
		 <cfqueryparam cfsqltype="cf_sql_varchar" null="#iif(arguments.userBean.getPhotoFileID() neq '',de('no'),de('yes'))#" value="#arguments.userBean.getPhotoFileID()#">,
		#arguments.userBean.getKeepPrivate()#,
		 <cfqueryparam cfsqltype="cf_sql_varchar" null="#iif(arguments.userBean.getIMName() neq '',de('no'),de('yes'))#" value="#arguments.userBean.getIMName()#">,
		 <cfqueryparam cfsqltype="cf_sql_varchar" null="#iif(arguments.userBean.getIMService() neq '',de('no'),de('yes'))#" value="#arguments.userBean.getIMService()#">,
		 #createODBCDAteTime(now())#,
		 <cfqueryparam cfsqltype="cf_sql_varchar" null="#iif(arguments.userBean.getTags() neq '',de('no'),de('yes'))#" value="#arguments.userBean.getTags()#">
		 )
		 
   </CFQUERY>
   
  
   <cfset createUserMemberships(arguments.userBean.getUserID(),arguments.userBean.getGroupID()) />
   <cfset clearBadMembeships(arguments.userBean) />
   <cfset createUserInterests(arguments.userBean.getUserID(),arguments.userBean.getCategoryID()) />
   <cfset createTags(arguments.userBean) />
  
 
</cffunction>

Open in new window

Yea, that's good news and bad news.

It looks like the right place, but it also looks like they are keeping all the data in a CFC (the argument is passed in "userBean").  I think that just makes it more complex as you have no idea how many different areas you are going to be effecting if you modify this code.  

Somewhere else, the form post you are doing has to populate that cfc.   The form submits to some index file apparently...
 
as indicated here...

<form name="profile" id="profile" action="#application.configBean.getIndexFile()#?nocache=1" method="post" onsubmit="return validate(this);"  enctype="multipart/form-data">


that must be the main index.cfm file it's referring to.

perhaps finding this is a better place to do it... I don't think you want to try and modify the cfc and sql - it will break other places; we want to keep it form specific
Avatar of Zac123

ASKER

ok well the main index.cfm simply looks like this:

[code][/code]


so you might think well lets have a look at /contentserverlocal.cfm

that looks like this: (which is even more confusing, maybe i'm i'm just trying to make something do something it simply wasnt designed to do?)


<cfsilent>
<cfset siteID = listGetAt(cgi.script_name,listLen(cgi.script_name,"/")-1,"/") />
<cfparam name="url.path" default="" />
 
<cfif left(cgi.path_info,1) eq "/" and cgi.path_info neq "/">
<cfset url.path=right(cgi.path_info,len(cgi.path_info)-1) />
</cfif>
 
<cfif len(url.path) and right(cgi.path_info,1) neq "/"  and right(cgi.path_info,len(application.configBean.getIndexfile())) neq application.configBean.getIndexfile()>
<cfset url.path=url.path  & "/" />
</cfif>
 
<cfif siteID eq listFirst(url.path,"/")>
	<cfset url.path="#application.configBean.getStub()#/#url.path#" />
<cfelse>
	<cfset url.path="#application.configBean.getStub()#/#siteID#/#url.path#" />
</cfif>
</cfsilent>
<cfinclude template="contentServer.cfm">

Open in new window