accepting more than 5 parameters in the mail() command
Moderator: General Moderators
accepting more than 5 parameters in the mail() command
Is it possible to have more than 5 parameters in the mail() command? I am trying to mail 13 fields collected from a from a form but I get the following error:
Warning: mail() expects at most 5 parameters, 16 given in /home/bertspar/public_html/sendmail.php on line 16
My script is as follows:
<?
$Title = $_REQUEST['Title'] ;
$Name = $_REQUEST['Name'] ;
$Initial = $_REQUEST['Initial'] ;
$Surname = $_REQUEST['Surname'] ;
$Position = $_REQUEST['Position'] ;
$Company = $_REQUEST['Company'] ;
$Address1 = $_REQUEST['Address1'] ;
$Address2 = $_REQUEST['Address2'] ;
$Address3 = $_REQUEST['Address3'] ;
$Country = $_REQUEST['Country'] ;
$ContactNumber = $_REQUEST['ContactNumber'] ;
$CellNumber = $_REQUEST['CellNumber'] ;
$Email = $_REQUEST['Email'] ;
mail( "albert_oflaherty@hotmail.com", "Expression Of Interest in Forum on Public Safety 2006",
$Title,$Name,$Initial,$Surname,$Position,$Company,$Address1,$Address2,$Address3,$Country,$ContactNumber,$CellNumber,$Email, "From: $Email" );
header( "Location: http://www.bertsparadise.com/Confirmation.htm" );
?>
Can someone please help?
Warning: mail() expects at most 5 parameters, 16 given in /home/bertspar/public_html/sendmail.php on line 16
My script is as follows:
<?
$Title = $_REQUEST['Title'] ;
$Name = $_REQUEST['Name'] ;
$Initial = $_REQUEST['Initial'] ;
$Surname = $_REQUEST['Surname'] ;
$Position = $_REQUEST['Position'] ;
$Company = $_REQUEST['Company'] ;
$Address1 = $_REQUEST['Address1'] ;
$Address2 = $_REQUEST['Address2'] ;
$Address3 = $_REQUEST['Address3'] ;
$Country = $_REQUEST['Country'] ;
$ContactNumber = $_REQUEST['ContactNumber'] ;
$CellNumber = $_REQUEST['CellNumber'] ;
$Email = $_REQUEST['Email'] ;
mail( "albert_oflaherty@hotmail.com", "Expression Of Interest in Forum on Public Safety 2006",
$Title,$Name,$Initial,$Surname,$Position,$Company,$Address1,$Address2,$Address3,$Country,$ContactNumber,$CellNumber,$Email, "From: $Email" );
header( "Location: http://www.bertsparadise.com/Confirmation.htm" );
?>
Can someone please help?
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
mail takes 5 parameters, thats all it will take. you can't just put in other parameters and expect php to know what to do with them, php does not know what $position is or why its there.
heres what you want:
heres what you want:
Code: Select all
<?
$body = $_REQUEST['Title']."\n";
$body .= $_REQUEST['Name']."\n";
$body .= $_REQUEST['Initial']."\n";
$body .= $_REQUEST['Surname']."\n";
$body .= $_REQUEST['Position']."\n";
$body .= $_REQUEST['Company']."\n";
$body .= $_REQUEST['Address1']."\n";
$body .= $_REQUEST['Address2']."\n";
$body .= $_REQUEST['Address3']."\n";
$body .= $_REQUEST['Country']."\n";
$body .= $_REQUEST['ContactNumber']."\n";
$body .= $_REQUEST['CellNumber']."\n";
$body .= $_REQUEST['Email']."\n";
mail( "albert_oflaherty@hotmail.com", "Expression Of Interest in Forum on Public Safety 2006", $body, "From: $Email" );
header( "Location: http://www.bertsparadise.com/Confirmation.htm" );
?>yes, replace it with
$_REQUEST takes data from both $_POST and $_GET (whichever is available). This becomes a flaw as the user can just add ?field_name=value in which $_REQUEST['field_name'] will become value.
Code: Select all
$_POST['field_name'];Mickd,
Do you know the answer to this question?
I now receive the contents of the $body in the email (which is correct), however, I am back where I started as the sender of the email is now listed as <unknown>. It seems that it cannot recognise the contents of the $Email variable in the mail() command. Any suggestions?
Do you know the answer to this question?
I now receive the contents of the $body in the email (which is correct), however, I am back where I started as the sender of the email is now listed as <unknown>. It seems that it cannot recognise the contents of the $Email variable in the mail() command. Any suggestions?
Code: Select all
<?php
$email = $_POST['email'];
$body = // etc etc
mail( "albert_oflaherty@hotmail.com", "Expression Of Interest in Forum on Public Safety 2006", $body, "From: $email" );
?>- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
look at fopen() for some examples.5leander5 wrote:What code do I need to include to save the contents of the user form to a text file (ie. to write the variables to a text file) as well as emailing it to someone?
Yeah, mail() is a dangerous function if it falls in the wrong hands.. beware indeed. Just last week I spoke a webhost provider who wasn't so happy about the 50000 spammails that were send from their servers the week before ... luckily it wasn't my scriptsThere's a potential exploit a spammer could use in the script