|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Passing Form Data To A Remote PHP Function
Check it....
PHP Code:
Doesn't work. And....PHP Code:
Doesn't work. The function BM_Add() is obviously located in the included file. I've also tried surrounding the BM_Add() function with PHP tags. When I do that it executes the function whether the form is submitted or not. Essentially it just keeps refreshing the page. Which, of course, is not the intended use. Any suggestions? ![]() |
|
#2
|
||||
|
||||
|
A form action calls a page and not a PHP function. Your action needs to call a page that includes bm_functions.inc and does a call to BM_Add(). You can also do this in the same page by specifying the POST method and checking for $_POST vars to toggle whether to display the form or to process the results.
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
|
#3
|
|||
|
|||
|
Yeah I was talking with my resident PHP expert and he informed me of the same.
Now I'm using in the remote function: Code:
if ($BM_Add == "on") BM_Add();
function BM_Add() {
if(!$_POST['site_name'] || !$_POST['site_desc'] || !$_POST['addr'] || !$_POST['grp'] || !$_POST['BM_Add']) {
echo $_POST['site_name']. " + " .$_POST['site_desc']. " + " .$_POST['addr']. " + " .$_POST['grp']. " + " .$_POST['BM_Add'];
echo "
<div align=\"center\">
<b class=\"add_err\">- Addition Failed -</b>
<meta HTTP-EQUIV=\"refresh\" content=\"2; url=add_form.php\">
</div><br>
";
}
else { ..............
But one question I have is how does the function know what values it needs to use? Or does it have the ability to use any values passed to the file that it's in? Thanks for the response dhouston. Maybe you can answer my other questions. |
|
#4
|
||||
|
||||
|
Since you're using the $_POST superglobal, you don't necessarily need to pass any values to the function. You can pass a comma-separated list of values to a function and use those within the function's scope, though, if there are no globals that contain the info you need. If these two fairly basic points have eluded you, you might want to dig around for a good basic PHP/Web-application tutorial that'll help you get some of the basics under your belt. Unfortunately, I can't point you to one off-hand. Anybody else know of any good starting points?
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Passing Form Data To A Remote PHP Function |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|