Jump to content

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


prohor

Recommended Posts

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,

// <?PHP and other variable is here....
$number='number'; 

<script>
			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 {
						
						document.getElementById("number").value;
						
						return true;
					}
				}
				else { alert(fail); return false; }
			}
		</script>

So, actually how I can store the value from js alert to php varible? help me. Thanks for your valuable time and opinion.

Link to comment
Share on other sites

The only way to get a value from JS to your PHP is to send a request from the JS to your server. This could either be through a form submission or an AJAX request

 

PHP is run on the server, whereas JS is run on the client, essentially 2 completely different places that each have no idea about the other.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.