CIAOOO!!!!!
Allora, mi piacerebbe utilizzare il form che ho linkato al primo messaggio... mi sembra molto buono.
Il codice di "conferma" è il seguente:
Codice PHP:
<?php
/*
This file is a part of Basic PHP Form. Copyright (c) 2005 Mark MacCollin, Mevin Productions, [url]www.mevin.com[/url]
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
include('header.php');
require('config.php');
///////////// receives the form values //////////////////////
$first_name = $_REQUEST['first_name'] ;
$last_name = $_REQUEST['last_name'] ;
$home_address = $_REQUEST['home_address'] ;
$city = $_REQUEST['city'] ;
$state = $_REQUEST['state'] ;
$phone = $_REQUEST['phone'] ;
$zip = $_REQUEST['zip'] ;
$alt_phone = $_REQUEST['alt_phone'] ;
$email = $_REQUEST['email'] ;
$comments = $_REQUEST['comments'] ;
/////////////Allows the use of Apostrophes or single quotes /////////////////
$comments=stripslashes($comments);
////////// makes sure the form is submitted from your server and not someone elses /////////////////////////
if (strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'])>7 || !strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']))
die("<font color=red>Error! Bad Referer</span> ");
/////////////// Error messages. ///////////////
///////// The first name through the state fields are only checked to ensure they aren't blank /////
if (($first_name_on == "1" ) && ($first_name == ""))
{ echo "<font color=red>First name is required. Please go back and correct.</span>
";
}
if ( $last_name == "")
{ echo "<font color=red>Last name is required. Please go back and correct.</span>
";
}
if ( $city == "")
{ echo "<font color=red>City is required. Please go back and correct.</span>
";
}
if ( $state == "")
{ echo "<font color=red>State is required. Please go back and correct.</span>
";
}
//////////////////// this error message verifies that the email field is typed in a valid email format. ////////////////
if (!preg_match('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/',$email))
{ echo "<font color=red>A valid email address is required. Please go back and correct.</span>
";
}
////// This error message verifies that the zip field is typed with either a 5 digit and/or with additional 4 digit code. /////
if (!preg_match('/^\d{5}(-\d{4})?$/',$zip))
{
echo('<font color=red>A valid zip code is required. Please go back and correct.</span>
');
}
////// This error message verifies that the phone field is typed with either the (###) ###-#### or the ###-###-#### format.
if (!preg_match('/^\(?\d{3}\)?\s|-\d{3}-\d{4}$/',$phone))
{ echo "<font color=red>A valid phone number is required. Please go back and correct.</span>
";
}
$validation_error = (($first_name_on =="1") && ($first_name == ""))||(($last_name_on =="1") && ($last_name == ""))||(($city_on =="1") &&($city == ""))||(($state_on =="1") && ($state == ""))||(($email_on =="1") && (!preg_match('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/',$email)))||(($zip_on =="1") &&(!preg_match('/^\d{5}(-\d{4})?$/',$zip)))||(($phone_on =="1") && (!preg_match('/^\(?\d{3}\)?\s|-\d{3}-\d{4}$/',$phone)));
if ($validation_error)
{
echo"
</p>
<FORM><INPUT TYPE=\"button\" VALUE=\"Back\" onClick=\"history.go(-1)\"></FORM>
</p>";
include('footer.php');
exit();
}
//////// encapsulates all these variables in one to make it easier to pass on to the mail script /////////
$msgbody =
"
First name: $first_name
Last name: $last_name
Home address: $home_address
City: $city
State: $state
Zip: $zip
Primary phone: $phone
Alternate phone: $alt_phone
Email: $email
Additional comments:
$comments";
/////////////Allows the use of Apostrophes or single quotes /////////////////
$msgbody=stripslashes($msgbody);
///////// prints the form results so the visitor can review. This option can be turned off in config.php.
if ($confirm_option == "1")
{
print "
<table border=0 class=confirm_table>
<tr valign=top>
<td colspan=2 align= ><div align=left>
[b]<FONT class=almost_done>YOU'RE ALMOST DONE!</FONT> Here is what you submitted. If this looks ok, click the [b]confirm[/b] button below. If you need to make a correction, <a href=javascript:history.back(1)>click here to go back to the form.</a>[/b] </p>
</td>
</tr>
<tr valign=top>
<td align=right class=labels ><div align=left>First Name:</div></td>
<td class=results><span class=results>$first_name</span>[/b]
</td>
</tr>
<tr valign=top>
<td class=labels ><div align=left>Last Name: </div></td>
<td class=results ><span class=results>$last_name</span>[/b]</td>
</tr>
<tr valign=top>
<td class=labels ><div align=left>Home Address: </div>
</td>
<td class=results ><span class=results>$home_address</span>[/b]</td>
</tr>
<tr valign=top>
<td class=labels ><div align=left>City:
</div></td>
<td class=results ><span class=results>$city</span>[/b]
</td>
</tr>
<tr valign=top>
<td class=labels ><div align=left>State:</div></td>
<td class=results > <span class=results>$state</span>[/b]</td>
</tr>
<tr valign=top>
<td class=labels ><div align=left>Zip:</div></td>
<td class=results ><span class=results>$zip</span>[/b]</td>
</tr>
<tr valign=top>
<td class=labels ><div align=left>Primary Phone:</div></td>
<td class=results ><span class=results>$phone</span>[/b]</td>
</tr>
<tr valign=top>
<td class=labels ><div align=left>Alternate Phone: </div></td>
<td class=results ><span class=results>$alt_phone</span>[/b]</td>
</tr>
<tr valign=top>
<td class=labels ><div align=left>E-mail:</div></td>
<td class=results ><span class=results>$email</span>[/b]</td>
</tr>
<tr valign=top>
<td colspan=2 valign=top ><div align=left>
<span class=labels>Additional comments:</span>
<span class=results>$comments</span>
</p>
</div></td>
</tr>
<tr valign=top>
<td colspan=2></td>
</tr>
</table>
<form action=\"mail.php\" method=\"post\">
<table border=0>
<tr><td>
<input name=\"msgbody\" type=\"hidden\" value=\"$msgbody\">
<input name=\"email\" type=\"hidden\" value=\"$email\">
<input name=\"first_name\" type=\"hidden\" value=\"$first_name\">
<input name=\"last_name\" type=\"hidden\" value=\"$last_name\">
<center><input type=\"submit\" name=\"Submit\" value=\"Confirm\">
</center>
</td></tr>
</table></form>
";
include('footer.php');
exit();
}
else {
print "";
}
//////// encapsulates all these variables in one to make it easier to pass on to the mail script /////////
$msgbody =
"
First name: $first_name
Last name: $last_name
Home address: $home_address
City: $city
State: $state
Zip: $zip
Primary phone: $phone
Alternate phone: $alt_phone
Email: $email
Additional comments:
$comments";
/////////////Allows the use of Apostrophes or single quotes /////////////////
$msgbody=stripslashes($msgbody);
/* subject */
$subject = "$the_subject";
/* Uncomment the code below if you're sending HTML mail */
if ($html_on =="1")
{
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
}
$headers .= "To: $recipient_main\r\n";
$headers .= "From: $first_name $last_name <$email>\r\n";
$headers .= "Cc: $recipient_cc\r\n";
$headers .= "Bcc: $recipient_bcc\r\n";
/* and now mail it */
mail($to, $subject, $msgbody, $headers);
/* Thank the visitor */
print "$thanks";
include('footer.php'); ?>
Poi c'è un file "config" che è il seguente...
Codice PHP:
<?php
/*
This file is a part of Basic PHP Form. Copyright (c) 2005 Mark MacCollin, Mevin Productions, [url]www.mevin.com[/url]
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
To make this program work, all you have to do is upload all the files to the same server directory and modify the variables below (where you want the results to be emailed) If you need further help, see the readme document.
*/
// This is the main email address where the form results are sent:
$recipient_main="miamail@gmail.com";
// CC
$recipient_cc="";
//BCC
$recipient_bcc="";
//Subject of incoming email
$the_subject="Subjects are a good thing";
//Choose which fields you want to make required by entering a 1 for yes and 0 for no. This makes it easy to optionally validate any field. NOTE: the validation for the phone number and zip code is configured for the United States.
$first_name_on="1";
$last_name_on="1";
$home_address_on="1";
$city_on="1";
$state_on="1";
$zip_on="1";
$phone_on="1";
$email_on="1";
$comments_on="1";
//Allows the use of Apostrophes or single quotes - DO NOT edit this line!
$comments=stripslashes($comments);
//Allows the use of html mail. 1 for yes, 0 for no. (html mail is not recommended)
$html_on="0";
//Confirmation page option. Choose 1 if you want a confirmation page and 0 if you want the form submitted right after the submit button is clicked.
$confirm_option="1";
// message to the visitor thanking them for filling out the form
$thanks="<table class=confirm_table border=0>
<tr valign=top>
<td>
[b]Thank You! Have a great day![/b]</p>
</p>
</p>
</p>
</td></tr></table>
";
?>
Spero possiate essemi di aiuto, non capisco perchè non mi arrivano ste mail... uff... sarà mica gmail? ...Naaaaaa
Sarà xyz? ...boo!?