Click to See Complete Forum and Search --> : creating an error message


keko2005
08-09-2005, 03:53 PM
hey guys, im new to php, im just doing some testing, but i came across a problem when i wanted to do something. lets say i have 2 submit buttons. each submit button will create a text. now, how do i get it to load the text when the user clicks the submit buttons in the <tr> above the buttons <tr>? do i have to reload the page(if i do, how do i got about doing this), or can i just echo or print to the <tr> itself?

maybe a tutorial will do if u guys got one
thanks

ShrineDesigns
08-09-2005, 09:40 PM
example
<?php
if($_POST)
{
$msg = (isset($_POST['s1'])) ? 'something' : 'something else';
}
?>
<form action="" method="post">
<?php
if(isset($msg))
{
echo " <div>$msg</div>\n";
}
?>
<div>
<input type="submit" name="s1" value="test 1">
<input type="submit" name="s2" value="test 2">
</div>
</form>

Stephen Philbin
08-10-2005, 12:43 AM
By the way, yes that code does cause the page to reload. PHP is a server side language. It can only ever be processed on the server and the server only ever proccesses a php document once at the time of request.

Stick something in google like "client side" "server side" difference

It'll hopefully come up with some stuff that'll teach you the basic differences. They're a key concept you must grasp.

aznchong91
08-10-2005, 02:13 AM
You could also use javascript to do this, since php can be embedded into javascript as well.

If you don't know how, just use the function, getElementById(name-of-the-<tr>-tag).value=(the text). If you need any further assistance, just say so, or go to the javascript forum and ask for help.