ciao ragazzi ho un problema nel inserire il controllo capctka vi posto tutto il cod semi potreste dare una mano inoltre non saprei se inserire lo script sendmail.php dov e il form vi poso lo script
Codice PHP:
<?php
include_once ("includes/include.php");
$ip = $_SERVER['REMOTE_ADDR'];
$date = date('Y-m-d H:i:s');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Documento senza titolo</title>
<script type="text/javascript" src="script-javascript/flashobject.js"></script>
<SCRIPT TYPE="text/javascript" SRC="script-javascript/content.js"></SCRIPT>
<script src="script-javascript/AC_RunActiveContent.js" type="text/javascript"></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="stili-css/marik.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
html, body {
width: 100% ;
margin: 0px auto;
text-align: center;
padding: 15px;
background-color: #dddddd;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
#captcha{margin:0 auto;text-align:center}
.errore{color:#f00}
.style2 {
font-size: 14px;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
.style3 {font-size: 14px; font-family: Verdana, Arial, Helvetica, sans-serif; color: #000099; }
-->
</style>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<body>
<table width="1024" border="0" align="center" class="sfondo">
<tr>
<td valign="top"> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="sfondomenualto">
<tr>
<td width="1024"></td>
<div id ="menu"></div>
<script type="text/javascript">
var fo = new FlashObject("flash/banner.swf", "Menu", "100%", "300", "false", "");
fo.addParam("quality", "high");
fo.addParam("menu", "false");
fo.write("menu");
</script>
</tr>
<tr>
</tr>
</table>
<form action="" method="post">
<table width="581" border="0" align="center">
<tr>
<td width="177" rowspan="14"></td>
<td height="44" colspan="9"></td>
</tr>
<tr>
<td height="20" colspan="9"> <div align="right"> </div></td>
</tr>
<tr>
<td colspan="3"></td>
<td height="24" colspan="5" valign="top"><div align="right">
<input name="Name" type="text" id="Name3" size="30">
</div></td>
<td width="29"></td>
</tr>
<tr>
<td colspan="3"></td>
<td height="24" colspan="5" valign="top"><div align="right">
<input name="cognome" type="text" id="cognome2" size="30">
</div></td>
<td width="29"></td>
</tr>
<tr>
<td height="24" colspan="3"></td>
<td colspan="5" valign="top"> <div align="right"> </div>
<div align="right">
<input name="telefono" type="text" id="telefono2" size="30">
</div></td>
<td width="29"></td>
</tr>
<tr>
<td height="26" colspan="3"></td>
<td colspan="5" valign="top"> <div align="right"> </div>
<div align="right">
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
<option selected>informazioni</option>
</select>
</div></td>
<td width="29"></td>
</tr>
<tr>
<td height="26" colspan="3"></td>
<td colspan="5" valign="top"><div align="right">
<input name="Email" type="text" id="cognome3" size="30">
</div></td>
<td width="29"></td>
</tr>
<tr>
<td height="26" colspan="4"></td>
<td width="46" valign="top"></td>
<td colspan="3" valign="top"><div align="right">
<input name="Email2" type="text" id="Email" size="30">
</div></td>
<td width="29"></td>
</tr>
<tr>
<td width="35" height="120"></td>
<td width="21"></td>
<td colspan="6"><div align="right">
<textarea name="Message" cols="30" rows="6" id="Message"></textarea>
</div></td>
<td width="29"></td>
</tr>
<tr>
<td height="25"></td>
<td></td>
<td width="52"></td>
<td colspan="5"><center>
<? echo "$ip";?></center></td>
<td></td>
</tr>
<tr>
<td height="20"></td>
<td></td>
<td valign="top"></td>
<td colspan="5" valign="top"><center>
<? echo "$date" ?></center></td>
<td></td>
</tr>
<tr>
<td colspan="2" rowspan="2" valign="top"><div align="right"></div></td>
<td rowspan="2" valign="top"><div align="right"></div></td>
<td height="24" colspan="4" valign="top"> <div align="left"><img src= "captcha/captcha.php" />
</div></td>
<td height="24" valign="top"><input name="code" type="text" id="code" size="10" /></td>
<td rowspan="3"></td>
</tr>
<tr>
<td height="20" colspan="5" valign="top"></td>
</tr>
<tr>
<td height="26" colspan="2" valign="top"></td>
<td valign="top"></td>
<td colspan="3" valign="top"> </td>
<td width="43" valign="top"><input type="submit" name="Submit" value="Invia"></td>
<td width="135" valign="top"><div align="center">
<input type="submit" name="Submit2" value="Reset">
</div></td>
</tr>
</table>
</form>
</p></td>
</tr>
<tr>
<td height="24" valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="fotter">
<tr>
<td width="1024" height="24"><div align="center"><? echo _NOME_BOLD_ ; ?></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="44"><div align="center" class="copyrigt" >Copyright © 2005-2007
[url="http://www.xxxxxxxxx.it"]<? echo POWERED_BY ; ?>[/url]</div></td>
</tr>
</table>
</body>
</html>
mailform.php
Codice PHP:
<?
include 'include/config.php';
$adminaddress = "info@xxxxxxxxxxxxxxxxxxx.it";
$siteaddress ="http://www.xxxxxxxxxxxxxxx.it";
$sitename = "xxxxxxxxxxxxxxxxxxxx";
$CONFIG['expire'] = 60;
$CONFIG['regexpire'] = 24; //in ore
$CONFIG['expire'] = 60;
$CONFIG['regexpire'] = 24; //in ore
$CONFIG['check_table'] = array(
"name" => "check_global",
"email" => "check_global"
);
function check_email($value)
{
global $CONFIG;
$value = trim($value);
if (($value == ""))
{
echo"Il campo non può essere lasciato vuoto";
}
else return"OK";
}
//--------------
define('AUTH_LOGGED', 99);
define('AUTH_NOT_LOGGED', 100);
define('AUTH_USE_COOKIE', 101);
define('AUTH_USE_LINK', 103);
define('AUTH_INVALID_PARAMS', 104);
define('AUTH_LOGEDD_IN', 105);
define('AUTH_FAILED', 106);
define('REG_ERRORS', 107);
define('REG_SUCCESS', 108);
define('REG_FAILED', 109);
$conn = @mysql_connect($CONFIG['host'], $CONFIG['user'], $CONFIG['pass']) or die('Impossibile stabilire una connessione');
@mysql_select_db($CONFIG['dbname']) or die("Errore nel DB");
//No need to change anything below ...
// Gets the date and time from your server
$date = date("m/d/Y H:i:s");
// Gets the IP Address
if ($REMOTE_ADDR == "") $ip = "no ip";
else $ip = getHostByAddr($REMOTE_ADDR);
// Gets the POST Headers - the Flash variables
$action = $HTTP_POST_VARS['action'] ;
$email = $HTTP_POST_VARS['email'] ;
$name = $HTTP_POST_VARS['name'] ;
$cognome = $HTTP_POST_VARS['cognome'] ;
$comments = $HTTP_POST_VARS['comments'] ;
$telefono = $HTTP_POST_VARS['telefono'] ;
$oggetto = $HTTP_POST_VARS['oggetto'] ;
//Process the form data!
// and send the information collected in the Flash form to Your nominated email address
if ($action == "send")
{
//Innanzitutto controlliamo la var.le name:
$controllo = check_email($email);
if ($controllo != "OK")
{
echo $controllo;
//Qui potresti anche far visualizzare una cosa del genere:
echo "
<A HREF=\"http://www.xxxxxxxxxxxx.com/homeita/\">Ritorna alla registrazione</A>";
}
else
{
//Ora inseriamo i dati nel DB.
//Ovviamente devi creare una tabella in cui inserire i dati ke passi con il post.
$link_db = mysql_connect($CONFIG['host'],$CONFIG['user'],$CONFIG['pass']);
mysql_select_db($CONFIG['dbname']);
$sql_insert = "INSERT INTO contact (name,email,telefono,oggetto,comments,date,ip) VALUES('$name','$email','$telefono','$oggetto','$comments','".date('Y-m-d H:i:s')."','".$_SERVER['REMOTE_ADDR']."')";
if (mysql_query($sql_insert))
{
echo "OK RIGA INSERITA
";
}
else
{
die(mysql_error());
}
mysql_close($link_db);
//
mail ("$adminaddress","informazioni",
"Il visitatore ha lasciato le seguenti informazioni \n
Name: $name
Email: $email\n
Telefono: $telefono
Messaggio:
------------------------------
$comments
Logged Info :
------------------------------
Using: $HTTP_USER_AGENT
Hostname: $ip
IP address: $REMOTE_ADDR
Date/Time: $date","FROM:$email" ) ;
//This sends a confirmation to your visitor
mail ("$email","Re:",
"Salve $name $cognome ,\n
abbiamo ricevuto il suo messaggio e presto sarà contattato.\n
Saluti dallo Staff di $sitename
By
$siteaddress","FROM:$adminaddress ") ;
//Confirmation is sent back to the Flash form that the process is complete
$sendresult = "Thank you. You will receive a confirmation email shortly.";
$send_answer = "answer=";
$send_answer .= rawurlencode($sendresult);
echo $send_answer;
}
}
?>
pagina dove c e il cod capcka
Codice PHP:
session_start();
$PHP_SELF = $_SERVER['PHP_SELF'];
$errore = 0;
if(isset($_POST['submit']) && isset($_SESSION['captcha'])) {
if(isset($_POST['code'])){
$_code = $_POST['code'];
if($_SESSION['captcha'] == $_code){
print " messaggio inviato con successo";
exit;
} else {
$errore = 1;
}
} else {
$errore = 1;
}
}
if(!isset($_SESSION['captcha'])){session_register('captcha');}
$PHP_SELF = $_SERVER['PHP_SELF'];
$stringa = '';
$cifre = 5;
for($i=1;$i<=$cifre;$i++){
$letteraOnumero = rand(1,2);
if($letteraOnumero == 1){
// lettera
$lettere = 'ABEFHKMNRVWX';
$x = rand(1,11);
$lettera = substr($lettere,$x,1);
$stringa .= $lettera;
} else {
$numero = rand(3,7);
$stringa .= $numero;
}
}
$_SESSION['captcha'] = $stringa;