and I was wondering if anyone knew a good PHP tutorial for newbies on how to create a working form with PHP? That is the backend of it?
Answers: Forms ( SitePoint Forums PHP )
Forms
I can give you at least a quick headstart - don't have a good resource to recommend though I'm sure there are many.
Basically, there are two attributes of your <form> element that your php script will care about - action and method - and it will also care about the names of the input elements that define your form data elements.
action - just the url/path to your php file
method - determines how the form's data (input elements etc.) get sent to your php file/script. this should be either POST or GET. There are a couple differences btw the two which probably won't matter to you short term - basically GET will place the values into the URI string passed to your file, and there are some length restrictions if I recall correctly (in terms number of values that can be sent and/or how long they can get... may have to do with URI string length restrictions or something...)
Then in php, you have 3 associative arrays (keys are names of your form input elements) you can use to access your data in file.php from the example snippet above: $_GET, $_POST, $_REQUEST.
$_GET - contains your form data if you used method="GET"
$_POST - contains your form data if you used method="GET"
$_REQUEST - contains all $_POST and $_GET elements
here's an example - suppose your had an input element like:
<input type="text" name="my_text" />
then you could access it in your php script using something like:
$received_text = $_REQUEST['my_text'];
of course you could use $_GET or $_POST as well depending on which method you chose in your form element.
Hope this helps!
JSM
Forms
thanks but i also need to create the backend where the form sends all the stuff and such, perhaps even examples.
silver163
Forms
if register_global=on in php.ini, you can use the var directly, but register_global on is not a good choice.
urdoll
Forms
when you say backend where the form sends things... do you mean writing to a database?
usually the following basic steps are necessary with respect to form handling... let us know which one you're currently dealing with:
1. generating the form html (might be static html, might be scripted, etc.)
2. accessing the form data submitted to your php script (that's what my first post was meant to help with)
3. potentially saving the form data (to a db, to a file, perhaps emailing it...)
hope this helps clarify!
JSM
Forms
when i say backend I mean a file that has the information to which email address to send the form to. I was hoping for a website with a tutorial and examples I can see.