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

Monday, May 16, 2022

[FIXED] How to get the textbox value in PHP?

 May 16, 2022     dom-events, javascript, php     No comments   

Issue

On my page I have one textbox and one button.
-- on the button click event.
-- one function will be called.
Now,
How to get that value of textbox and store in PHP variable? This should be done in that function which we will call on button click.


Solution

You'll have to know that Javascript and PHP run on two different servers. So they can not communicate directly.

You'll basicly have two options:

POST the value

Make a form with a post action, submit the form, and you can access the value in PHP with the $_POST array

Disadvantage is that the browser leaves the page to submit the form, but it doesn't require javascript.

Use AJAX

Get the value in Javascript, make an XMLHTTPRequest to the server, and you can access the variable too via $_GET or $_POST, depending on how you sent the value.



Answered By - Ikke
Answer Checked By - Katrina (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