RE: forms & functions
| From: | Tim Ward | Date: | Tue, 27 Feb 2001 09:41:34 +0000 |
| Subject: | RE: forms & functions | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-41822@lists.php.net to get a copy of this message | ||
essentially, no.
PHP runs server side and the action of a form is generated client-side. To
run a PHP function the page needs to be resubmitted. The code you have
written will run the function before the page is submitted. try something
like ...
<?
function myfunction()
{ if($submit)
{ $result = mysql_query("INSERT INTO app
(name,company,address,suburb,state,post,areacode,phone,faxarea
code,fax,email,secret) VALUES
('$name','$company','$address','$suburb','$state','$post',
'$areacode','$phone','$faxareacode','$fax','$email','$secret')");
}
}
if ($thissubmit) myfunction();
?>
<form action="#?submit=<?php echo($submit) ?>&thissubmit=1">
Tim Ward
Senior Systems Engineer
Please refer to the following disclaimer in respect of this message:
http://www.stivesdirect.com/e-mail-disclaimer.html
> -----Original Message-----
> From: Peter Houchin [mailto:peterh@vfsa.com.au]
> Sent: 27 February 2001 00:16
> To: PHP MAIL GROUP
> Subject: forms & functions
>
>
> Hiya,
>
> Can i call a function from the action line of a form?
>
> ie:
> <?
> function myfunction(){
> if($submit){
> $result = mysql_query("INSERT INTO app
> (name,company,address,suburb,state,post,areacode,phone,faxarea
> code,fax,email,secret) VALUES
>
> ('$name','$company','$address','$suburb','$state','$post','$ar
>
> eacode','$phone','$faxareacode','$fax','$email','$secret')");
> }
> }
> ?>
> <form action="<? myfunction(); ?>
>
> i would like to do it this way because i have a form on
> another page with passed the vaules thru to this one .. and i
> don't want it looking at the if($submit)
> Any help would be great
>
> Thanks
>
> Peter Houchin
> Sun Rentals
> peterh@sunrentals.com.au
>
>