- Home
- Categorie
- Coding e Sistemistica
- PHP
- Aiuto con applicazione CAPTCHA
-
Aiuto con applicazione CAPTCHA
Ciao ragazzi,
mi serve una mano con l'applicazione di un captcha con un php script per top 100!
Allora comincio dallo script della Top 100:
la top 100 contiene varie pagine fatte ovviamente in php, tra le quali ci sono il file per installare la top 100 nel database mysql, il file config.php, la pagina per fare iscrivere i siti e altre!
Di seguito vi posto il contenuto della pagina che permette ai siti di iscriversi (join.php)
[php]
<?
// Report all script errors on this page
error_reporting(E_ALL);
// Including CONFIG.PHP which includes all configurations
require("config.php");
// Including language file
include("languages/" . $lang_file);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title><? echo htmlspecialchars($topsite_name) ." ( " . $text['107'] ." : ". mysql_result(mysql_query("SELECT COUNT(1) FROM ". $table ."_sites"),0) . " )"; ?></title>
<link rel="stylesheet" type="text/css" href="http://vincenzothebest.altervista.org/Top100/Skintop-nera.css" /><script language=javascript>
function showimage()
{
if(!document.images)return;
document.images.icons.src="http://www.giorgiotave.it/forum/images/flags/"+document.form.country.options[document.form.country.selectedIndex].value;
}
</script>
</head>
<body id="container">
<div id="header"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<div id="headerlogo"></div>
</td>
</tr>
</table></div>
<?
// Check if the installation file still is located in the topsites directory
if(file_exists("install.php"))
{ // If it is... give error
?>
<table cellpadding="2" cellspacing="0" width="75%" align="center">
<tr>
<td colspan="2"><br><hr /><br></td>
</tr>
</table>
<table border="1" cellpadding="2" cellspacing="0" width="50%" class="content" align="center">
<tr class="title">
<td width="100%" align="center"><? echo $text['1'] ?></td>
</tr>
<tr>
<td width="100%"><? echo $text['9'] ?> ...</td>
</tr>
</table>
<?
}
else
{ // Else start executing the script
?><center>
<div align="center" style="padding:3px;width:75%;">
<ul id="maintab" class="basictab">
<li><a href="index.php"><? echo $text['2'] ?></a></li>
<li rel="references"><a href="#">Aggiungi il tuo sito ▼</a></li>
<li rel="references2"><a href="#">Recupera i tuoi dati ▼</a></li>
<li rel="references3"><a href="#">Gestisci i tuoi dati ▼</a></li>
<li rel="references4"><a href="#">Utilità per il tuo sito ▼</a></li>
</ul>
<div id="references" class="submenustyle">
<a href="<? echo $_SERVER['PHP_SELF'] ?>"><? echo $text['3'] ?></a>
<a href="http://vincenzothebest.altervista.org/Top100/faq.html">F.A.Q.</a>
<a href="http://vincenzothebest.altervista.org/Top100/regolamento.html">Regolamento</a>
</div><div id="references2" class="submenustyle">
<a href="lostid.php"><? echo $text['5'] ?></a>
<a href="lostcode.php"><? echo $text['6'] ?></a>
<a href="passreset.php"><? echo $text['7'] ?></a>
</div>
<div id="references3" class="submenustyle">
<a href="edit.php"><? echo $text['4'] ?></a>
<a href="admin.php"><? echo $text['8'] ?></a>
</div>
<div id="references4" class="submenustyle">
<a href="http://vincenzothebest.altervista.org/Top100/manuale_banner.html">Manuale: Come creare un banner</a>
</div>
<script type="text/javascript">
//initialize tab menu, by passing in ID of UL
initalizetab("maintab")
</script>
<div id="references" class="submenustyle">
<a href="<? echo $_SERVER['PHP_SELF'] ?>"><font class="active"><? echo $text['3'] ?></font></a>
<a href="http://vincenzothebest.altervista.org/Top100/faq.html">F.A.Q.</a>
<a href="http://vincenzothebest.altervista.org/Top100/regolamento.html">Regolamento</a>
</div><div id="references2" class="submenustyle">
<a href="lostid.php"><? echo $text['5'] ?></a>
<a href="lostcode.php"><? echo $text['6'] ?></a>
<a href="passreset.php"><? echo $text['7'] ?></a>
</div>
<div id="references3" class="submenustyle">
<a href="edit.php"><? echo $text['4'] ?></a>
<a href="admin.php"><? echo $text['8'] ?></a>
</div><div id="references4" class="submenustyle">
<a href="http://vincenzothebest.altervista.org/Top100/manuale_banner.html">Manuale: Come creare un banner</a>
</div>
</div>
</center><?
// Show form to add your site
if(!isset($_POST['submit']))
{
?>
<center>
<table style="margin-top: 30px;" border="1" cellpadding="2" cellspacing="0" width="50%" class="content" align="center">
<tr class="title">
<form method="POST" name=form>
<input type="hidden" name="submit" value="1">
<td width="100%" colspan="2">
<p align="center"><? echo $text['73'] ?></td>
</tr>
<tr>
<td width="50%"><? echo $text['36'] ?> :</td>
<td width="50%"><input type="text" name="sitename" size="24" maxlength="50"></td>
</tr>
<tr>
<td width="50%"><? echo $text['37'] ?> :</td>
<td width="50%"><input type="text" name="url" size="24" maxlength="100"></td>
</tr>
<tr>
<td width="50%"><? echo $text['38'] ?> [ 88 x 31 ] :</td>
<td width="50%"><input type="text" name="buttonurl" size="24" maxlength="125"></td>
</tr>
<tr>
<td width="50%"><? echo $text['39'] ?> :</td>
<td width="50%"><input type="text" name="email" size="24" maxlength="75"></td>
</tr>
<tr>
<td width="50%"><? echo $text['137'] ?> :</td>
<td width="50%"><select name="country" onChange="showimage()"><?// Selecting different flags directory 'images/flags'
$handle = opendir('images/flags');
while(false!==($file = readdir($handle)))
{
if($file != "." AND $file != "..")
{
if($file == "flag_oth.gif")
{
$selected = " selected";
}
else
{
$selected = " ";
}echo "<option value=\"" . $file . "\"" . $selected . ">" . $file . "</option>\n"; }
}
closedir($handle);
?>
</select><img src="http://www.giorgiotave.it/forum/images/flags/flag_oth.gif" name="icons" border="1" hspace="10"></td>
</tr>
<tr>
<td width="50%" valign="top"><? echo $text['40'] ?> :</td>
<td width="50%"><textarea rows="7" name="description" cols="26"></textarea></td>
</tr>
<tr>
<td width="50%" valign="top"><? echo $text['22'] ?> :</td>
<td width="50%"><input type="password" name="pssw" size="12" maxlength="25"></td>
</tr>
<tr>
<td width="50%" valign="top"><? echo $text['22'] ?> [ <? echo $text['59'] ?> ]:</td>
<td width="50%"><input type="password" name="pssw2" size="12" maxlength="25"></td>
</tr>
<tr>
<td width="100%" valign="top" colspan="2">
<p align="center"><input type="submit" value="<? echo $text['72'] ?>"></td>
</tr>
</table></center>
<?
}
// Form has been submitted
if(isset($_POST['submit']))
{
// Checking if email isn't used before to register a website
$query = mysql_query("SELECT COUNT(1) FROM " . $table . "_sites WHERE email = '" . $_POST['email'] . "'");
$result = mysql_result($query,0);
// If email has been registered, give error
if(!empty($result))
{
?>
<table border="1" cellpadding="2" cellspacing="0" width="50%" class="content" align="center">
<tr class="title">
<td width="100%"><p align="center"><? echo $text['73'] ?></td>
</tr>
<tr>
<td width="100%"><? echo $text['74'] ?> ...
<br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a></td>
</tr>
</table>
<?
}
else
{ // If email hasn't been registered, run script to add site
?>
<table border="1" cellpadding="2" cellspacing="0" width="50%" align="center">
<tr class="title">
<td width="100%"><p align="center"><? echo $text['73'] ?></td>
</tr>
<tr class="content">
<td width="100%">
<?
// If sitename wasn't filled in
if(empty($_POST['sitename']))
{
?>
<? echo $text['75'] ?>
<br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a>
<?
}
// If URL wasn't filled in
elseif(empty($_POST['url']))
{
?>
<? echo $text['76'] ?>
<br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a>";
<?
}
// If email wasn't filled in
elseif(empty($_POST['email']))
{
?>
<? echo $text['77'] ?>
<br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a>
<?
}
// If description wasn't filled in
elseif(empty($_POST['description']))
{
?>
<? echo $text['78'] ?>
<br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a>
<?
}
// If password / confirm password weren't filled in
elseif(empty($_POST['pssw']) OR empty($_POST['pssw2']))
{
?>
<? echo $text['79'] ?>
<br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a>
<?
}
else
{
// If passwords are not the same
if($_POST['pssw'] != $_POST['pssw2'] OR empty($_POST['pssw']) OR empty($_POST['pssw2']))
{
?>
<? echo $text['61'] ?> ...
<br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a>
<?
}
else
{
// Not encrypted version of password
$pssw = $_POST['pssw'];
// Encrypted version of password
$pssw_encrypted = md5($_POST['pssw']);
$POST['country'] = str_replace("flag","", $_POST['country']);
$_POST['country'] = str_replace(".gif","", $_POST['country']);
$date = date("dmY");// Insert data of website into database mysql_query("INSERT INTO " . $table . "_sites (sitename,url,buttonurl,email,description,password,hitsin,clicksin,hitsout,hitstotal,hitstoday,date,register_date,country,rank,ip) VALUES ('" . $_POST['sitename'] . "','" . $_POST['url'] . "','" . $_POST['buttonurl'] . "','" . $_POST['email'] . "','" . $_POST['description'] . "','" . $pssw_encrypted . "','0','0','0','0','" . $date . " | 0','" . $date . " | 1',NOW(),'" . $_POST['country'] . "','-','" . $_SERVER['REMOTE_ADDR'] . "')") or die (mysql_error()); $query = mysql_query("SELECT * FROM " . $table . "_sites WHERE email = '" . $_POST['email'] . "' AND url = '" . $_POST['url'] . "'") or die(mysql_error()); while($row = mysql_fetch_assoc($query)) { $memberid = $row['memberid']; } // Creating row for ratings for this website mysql_query("INSERT INTO " . $table . "_rate VALUES ('$memberid','0','0')") or die (mysql_error()); $sitename = htmlspecialchars($_POST['sitename']); $email = htmlspecialchars($_POST['email']); $url = htmlspecialchars($_POST['url']); $buttonurl = htmlspecialchars($_POST['buttonurl']); $description = htmlspecialchars($_POST['description']); $message = "<font style=\"font-family: verdana; font-size: 8pt\"> Hai fatto richiesta alla top100: " . $webmaster_url . ",<br> Ecco perchè vi inviamo il riepilogo dei vostri dati. La preghiamo di conservare questa e-mail. La password sottostante è decriptata ma nei nostri server è criptata per proteggervi da hacker.!<br><br> INFORMAZIONI ACCOUNT " . $memberid . "<br> ID: " . $memberid . "<br> Nome Sito : " . $sitename . "<br> URL : " . $url . "<br> Button URL : " . $buttonurl . "<br> Descrizione : " . $description . "<br> Password : " . $pssw . "<br> <br><br>Grazie,<br> Webmaster di " . $webmaster_url . "</font>"; mail("$email","Ti Sei Iscritto a: " . $topsite_name . " !!!","$message","From: Ti Sei Iscritto a: " . $topsite_name . " !!!<" . $webmaster_email . ">\nContent-Type: text/html; charset=iso-8859-1"); if($webmaster_sendmail) { $message = "<font style=\"font-family: verdana; font-size: 8pt\"> Un nuovo membro si è iscritto alla tua top100, ecco i suoi dati:<br><br>INFORMAZIONI ACCOUNT " . $memberid . "<br> ID: " . $memberid . "<br> Nome Sito : " . $sitename . "<br> URL : " . $url . "<br> Button URL : " . $buttonurl . "<br> Descrizione : " . $description . "<br> Password : " . $pssw . "<br> <br><br>Grazie,<br> Webmaster di " . $webmaster_url . "</font>"; mail("$webmaster_email","Nuovo Membro Nella TOP100", "$message","From: Nuovo Membro Nella TOP100<" . $webmaster_email . ">\nContent-Type: text/html; charset=iso-8859-1"); }
?>
<? echo $text['80'] ?><br><br>
<? echo $text['81'] ?>:<br><br><center>
<textarea cols="45" rows="5" onClick="this.select()"><a href="<? echo $script_url ?>/index.php?id=<? echo $memberid ?>" target="_blank"><img src="<? echo $script_url ?>/img.php?id=<? echo $memberid ?>" border="0"></a></textarea><br>
<a href="index.php"><< <? echo $text['82'] ?></a></center>
<?
}
}
?>
</td>
</tr>
</table>
<?
}
}
}
?>
<table cellpadding="0" cellspacing="0" width="75%" align="center">
<tr>
<td width="100%"><br><hr /></td>
</tr>
</table>
<?
$time = $debug->endTimer();
echo "<center>";echo "\n<br>Pagina caricata in : " . $time . " secondi.";
echo "</center>";
include("footer.txt");</body>
</html>
?>[/php]
In questa pagina voglio integrare lo script del CAPTCHA ma non so proprio come fare!
Il Captcha richiede la creazione di una tabella nel database
ed è la seguente:
[php]CREATE TABLE validation (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
url_key CHAR(40) UNIQUE NOT NULL,
captcha CHAR(32) NOT NULL,
expire_date DATETIME NOT NULL,PRIMARY KEY(id),
INDEX(url_key)
);
[/php]poi lo script presenta due parti:
- questa parte permette il funzionamento dello script:
[php]<?php
$pdo = new PDO('mysql:host=localhost;dbname=captcha', 'root', '');
$stmt = $pdo->prepare("SELECT * FROM validation WHERE url_key = ? AND expire_date > NOW()");
$stmt->execute(array($_GET['token']));$row = $stmt->fetch(PDO::FETCH_ASSOC);
$texture = imagecreatefrompng('texture.png');
$source = imagecolorat($texture, rand(0, imagesx($texture)), rand(0, imagesy($texture)));
$r = ($source >> 16 & 0xff) + 50;
$g = ($source >> 8 & 0xff) + 50;
$b = ($source & 0xff) + 50;
$text_color = imagecolorallocate($texture, $r, $g, $b);imagestring($texture, 5, (imagesx($texture) - strlen($row['captcha']) * 5)/ 2, 5, $row['captcha'], $text_color);
header('Content-Type: image/png');
imagepng($texture);
imagedestroy($texture);
?>
[/php]- questa invece serve a controllare la corretta immissione dei caratteri da parte di coloro che si vogliono iscrivere:
[php]<?php
function random_string($len)
{
$string = "";
$chars = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
"l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
"w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G",
"H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
"S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2",
"3", "4", "5", "6", "7", "8", "9");
for($i = 0; $i < $len; ++$i)
{
shuffle($chars);
$string .= $chars[0];
}return $string;
}$message = 'Inserisci la scringa alphanumerica per effettuare la validazione:';
$pdo = new PDO('mysql:host=localhost;dbname=captcha', 'root', '');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);if(isset($_POST['validate_token']))
{
// Eseguo la validazione
$stmt = $pdo->prepare("SELECT * FROM validation WHERE url_key = ? AND expire_date > NOW()");
$stmt->execute(array($_POST['token']));$row = $stmt->fetch(PDO::FETCH_ASSOC);
$message = ($row && ($row['captcha'] == $_POST['validate_token'])) ? 'token corretto' : 'token <strong>NON</strong> corretto';
$stmt = $pdo->prepare("DELETE FROM validation WHERE url_key = ?");
$stmt->execute(array($_POST['token']));
}// Elimino tutti i record scaduti
$pdo->query("DELETE FROM validation WHERE expire_date <= NOW()");// Genero casualmente un record per la tabella validation
$url_key = sha1(uniqid(rand(), true)); // Possiamo (e dovremmo) fare meglio
$captcha = random_string(6);
$stmt = $pdo->prepare("INSERT INTO validation (id, url_key, captcha, expire_date) VALUES ('', ?, ?, DATE_ADD(NOW(), INTERVAL 5 MINUTE))");
$stmt->execute(array($url_key, $captcha));?>
<html>
<head>
<title>CAPTCHA test</title>
</head>
<body>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name="token" value="<?php echo $url_key; ?>" />
<p>
<?php echo $message; ?>
</p>
<img src="captcha.php?token=<?php echo $url_key; ?>" width="200" height="30" /><br/>
<input type="text" name="validate_token" />
<input type="submit" name="action" value="Test" />
</form>
</body>
</html>
[/php]Questo è tutto! La mia difficoltà sta nell'integrare il CAPTCHA allo script della Top 100!
C'è qualcuno esperto in php che può aiutarmi?
P.s il lavoro e l'aiuto verranno ricambiati assolutamente!
-
Il problema dei CAPTCHA è che ultimamente i BOT riecono a leggerli sempre meglio, ci sono soluzioni migliori, e molto più semplici...
-
Se ti posto il codice dello script gli sapresti applicare qualche protezione?
-
Si certo!
Che cosa intendevi con:
@VincenzoL said:P.s il lavoro e l'aiuto verranno ricambiati assolutamente!
?
-
Avrei linkato la persona che mi avrebbe aiutato
-
avanti posta pure il codice!
-
Allora ti preavviso che è un modulo che non fa riferimento ad un'altra pagina a parte in php, ma la sua azione è $_POST
Ho cercato di fissare la condizione che se il campo rimane vuoto il modulo non deve essere eseguito, però il modulo anche in presenza di campi vuoti viene eseguito comunque!
Di seguito ho postato il codice dello script:
[PHP]
<?
// Show form to add your site
if(!isset($_POST['submit']))
{
?>
<table style="margin-top: 30px;" border="1" cellpadding="2" cellspacing="0" width="50%" class="content" align="center">
<tr class="title">
<form method="POST" name=form>
<input type="hidden" name="submit" value="1">
<td width="100%" colspan="2">
<p align="center"><? echo $text['73'] ?></td>
</tr>
<tr>
<td width="50%"><? echo $text['36'] ?> :</td>
<td width="50%"><input type="text" name="sitename" size="24" maxlength="50"></td>
</tr>
<tr>
<td width="50%"><? echo $text['37'] ?> :</td>
<td width="50%"><input type="text" name="url" size="24" maxlength="100"></td>
</tr>
<tr>
<td width="50%"><? echo $text['38'] ?> [ 88 x 31 ] :</td>
<td width="50%"><input type="text" name="buttonurl" size="24" maxlength="125"></td>
</tr>
<tr>
<td width="50%"><? echo $text['39'] ?> :</td>
<td width="50%"><input type="text" name="email" size="24" maxlength="75"></td>
</tr>
<tr>
<td width="50%"><? echo $text['137'] ?> :</td>
<td width="50%"><select name="country" onChange="showimage()"><?
// Selecting different flags directory 'images/flags'
$handle = opendir('images/flags');
while(false!==($file = readdir($handle)))
{
if($file != "." AND $file != "..")
{
if($file == "flag_oth.gif")
{
$selected = " selected";
}
else
{
$selected = " ";
}
echo "<option value="" . $file . """ . $selected . ">" . $file . "</option>\n";
}
}
closedir($handle);
?>
</select><img src="images/flags/flag_oth.gif" name="icons" border="1" hspace="10"></td>
</tr>
<tr>
<td width="50%" valign="top"><? echo $text['40'] ?> :</td>
<td width="50%"><textarea rows="7" name="description" cols="26"></textarea></td>
</tr>
<tr>
<td width="50%" valign="top"><? echo $text['22'] ?> :</td>
<td width="50%"><input type="password" name="pssw" size="12" maxlength="25"></td>
</tr>
<tr>
<td width="50%" valign="top"><? echo $text['22'] ?> [ <? echo $text['59'] ?> ]:</td>
<td width="50%"><input type="password" name="pssw2" size="12" maxlength="25"></td>
</tr>
<tr>
<td width="100%" valign="top" colspan="2">
<p align="center"><input type="submit" value="<? echo $text['72'] ?>"></td>
</tr>
</table>
<?
}
// Form has been submitted
if(isset($_POST['submit']))
{
// Checking if email isn't used before to register a website
$query = mysql_query("SELECT COUNT(1) FROM " . $table . "_sites WHERE email = '" . $_POST['email'] . "'");
$result = mysql_result($query,0);
// If email has been registered, give error
if(!empty($result))
{
?>
<table border="1" cellpadding="2" cellspacing="0" width="50%" class="content" align="center">
<tr class="title">
<td width="100%"><p align="center"><? echo $text['73'] ?></td>
</tr>
<tr>
<td width="100%"><? echo $text['74'] ?> ...
<br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a></td>
</tr>
</table>
<?
}
else
{ // If email hasn't been registered, run script to add site
?>
<table border="1" cellpadding="2" cellspacing="0" width="50%" align="center">
<tr class="title">
<td width="100%"><p align="center"><? echo $text['73'] ?></td>
</tr>
<tr class="content">
<td width="100%">
<?
// If sitename wasn't filled in
if(empty($_POST['sitename']))
{
?>
<? echo $text['75'] ?>
<br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a>
<?
}
// If URL wasn't filled in
elseif(empty($_POST['url']))
{
?>
<? echo $text['76'] ?>
<br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a>";
<?
}
// If email wasn't filled in
elseif(empty($_POST['email']))
{
?>
<? echo $text['77'] ?>
<br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a>
<?
}
// If description wasn't filled in
elseif(empty($_POST['description']))
{
?>
<? echo $text['78'] ?>
<br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a>
<?
}
// If password / confirm password weren't filled in
elseif(empty($_POST['pssw']) OR empty($_POST['pssw2']))
{
?>
<? echo $text['79'] ?>
<br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a>
<?
}
else
{
// If passwords are not the same
if($_POST['pssw'] != $_POST['pssw2'] OR empty($_POST['pssw']) OR empty($_POST['pssw2']))
{
?>
<? echo $text['61'] ?> ...
<br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a>
<?
}
else
{
// Not encrypted version of password
$pssw = $_POST['pssw'];
// Encrypted version of password
$pssw_encrypted = md5($_POST['pssw']);
$POST['country'] = str_replace("flag","", $_POST['country']);
$_POST['country'] = str_replace(".gif","", $_POST['country']);
$date = date("dmY");
[/PHP]
-
lo script che hai postato non è completo manca qualcosa
è troncato sul fondo...
comunque ora gli do un'occhiata
-
[PHP]
<?
// Show form to add your site//ATTENZIONE PER OGNI DOMANDA INSERIRE UNA RISPOSTA
$aDOMANDE=array('Quanto fa 10+3?', 'quale lettera è la iniziale di <b>BIANCO</b>?', 'scrivi solo la parola <b>ROMA</b>');
$aRISPOSTE=array('13', 'B', 'Roma');$TOTALE_domande=count($aDOMANDE); $TOTALE_domande=$TOTALE_domande-1;
//for ($iQ = 0; $iQ < count($righeCheck); $iQ++) {if(!isset($_POST['submit']))
{
?>
<table style="margin-top: 30px;" border="1" cellpadding="2" cellspacing="0" width="50%" class="content" align="center">
<tr class="title">
<form method="POST" name=form>
<input type="hidden" name="submit" value="1">
<td width="100%" colspan="2">
<p align="center"><? echo $text['73'] ?></td>
</tr>
<tr>
<td width="50%"><? echo $text['36'] ?> :</td>
<td width="50%"><input type="text" name="sitename" size="24" maxlength="50"></td>
</tr>
<tr>
<td width="50%"><? echo $text['37'] ?> :</td>
<td width="50%"><input type="text" name="url" size="24" maxlength="100"></td>
</tr>
<tr>
<td width="50%"><? echo $text['38'] ?> [ 88 x 31 ] :</td>
<td width="50%"><input type="text" name="buttonurl" size="24" maxlength="125"></td>
</tr>
<tr>
<td width="50%"><? echo $text['39'] ?> :</td>
<td width="50%"><input type="text" name="email" size="24" maxlength="75"></td>
</tr>
<tr>
<td width="50%"><? echo $text['137'] ?> :</td>
<td width="50%"><select name="country" onChange="showimage()"><?
// Selecting different flags directory 'images/flags'
$handle = opendir('images/flags');
while(false!==($file = readdir($handle)))
{
if($file != "." AND $file != "..")
{
if($file == "flag_oth.gif")
{
$selected = " selected";
}
else
{
$selected = " ";
}
echo "<option value="" . $file . """ . $selected . ">" . $file . "</option>\n";
}
}
closedir($handle);
?>
</select><img src="images/flags/flag_oth.gif" name="icons" border="1" hspace="10"></td>
</tr>
<tr>
<td width="50%" valign="top"><? echo $text['40'] ?> :</td>
<td width="50%"><textarea rows="7" name="description" cols="26"></textarea></td>
</tr>
<tr>
<td width="50%" valign="top"><? echo $text['22'] ?> :</td>
<td width="50%"><input type="password" name="pssw" size="12" maxlength="25"></td>
</tr>
<tr>
<td width="50%" valign="top"><? echo $text['22'] ?> [ <? echo $text['59'] ?> ]:</td>
<td width="50%"><input type="password" name="pssw2" size="12" maxlength="25"></td>
</tr>
<tr>
<td width="100%" valign="top" colspan="2">
Sei umano?<br>
<?
$idDomanda=rand(0,$TOTALE_domande);
echo $aDOMANDE[$idDomanda];
?>
<input type="text" name="risposta" size="40" maxlength="100">
<input type="Hidden" name="idDomanda" value="<? echo $idDomanda; ?>"></td>
</tr>
<tr>
<td width="100%" valign="top" colspan="2">
<p align="center"><input type="submit" value="<? echo $text['72'] ?>"></td>
</tr>
</table>
<?
}
// Form has been submitted
if(isset($_POST['submit']) and isset($_POST['sitename']) and isset($_POST['url']))
//con [ and isset($_POST['nomeCAMPO']) ] aggiungi i campi che devono essere riempiti per l'invio del form
{//CONDIZIONE DI CONTROLLO DELLA PAGINA RANDOM uso strtolower() per evitare problemi di scrittura tar minuscolo e maiuscolo strtolower() trasforma tutto in minuscolo
if( strtolower($aRISPOSTE[$idDomanda]) != strtolower($_POST['risposta']) ) {
//stampo l'errore magari quello lo peronalizzi (non ho capito la logica...)echo strtolower($aRISPOSTE[$idDomanda])."<br>";
echo strtolower($_POST['risposta'])."<br>";
?><table border="1" cellpadding="2" cellspacing="0" width="50%" class="content" align="center">
<tr class="title">
<td width="100%"><p align="center">ERRORE....</td>
</tr>
<tr>
<td width="100%">La risposta non è corretta ...
<br><br><a href="post.php"><< torna indietro</a></td>
</tr>
</table>
<?
} else {// Checking if email isn't used before to register a website
$query = mysql_query("SELECT COUNT(1) FROM " . $table . "_sites WHERE email = '" . $_POST['email'] . "'");
$result = mysql_result($query,0);
// If email has been registered, give error
if(!empty($result))
{
?>
<table border="1" cellpadding="2" cellspacing="0" width="50%" class="content" align="center">
<tr class="title">
<td width="100%"><p align="center"><? echo $text['73'] ?></td>
</tr>
<tr>
<td width="100%"><? echo $text['74'] ?> ...
<br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a></td>
</tr>
</table>
<?
}
else
{ // If email hasn't been registered, run script to add site
?>
<table border="1" cellpadding="2" cellspacing="0" width="50%" align="center">
<tr class="title">
<td width="100%"><p align="center"><? echo $text['73'] ?></td>
</tr>
<tr class="content">
<td width="100%">
<?
// If sitename wasn't filled in
if(empty($_POST['sitename']))
{
?>
<? echo $text['75'] ?>
<br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a>
<?
}
// If URL wasn't filled in
elseif(empty($_POST['url']))
{
?>
<? echo $text['76'] ?>
<br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a>";
<?
}
// If email wasn't filled in
elseif(empty($_POST['email']))
{
?>
<? echo $text['77'] ?>
<br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a>
<?
}
// If description wasn't filled in
elseif(empty($_POST['description']))
{
?>
<? echo $text['78'] ?>
<br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a>
<?
}
// If password / confirm password weren't filled in
elseif(empty($_POST['pssw']) OR empty($_POST['pssw2']))
{
?>
<? echo $text['79'] ?>
<br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a>
<?
}
else
{
// If passwords are not the same
if($_POST['pssw'] != $_POST['pssw2'] OR empty($_POST['pssw']) OR empty($_POST['pssw2']))
{
?>
<? echo $text['61'] ?> ...
<br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a>
<?
}
else
{
// Not encrypted version of password
$pssw = $_POST['pssw'];
// Encrypted version of password
$pssw_encrypted = md5($_POST['pssw']);
$POST['country'] = str_replace("flag","", $_POST['country']);
$_POST['country'] = str_replace(".gif","", $_POST['country']);
$date = date("dmY");
}
}
}
}
}
?>
[/PHP]
-
Non ho capito in questa parte
[PHP]<table border="1" cellpadding="2" cellspacing="0" width="50%" class="content" align="center">
<tr class="title">
<td width="100%"><p align="center">ERRORE....</td>
</tr>
<tr>
<td width="100%">La risposta non è corretta ...
<br><br><a href="post.php"><< torna indietro</a></td>
</tr>
</table>[/PHP]perchè fai riferimento a post.php?
Cmq ti ho allegato il file intero dello script cosi ne capisci per intero la sua logica...;)
NB: puntualizzo che la pagina che ti ho allegato contiene un form che permette alla gente di iscriversi ad una classifica! Questo file fa riferimento anche ad un file di installazione, che ha creato le tabelle nel mio db mysql)
-
Scusa ma lo script che ti ho inviato è già funzionante...
la parte
[PHP]
<table border="1" cellpadding="2" cellspacing="0" width="50%" class="content" align="center">
<tr class="title">
<td width="100%"><p align="center">ERRORE....</td>
</tr>
<tr>
<td width="100%">La risposta non è corretta ...
<br><br><a href="post.php"><< torna indietro</a></td>
</tr>
</table>
[/PHP]la puoi personalizzare da solo
post.php è il nome della pagina che ho usato io per la prova li puoi mettere quelo che vuoiper il resto lo script funziona...
-
Come immaginavo mi da errori di sintassi...come facevi a dire che lo script funziona se non hai visto il resto dello script?
Per quel motivo ti ho postato la pagina intera...Spero tu voglia aiutarmi...
-
??? ma dico ??? ma il lavoro è tuo? o è mio?
no perchè mi sta venendo un dubbio...comunque il file che mi hai invato non funziona e da errore perchè mancano dei file di inclusione...
non puoi mica scaricar il lavoro così se vuoi un aiuto devi anche collaborare
io sullo script che mi hai inviato all'inizio ho realizzato un sistema funzionante ora potresti anche provare ad inserirlo tu nel tuo progetto
se poi trovi dei problemi come hai fatto prima scirivi e dici che problemi hai trovato e via via si cerca di darti una mano ma per favore collabora!
-
Si scusa hai ragione! Cmq molto probabilmente non ti funziona la pagina perchè come ti ho spiegato lo script va installato in un database mysql!
Cmq l'errore di sintassi si riferiva alle parentesi graffe chiuse in fondo allo script...