We can use variable value in JavaScript in PHP, but we can not directly use value in client side (JavaScript) in server side PHP.
Here is simple solution to use value in client side (JavaScript) variable in server side PHP varaible :
we need to pass values in JavaScript to server side using location.href JavaScript function in the url……
location.href=”blog_app.php?name=” +name;
Here is example code
note : create single blog_app.php php file, add following sample codes to test this.
<html> <head> <script language=javascript> function promptor() { var name=prompt("Please enter your Email","Enter your email"); // passing javascript if (name!=null && name!="") { location.href="blog_app.php?name=" +name; } else { document.writeln("please fill your email"); } } </head> <body> <input name="Downlaod" type="submit" id="Downlaod" >