Joined: 02 Jul 2009 Posts: 2 Location: Leominster, MA
Posted: Thu Jul 02, 2009 7:33 pm Post subject: I need help with php_self and forms
I have created a combo php/html form that accepts user input. I want to send the fields the user inputs to a MySQL database. I have something set up that works, but the "action" in the form section points to another php script file. I've read that if the PHP_SELF variable is used in the "action" field of the form you can check to see if the form has been submitted, and that the form will be redisplayed after submission. What I haven't seen, or been able to figure out, is how does the data get passed to MySQL? I'm using a separate script. I'm very new to this, so any help or suggestions, or even examples would be greatly appreciated.
Peter V.
Joined: 02 May 2004 Posts: 5915 Location: toronto, canada
Posted: Fri Jul 03, 2009 3:52 pm Post subject:
PHP_SELF passes the data back to the same page, where you could have functions that show the form, functions that process the from and functions that do something with the data (like email and save to a database)
function processForm()
{
//clean and validate data here
//all data gets put into $arrayData
//call function to save t db
saveData($arrayData);
//call to email the data
function emailData($arrayData);
}
function showForm($data='')
{
//show form
//$data is the array that holds the values of the form for redisplay
}
function emailData($data)
{
//create email message
}
function saveData($data)
{
//really this should be in an include file that holds a variety of DB
//functions like saveData, getData, deleteData, updateData
//more of a DB class of some kind
}
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum