is it possible to use php as a client side scripting language?
if it possible, how can i read values releated with the form?

This, sir, is exactly what JavaScript was created for.

Here is an example of how to access a form element with the name "input1":

<html>
<body>
<form onSubmit="return getFormValue()">
	<input type="text" name="input1"/><br/>
	<input type="submit" value="Submit"/>
</form>

<script type="text/javascript">
function getFormValue() {
	var myInput = document.getElementsByName("input1");
	if (myInput)
		alert("input1's value: " + myInput[0].value);
	return false;
}
</script>
</body>
</html>

This will alert the value of what's typed into the input element when you click Submit.

Member Avatar for diafol

I came across this a little while ago. I tried some of the functions and they were fine, although one or two didn't work (probably my fault):

http://phpjs.org/

It's basically a set of js functions named after php functions. Interesting.

commented: nice.....Thanks for share this +1

Also you might want to look into AJAX. ;)

To answer the actual question:
No, you can't use PHP client-side.

Unless you happen to have a browser that supports PHP as a scripting language.
(Of which I know none)

I came across this a little while ago. I tried some of the functions and they were fine, although one or two didn't work (probably my fault):

http://phpjs.org/

It's basically a set of js functions named after php functions. Interesting.

Yea, I tried those to a while back. Very useful.

This should make it easier for PHP programmers to get started with JavaScript. They would at least have the basic PHP functions available.

If you are trying to get values from a form, why not use the $_POST and $_GET vars in PHP... Any data from the form will be in these.

Using JavaScript is all well and good until you come across a browser which either has JavaScript disabled or does not support JavaScript.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.