[SOLVED] Function help??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
fresh
Forum Contributor
Posts: 259
Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika

[SOLVED] Function help??

Post by fresh »

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:

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

&lt;/td&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;table border=0 cellpadding=0 cellspacing=0&gt;
&lt;td&gt;
&lt;input type="text" name="test"&gt; 
&lt;input type="submit" name="sub" value="Inject"&gt;
&lt;/td&gt;
&lt;/table&gt;
&lt;/form&gt;
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 :)
User avatar
fresh
Forum Contributor
Posts: 259
Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika

Post by fresh »

hey, nevermind, figured it out.. thanks :)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

you should generaly post your solution for the well being of ppl reading the topic :)
User avatar
fresh
Forum Contributor
Posts: 259
Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika

Post by fresh »

well, I just snuffed the function call, and then just substitued the call with a new page which would echo the vars from the form page... simulating the same effect.. nothing much to share.. sorry :(
Post Reply