Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible to call a function on submission of a form?

Status
Not open for further replies.

jewel464g

Technical User
Jul 18, 2001
198
US
I have a page that allows a user to edit a database. There is an edit part, delete part, etc. Right now I'm using If else statements. The page is getting rather crowded. I would like to be able to break it up into functions so it would be easier to read. What I need to know is after editing the fields, is there a way to call the function on the same page by clicking the submit button? I'm new to PHP so please forgive me if this is a dumb question.
 
Yes and no.

PHP is a server side scripting language and none of the PHP code goes to the user. So no. You can not call it directly like that.

Yes you can submit the page to itself and then call your function. It will look like a page refresh to the user (unless they click back). You can use JavaScript to route the action part of a form depending on the user input.

Remember that PHP requires the server for processing and therefore results in a new page being sent to the user. JavaScript works good to have processing done on the client before a submission is sent to the server.

Hope this helps!

Scott
 
No, you can't. You have to do a reload of the page and here you call the function Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top