PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, May 19, 2022

[FIXED] How to call web-service call in PHP when click on login button

 May 19, 2022     codeigniter, dom-events, javascript, php, web-services     No comments   

Issue

I am a newbie to the Web-service area.
My question is I am using web service for login. When user click on login button, I have to call web-service and if web-service give me success reply then user go to home page.

I am confused with what to do; whether use on-click method means user click on login button call Javascript function which having call for web-service or any other thing available in PHP i.e. how to call in PHP when user click on login button, because after success I have to transfer user on homepage.

Then which method I have to follow:

  1. use JavaScript call for web service OR
  2. use PHP call for web-service but I don't know how to call when user click on button

because i want set session for user , when i use java-script function then how the userid is pass to php for storing in the session.

i am using codeigniter


Solution

I am not a php guy but this might help you make a better decision: As you said you have two options:

Option 1: (Bad Idea) 1. User Clicks login button 2. A JavaScript method is called, which makes a Ajax Call to authentication service 3. If authenticated, you redirect user to Home page

Option 2: 1. On Login click, you take the user to a controller. 2. Controller calls authentication 3. Responses with a redirect if successful.

Now why i say option 1 is bad idea because doing it in JS has potential threat, as some one can bypass the authentication to get access to login.

So doing it as you said with a 'php' call is a better idea.



Answered By - Shaunak
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing