PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old March 25th, 2004, 06:53 AM
tobycloud tobycloud is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Near Albany NY
Posts: 27 tobycloud User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to tobycloud Send a message via AIM to tobycloud
Passing Form Data To A Remote PHP Function

Check it....

PHP Code:
<?php include("bm_functions.inc"); ?>

<form action="BM_Add()">

    Site Name: <input type="text" name="site_name" value=""><br>

    Site Desc: <input type="text" name="site_desc" value=""><br>

    Address: <input type="text" name="addr" value=""><br>

    Group: <input type="text" name="grp" value=""><br>

    <input type="submit" value="Add Bookmark" OnClick="">
    
</form>


Doesn't work. And....

PHP Code:
<?php include("bm_functions.inc"); ?>

<form action="">

    Site Name: <input type="text" name="site_name" value=""><br>

    Site Desc: <input type="text" name="site_desc" value=""><br>

    Address: <input type="text" name="addr" value=""><br>

    Group: <input type="text" name="grp" value=""><br>

    <input type="submit" value="Add Bookmark" OnClick="BM_Add()">
    
</form>


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?

Reply With Quote
  #2  
Old March 25th, 2004, 07:39 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
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.

Reply With Quote
  #3  
Old March 25th, 2004, 08:45 AM
tobycloud tobycloud is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Near Albany NY
Posts: 27 tobycloud User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to tobycloud Send a message via AIM to tobycloud
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.

Reply With Quote
  #4  
Old March 25th, 2004, 11:26 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
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?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Passing Form Data To A Remote PHP Function


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway