Your variables are also available as plain old variables.  For a newbie it
might be easier and more user frinedly to use it that way rather than the
array mentioned below.

In your case, $demand and $name would contain the information entered by the
user.  I generally use this method in my code.


Robbert van Andel 


-----Original Message-----
From: Ernest E Vogelsinger [mailto:[EMAIL PROTECTED]]
Sent: Monday, November 18, 2002 4:36 PM
To: one_gundam_war
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] How to process data from forms


At 01:06 19.11.2002, one_gundam_war spoke out and said:
--------------------[snip]--------------------
>Ok. I am kind of new to PHP, but I have a question. I have a site, and it

You've got a lot of questions then I'm sure :)
Ok, let's start:

>has a system where people can apply. However, the mailto: system seems like
>it would be too much of a hassle, and I don't want to make users skip it
>just because they use webmail.
>
>So, does anyone know how to make the values in a form either automatically
>get e-mailed to an address (as in you just hit "submit" and it does it.
does
>not involve the client's e-mail addy) or to write it to a data file (which
I
>can then check and see individual responses in).

If you submit a form to a PHP script, the form variables are accessible in
a global associative array ($_GET for forms using the GET method, $_POST
for post forms, or $_REQUEST for both). You can easily hand these variables
to either an SQL statement, or to the mail() function for further
processing.

Assume this little form:

<form action="mailform.php" method="post">
Enter your name here: <input type="text" name="name"><br>
What is your demand? <textarea name="demand"></textarea><br>
<input type="submit" value="send it up">
</form>

When the user clicks on "Send it up", your script named "mailform.php" gets
executed and can process the data:

--------------------------------------------
<?php

// put the stuff into SQL
$sql = 'insert into mytable (name, demand) values (\'' .
       str_replace('\'', '\'\'', $_POST['name']) . '\',' .
       str_replace('\'', '\'\'', $_POST['demand']) . '\')';

// mail that stuff to me
mail('[EMAIL PROTECTED]', 'Form received from Webuser',
     'Name: '.$_POST['name']."\n\nDemand: ".$_POST['demand']."\n\n" .
     'Yours sincerely, ' . $_SERVER['PHP_SELF']);

?>
<h1>Thanks for klicking that button!</h1>
---------------------------------------------

This is of course kinda crude, untested, etc etc etc, but I hope you get
the basic idea. http://www.php.net/manual/en/ is a great place to look up
anything you need.



-- 
   >O Ernest E. Vogelsinger 
   (\) ICQ #13394035 
    ^ http://www.vogelsinger.at/


 "The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material from all
computers." 


Reply via email to