php question..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lop
Forum Newbie
Posts: 7
Joined: Thu Oct 09, 2003 9:39 am

php question..

Post 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 :)
mathewvp
Forum Commoner
Posts: 28
Joined: Wed Apr 23, 2003 10:28 am

Post 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
lop
Forum Newbie
Posts: 7
Joined: Thu Oct 09, 2003 9:39 am

Post by lop »

thank you very much:)
you have no idea how helpful that was!

thanks again

see u soon
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

lop
Forum Newbie
Posts: 7
Joined: Thu Oct 09, 2003 9:39 am

Post by lop »

thank you vary much this tutorial is very helpfull!

thanx nay
lop
Forum Newbie
Posts: 7
Joined: Thu Oct 09, 2003 9:39 am

Post 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!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What error does it tell you you have?

Mac
lop
Forum Newbie
Posts: 7
Joined: Thu Oct 09, 2003 9:39 am

Post by lop »

it says: Parse error... and then the direction of the page and the line number
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

would't be nice if you post the error message? :P

EDIT: go volka! :roll:
lop
Forum Newbie
Posts: 7
Joined: Thu Oct 09, 2003 9:39 am

Post 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.
lop
Forum Newbie
Posts: 7
Joined: Thu Oct 09, 2003 9:39 am

Post 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?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post 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 :lol:
Post Reply