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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie Help with mail form. 1

Status
Not open for further replies.

sborny

Technical User
Jun 29, 2001
157
GB
Hi all,

I don't know a thing about PHP so i don't know if the following is even possiblle..

I have a form on a web page and I need to be able to create a CSV file from the data in the form and then e-mail that CSV file to a designated address.

As I said I know nothing about PHP so any help would be much appreciated.

Cheers

Symon.

Everything has an answer, it's just knowing the right question to ask. !!!!
 
Hi,

Yes very possible. First thing is you need to capture the form field in the PHP script, then string them together with commaa between. The tricky thing is to email it, use the mail() function which satisfies most users. If that function wont do as you need there are some add ons you can use.
I'm assuming that you know some programming like ASP, Perl or whatever you just don't have the PHP bit. If I'm wrong reply and I can flesh this out as bit

 
depending on your version of php, you might try something like this:

<?php
$arr = get_defined_vars();
$mailBody=implode(",",$arr[HTTP_POST_VARS]) . "\n\n";
$email="info@someaddress.com";
$mailHeaders = "From: me@mysite.com\r\n";
$mailSubject = "You have got mail";
mail($email, $mailSubject, $mailBody, $mailHeaders);
print "<h1>Thanks for filling out the form</h1>";
?>

if you name that file response.php then your html form
should have something like this in it:


<form methode=post action=response.php>
<input name=something>
[<input name=something_else> ... ]
<input type=submit>
</form>
 
Hi elck,

Thanks for the script.

I have tried it and I get an email but it has nothing attached to it.

Any ideas.

Hi ingresman,

I am afraid that I don't know any of the scripting languages. Just starting to try and get my head around them.

Cheers

Symon.

Everything has an answer, it's just knowing the right question to ask. !!!!
 
Hi all,

Just a quick note,

I have some javascript running on the page that verifies that the fields have data in them.

Would this cause any problems with php working.

cheers

symon.

Everything has an answer, it's just knowing the right question to ask. !!!!
 
Cannot see how the javascript can mess things up, but I think my example doesn't work there because you have another php version.
What version do you have? <?php phpinfo();?>

 
I think elck's got you going with that code, try some quotes
around HTTP_POST_VARS since it's an assoc array like:

$arr['HTTP_POST_VARS']

HTH
 
Hi all,

sorry it has been a while for me to respond but I have been away.

I have tried the code with and without the quotation marks and I get the email but do not have anything attached to it.

Does anyone have anymore ideas.

Cheers

Symon.


Everything has an answer, it's just knowing the right question to ask. !!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top