Page 1 of 1
php question..
Posted: Thu Oct 09, 2003 9:39 am
by lop
hi everyone,
i need to make something and i don't know if its possible with php.
i want to make a form and when submited the form details to go automatically to an e-mail.
is this possible? and if yes how exactly?
thank you in advance

Posted: Thu Oct 09, 2003 9:43 am
by mathewvp
Assuming that the form has fields sub for subject,msg for message,to for to,
<?
extract($_POST);
mail($to,$sub,$msg,"From:
you@yourhost.com");
?>
Also use stripslashes() to strip all ''' from the subject and message
As simple as that
Posted: Thu Oct 09, 2003 9:47 am
by lop
thank you very much:)
you have no idea how helpful that was!
thanks again
see u soon
Posted: Thu Oct 09, 2003 9:47 am
by Nay
Posted: Fri Oct 10, 2003 12:56 pm
by lop
thank you vary much this tutorial is very helpfull!
thanx nay
Posted: Thu Oct 16, 2003 5:37 am
by lop
ok ppl i need some help here, i'm going crazy....
so about this mail form thing.... i do the following
<?
$Title = $_REQUEST['Title'] ;
$First_name = $_REQUEST['First_name'] ;
$Last_name = $_REQUEST['Last_name'] ;
$Email = $_REQUEST['Email'] ;
mail( "
mail@hotmail.com", "Feedback Form Results",
$Title$First_name$Last_name$Email, "From: $Email");
header( "Location:
http://www.example.com/thankyou.html"" );
?>
and it says i have an error... whats my mistake can someone tell me please!
Posted: Thu Oct 16, 2003 5:45 am
by twigletmac
What error does it tell you you have?
Mac
Posted: Thu Oct 16, 2003 5:48 am
by lop
it says: Parse error... and then the direction of the page and the line number
Posted: Thu Oct 16, 2003 5:52 am
by volka
PHP Parse error: parse error, unexpected T_VARIABLE in blablabla on line 8
this one?
What are you trying to do with
$Title$First_name$Last_name$Email
? If you want to concatenate the string please read
http://www.php.net/manual/en/language.o ... string.php
Posted: Thu Oct 16, 2003 5:53 am
by qads
would't be nice if you post the error message?
EDIT: go volka!

Posted: Thu Oct 16, 2003 5:57 am
by lop
Parse error: parse error in /home/webpages/sendmail.php on line 18
yes exactly that..
i want to make a form with name,surname,e-mail,address and stuff like that and i want it to be e-mailed to me when someone presses submit.
Posted: Thu Oct 16, 2003 7:15 am
by lop
ok... i've manage to make it work...in a way.. i wrote that:
<?php
@extract($_POST);
$Title = stripslashes($Title);
$First_name = stripslashes($First_name);
$Last_name = stripslashes($Last_name);
$Email = stripslashes($Email);
$Message = "The form has been filled out by ". $Title . $First_name . $Last_name . $job_title . $Username . $Email . $Password . $Confirm_Password . $Title2 . $First_name2 . $Last_name2 . $Job_title2 . $Email2 . $Company_name;
mail ('
mail@hotmail.com',"Form submitted", $message);
it goes to my mail but its emty... do u know why?
Posted: Thu Oct 16, 2003 7:50 am
by volka
$message is empty except the static string?
if so try
Code: Select all
<?php
...
print_r($_POST);
@extract($_POST);
...
?>
and see wether it contains what you expect.
Your script should test the values anyway
Code: Select all
<?php
function stripPOST($elemName)
{
if (!isset($_POST[$elemName]) || strlen($_POST[$elemName]) == 0)
die($elemName . ' not set');
else
return stripslashes($_POST[$elemName]);
}
$Title = stripPOST('Title');
$First_name = stripPOST('First_name');
$Last_name = stripPOST('Last_name');
$Email = stripPOST('Email');
$Message = "The form has been filled out by ". $Title . $First_name . $Last_name . $job_title . $Username . $Email . $Password . $Confirm_Password . $Title2 . $First_name2 . $Last_name2 . $Job_title2 . $Email2 . $Company_name;
mail ('mail@hotmail.com',"Form submitted", $message);
?>
tested not even by compiler
Posted: Thu Oct 16, 2003 7:52 am
by Nay
Maybe this:
Code: Select all
mail ("mail@hotmail.com","Form submitted", $message);
I think you'll have to use double quotes on that one.
-Nay
edit: Always earlier than me, Volka
