View Full Version : PHP Question
GoldenEagle
03-24-2004, 09:47 PM
Does anyone know the code to have a from email to you?
For example I have -
form action="app.php" metod="post" What else do I need?
GoldenEagle
03-24-2004, 10:47 PM
bump
MacroGuru
03-24-2004, 11:22 PM
Does anyone know the code to have a from email to you?
For example I have -
form action="app.php" metod="post" What else do I need?Well, in the app.php you need to have the following.
mail ( "
[email protected]", "Subject of the Mail",
"Mail Body" );
You can also display the form on the APP.PHP if you wanted to for the End use to see by using the echo ("$variable"); command inside the area.
Hope this helps.
GoldenEagle
03-24-2004, 11:45 PM
?php mail ( "
[email protected]", "CFL Application"
"Mail Body");
?
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\Websites\thecfl.net\app.php on line 3
MacroGuru
03-24-2004, 11:59 PM
Hmm, if it is written exactly like what you have, the comma is missing between the CFL Application and your Mail body.
That could be the problem.
GoldenEagle
03-25-2004, 12:04 AM
Ok, so I now need to write varaibles for each answer in the form so I can see it in the email?
GoldenEagle
03-25-2004, 12:11 AM
Would I replace mail body with
echo ($name);
GoldenEagle
03-25-2004, 01:16 AM
I got it working but with this error message
Warning: mail() expects at most 5 parameters, 9 given in C:\Websites\thecfl.net\app.php on line 9
I am guessing that means I can only pass five parameters. Is there another function?
Can't you append all the text and put it all in the message argument?
Look at example 4 from the page http://www.php.net/manual/en/function.mail.php
http://www.php.net/manual (http://www.php.net/manual/en/function.mail.php) is nearly my homepage now since I began writing my stats site for Hattrick in the french league !
MacroGuru
03-25-2004, 07:22 AM
Here is a sample of the player registration form I use for the Utah Wolverines that e-mails the form to the owners/Coaches. e-mail addy's have been modified.
<?php
mail("
[email protected],
[email protected]", "Player Registration For Utah Wolverines",
"$name is interested in joining the Utah Wolverines, he feels he has what it takes to be part of a championship tradition.
He has provided us with the following information:
Personal Information
Name: $name
Date of Birth: $dob
Address: $address
Apt: $apt
City: $city
State: $state
Zip: $zip
Contact Information
Home Phone: $homephone
Work Phone: $workphone
Other Phone: $otherphone
Email: $email
Position Choice
QB: $qb
DB: $db
RB: $rb
PK: $pk
OL: $ol
KR: $kr
DL: $dl
ST: $st
LB: $lb
WR: $wr
Height: $height
Weight: $weight
40 Time: $forty
Bench: $bench
Player Experience
High School: $highschool
High School Years: $hsyears
Last High School Year: $hslast
College: $college
College Years: $cyears
Last College Year: $clast
Semi-Pro Team: $semipro
Years Semi-Pro: $spyears
Last Year Semi-Pro: $splast
Professional Team: $pro
Years Pro: $proyears
Emergency Contact Information
Contact Name: $emername
Contact Number: $emernumber
Player Bio
Where From: $wherefrom
Hobbies: $hobbies
Profession: $profession
Favorite Food: $food
Favorite Team: $team
Favorite Music: $music
Favorite Movie: $movie
Favorite Quote: $quote
");
?>
GoldenEagle
03-25-2004, 09:49 AM
<?php
mail ("
[email protected]", "CFL Application",
"Name: $name"
"Handle: $handle"
"Email: $email"
"AIM : $AIM"
"Team 1: $team1"
"Team 2: $team"
"Comments : $comments"
);
?>
This generates the following error message:
Parse error: parse error, unexpected '"' in C:\Websites\thecfl.net\app.php on line 5
If I taken the quotation marks away it gives me something an unexpected semi-colon error.
Have you tried to do it like this:
<?php
mail ("
[email protected]", "CFL Application",
"Name: $name
Handle: $handle
Email: $email
AIM : $AIM
Team 1: $team1
Team 2: $team
Comments : $comments"
);
?>
GoldenEagle
03-29-2004, 01:17 AM
I tried that and it worked. Sorry I did not update.
No problem. Glad to see it working for you !
sabotai
03-29-2004, 02:32 PM
General tip. Do not just throw your email address in there. Use variables to hold it. Spam bots will go through your PHP and see
[email protected] and you'll start getting spam.
If you did something like (using psuedo-code here...)
string name = "thechargers";
string isp = "hotmail";
string end = "net";
string email = name + "@" + isp + "." + end;
It'll fend off those damn bots.
Bonegavel
03-29-2004, 07:52 PM
Sab, the bots can't get at the php code. If they can, we are all Doomed!
sabotai
03-29-2004, 07:54 PM
Ok....well...they can't yet. :)
GoldenEagle
03-29-2004, 07:56 PM
Did you get that book yet sab?
sabotai
03-29-2004, 08:04 PM
It came today. Haven't had much of a chance to crack it open yet but I plan to later
vBulletin v3.6.0, Copyright ©2000-2026, Jelsoft Enterprises Ltd.