NetTalk Central

Author Topic: Calling NetWebForm from within embed code  (Read 3098 times)

Johan van Zyl

  • Full Member
  • ***
  • Posts: 180
  • jvz
    • View Profile
    • Email
Calling NetWebForm from within embed code
« on: November 11, 2014, 01:28:38 PM »
Hi

A. LoginForm
in ValidateUpdate 2 End
After the User has been validated - i.e. legally logged in, depending what type of User, I would like to call a form populated with THAT users details to be edited by the User himself. How do I call that form inside code and how do I ensure that the form is populated with that users details?
The login and password is validated against the People table which also contains all other details of the logged-in user. Therefore I will have the peopleguid in a Session Value, say called peopleguid.

B. After user is done  editing, upon leaving THAT form User must be logged out? How?
Johan van Zyl
Clarion 6.3 9058/C8 Gold/SQL/NetTalk WebServer

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11193
    • View Profile
Re: Calling NetWebForm from within embed code
« Reply #1 on: November 11, 2014, 09:10:13 PM »
>> How do I call that form inside code

You can set the "URL on Save" to be the form.

>> how do I ensure that the form is populated with that users details

The easiest way is to set the settings on the Form, on the Advanced tab, to "fetch" the record. Usually sing some SessionValue (set in the Login) so it knows which record to load.


If this isn't clear join us on the webinar this week and we can step through it.

>> After user is done  editing, upon leaving THAT form User must be logged out?

In form, PostUpdate routine

p_web.SetSessionLoggedIn(0)

cheers
Bruce

Johan van Zyl

  • Full Member
  • ***
  • Posts: 180
  • jvz
    • View Profile
    • Email
Re: Calling NetWebForm from within embed code
« Reply #2 on: November 11, 2014, 10:15:38 PM »
Thx Bruce,
I have two types of people who will log in.
Normals Users that would probably only ever  be staff members of medxinfo and those who are in the People table.
When logging in the code will use the loc:login to distinguish who is logging in
if len(clip(loc:login)) = 10 and sub(loc:login,1,1) = 0 !probably a cell number 
    clear(people)
    peo:cellno = clip(loc:login)
    if Access:people.TryFetch(peo:cellno_ukey)
...
if a User logs in then after login the LoginForm can call IndexPage or whatever BUT if logging in with cellno then the PeopleNetWebForm must be called populated with that persons details. Upon Saving must be logged out, before they can cause any damage.,
I guess the question is: can there be a choice of URL on Save depending on what type of user logged in.
 ,,,
Johan van Zyl
Clarion 6.3 9058/C8 Gold/SQL/NetTalk WebServer

MyBrainIsFull

  • Full Member
  • ***
  • Posts: 134
    • View Profile
Re: Calling NetWebForm from within embed code
« Reply #3 on: November 17, 2014, 12:49:55 PM »
Try this Johan, this is how I am testing for three levels of user
Admin and Suppliers are in one table
Students are in another table

My login will take the user to one of two pages

The key is the  p_web.Script( p_web.WindowOpen(   SomePage   ))
and some page can be 'blah.htm' where you want a static page to go to
or it can be 'subdomain.yoururl.com'


-------------------------------------------------------------

access:student.Open()
access:supplier.Open()                 
access:student.UseFile()
access:supplier.UseFile()       

Loc:Login    = p_web.Gsv('Loc:Login')
Loc:Password = p_web.Gsv('Loc:Password')

Stu:WebUserName =Loc:Login
Stu:WebPassword = Loc:Password           

Sup:WebUserName =Loc:Login
Sup:WebPassword = Loc:Password

if Access:Supplier.Fetch(Sup:Login_K) = 0           ! Login = Stu:WebUserName, Stu:WebPassword
 if Sup:LoginLevel=0; Sup:LoginLevel=5;.               
 p_web.SetSessionLevel(Sup:LoginLevel)                                                    !!<-----    5
 p_web.ssv( 'LoginLevel', Sup:LoginLevel)
         
if  Sup:LoginLevel=5
   p_web.ssv( 'IndexTitle', 'Welcome Supplier ' & clip(Sup:Firstname) & ', '& Sup:LastName)
   p_web.ssv( 'LoggedInAs', 'Supplier '               & clip(Sup:Firstname) & ', '& Sup:LastName)
ELSE
   p_web.ssv( 'IndexTitle', 'Welcome Admin ' & clip(Sup:Firstname) & ', '& Sup:LastName)
   p_web.ssv( 'LoggedInAs', 'Admin '               & clip(Sup:Firstname) & ', '& Sup:LastName)
END   

 p_web.ValidateLogin()
 p_web.SetSessionValue('hash',0)           
 p_web.SetSessionLoggedIn(1)
 if Sup:WebTheme~=''; p_web.ChangeTheme( Sup:WebTheme);.
 
 p_web.Script( p_web.WindowOpen(   SomePage   ))      !!<<<<<<  Read this Johan   
                   
elsif  Access:student.Fetch(Stu:Login_K) =0
loc:invalid = 'Loc:Login'
p_web.SetValue('retry',p_web.site.LoginPage)
p_web.DeleteCookie('loc__login')
p_web.DeleteCookie('loc__password')     
p_web.SetSessionLevel(1)
p_web.ssv( 'LoginLevel',1)     

p_web.ssv( 'IndexTitle', 'Welcome Student ' & clip(Stu:Firstname) & ', '& Stu:LastName)
p_web.ssv( 'LoggedInAs', 'Student ' & clip(Stu:Firstname) & ', '& Stu:LastName)
p_web.ValidateLogin()
p_web.Ssv('hash',0)             
       
p_web.Script( p_web.WindowOpen(  SomeOtherPage  ))        !!<<<<<<  Read this Johan
p_web.SetSessionLoggedIn(1)
 if Stu:WebTheme~=''; p_web.ChangeTheme( Stu:WebTheme);.
 
else
loc:Alert = 'Login Failed - Try Again.'
loc:invalid = 'Loc:Login'
p_web.SetSessionLevel(0)          ! set the session level, and any other session variables based on the logged in user.                 
p_web.SetSessionValue('hash',0)         ! clear the hash, so this login can't get "replayed".
p_web.ssv( 'LoggedInAs', 'Failed')
p_web.SetSessionLoggedIn(false)
End

access:student.Close()
access:supplier.Close()

Johan van Zyl

  • Full Member
  • ***
  • Posts: 180
  • jvz
    • View Profile
    • Email
Re: Calling NetWebForm from within embed code
« Reply #4 on: November 20, 2014, 10:45:14 AM »
Thx!
This looks like what I was looking for!

Later:
Wow - that works well!
So far I have only used this line of yours
p_web.Script( p_web.WindowOpen(  SomePage  ))        !!<<<<<<  Read this Johan
should be
p_web.Script( p_web.WindowOpen(  'SomePage'  ))
off course<g>
THX! 

« Last Edit: November 20, 2014, 11:39:43 AM by Johan van Zyl »
Johan van Zyl
Clarion 6.3 9058/C8 Gold/SQL/NetTalk WebServer