[SOLVED] Function help??
Posted: Sun Aug 01, 2004 11:50 am
hey
Im trying to call a function within a form element, could someone show me how to do so, here's my html form and PHP script:
So I'm trying to call a function when somone hits the inject submit button and echo either the right or wrong message in the laboratory div box, I have no idea how to do this, so a simple example would be much appreciated, thanks 
Im trying to call a function within a form element, could someone show me how to do so, here's my html form and PHP script:
Code: Select all
<form action="blah.php" method="post"> <-- may not be needed
Laboratory:
<div style='border:#323E4A 1px solid;width:400;height:80;color:#AAC9E8'>
<table border=0 cellpadding=0 cellspacing=0>
<td width=400 height=80>Code: Select all
<?php
function chk() {
$try = $_POST['test'];
$answer = "apple";
$right = "right";
$wrong = "wrong";
if ($answer != $try) {
echo "".$wrong."";
} else {
echo "".$right."";
}}
?>Code: Select all
</td>
</table>
</div>
<table border=0 cellpadding=0 cellspacing=0>
<td>
<input type="text" name="test">
<input type="submit" name="sub" value="Inject">
</td>
</table>
</form>