EQUATION IN PHP PLZ HELP...
Posted: Sat Oct 30, 2010 6:19 pm
hi, my point is to make a programme with php, so here we go:
you put an equation in ONE feild and it will solve it to you
here is a simple example:
<?php
$eq=$_POST['eq'];
?>
<form name="equation" method="POST" action="index.php">
<input type="text" name="eq" id="eq" value="<?php echo $eq;?>" >
<input type="submit" name="submit" value="SOLVE" >
</form>
<?php echo $eq;?> // if I put this line it will show me(lets say that i entered in the feild "1+2") :-----------------> it will show me "1+2", not "3"(the result)
NB : I don't want to use 2 feilds with 2 variables $a=$_POST['a']; $b=$_POST['b']; $result=$a+$b because the "+" can be chaged "/" "*" "-"
/////////////////////////////////////
another example:
[2+1__________________] [submit]
Result:
2+1
//////////////////////////////// I WANT THE RESULT TO BE "3"
THANK YOU
you put an equation in ONE feild and it will solve it to you
here is a simple example:
<?php
$eq=$_POST['eq'];
?>
<form name="equation" method="POST" action="index.php">
<input type="text" name="eq" id="eq" value="<?php echo $eq;?>" >
<input type="submit" name="submit" value="SOLVE" >
</form>
<?php echo $eq;?> // if I put this line it will show me(lets say that i entered in the feild "1+2") :-----------------> it will show me "1+2", not "3"(the result)
NB : I don't want to use 2 feilds with 2 variables $a=$_POST['a']; $b=$_POST['b']; $result=$a+$b because the "+" can be chaged "/" "*" "-"
/////////////////////////////////////
another example:
[2+1__________________] [submit]
Result:
2+1
//////////////////////////////// I WANT THE RESULT TO BE "3"
THANK YOU