how to get value from js alert message to store in PHP varible?

General discussions related to php

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 11
Joined: Sun Sep 11, 2016 8:38 am

Sun May 13, 2018 3:34 am

I am trying to learn php and js. Here I am trying to put a value in php varible from javascript alert message input box but failed.
here what I have done so far,

Code: Select all

// <?PHP and other variable is here....

			function number{
				if (fail == "") {
					number = prompt('Please enter Phone Number')
					if (number == "" || number == null) { 
						alert(' You have not specified the Phone Number. Please try again.'); 
						return false;
					else {
						return true;
				else { alert(fail); return false; }
So, actually how I can store the value from js alert to php varible? help me. Thanks for your valuable time and opinion.

php-forum Fan User
php-forum Fan User
Posts: 590
Joined: Fri Apr 01, 2016 2:18 am

Sun May 13, 2018 4:17 am

As PHP scripts only run when triggered, you have to make a request to your script's URL with the parameter in the URL or via POST / form. Or you take AJAX.

Post Reply