Ciao,
io ho un altro problema sempre sulla stessa pagina che ho già postato mille volte....e la posto mille ed una:
Parliamo del captcha....a me succede questo:
-Compilo il form con campi a caso.
-Faccio il refresh della pagina e i campi mi rimangono in memoria (pass esclusa).
-Sbaglio appositamente la mail o un'altra cosa o ometto un campo, mi visualizza l'alert, clicco ok ed i campi compilati sono ancora li.
-Compilo tutto bene e salto il captcha....stessa storia, alert che manca il campo, ok e tutto è sempre li.
-Compilo tutto bene e sbaglio il captcha.....messaggio di errore che il captcha è sbagliato e quando clicco su ok la pagina si ricarica ma cancellando tutti i campi....
E' un bel pò fastidiosa la cosa....come posso evitarla???? Credo ci sia qualche sbavatura nel javascript del controllo del captcha....ma non so dove....
io ho un altro problema sempre sulla stessa pagina che ho già postato mille volte....e la posto mille ed una:
PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Join!</title>
<link href="SGT_CSS_1.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
background-color: #999;
background-image: url(Immagini/Home/Bg.gif);
background-repeat: repeat-x;
}
-->
</style>
<script type="text/javascript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
function CAPTCHA()
{
var car, min, max, dif, lun, inc;
car = "abcdefghijklmnopqrstuvwxyz";
car += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
car += "1234567890";
min = 5;
max = 5;
dif = max - min;
lun = Math.round((Math.random() * dif) + min);
inc = 0;
cod = "";
while (inc < lun)
{
cod += car.charAt(Math.round(Math.random() * car.length));
inc++;
}
return cod;
}<!--Crea il captcha -->
function Prova(){
document.getElementById("captcha").innerHTML = CAPTCHA();<!--crea immagine captcha -->
}
function Invia()
{
var key2 = document.enter.key2.value;
if (key2 != document.getElementById("captcha").innerHTML)
{
alert("Please enter a correct code");
document.enter.key2.value = "";
document.enter.key2.focus();
}
else
{
document.enter.method = "post";
document.enter.action = "<?php print($_SERVER['PHP_SELF']); ?>";
document.enter.submit();
}
}<!--Verifica il captch
//-->
</script><!--Java-->
</head>
<body onload=
"; Prova()">
<!--Rollover -->
<div id="centrale"><!--Banner alto --><!--Banner destro --><!--Titolo sito --><!--Sottotitolo -->
<div id="contenuti">
<!--Immagine membership-->
<!--Scritto per membership --><!--Immagine register -->
<div id="Register">
<?php
session_start(); // Maintain session state
header("Cache-control: private"); // Fixes IE6's back button problem.
// Dont allow members to go to add user page
if(@$_SESSION['user']) header("location: login.php");
elseif(@$_POST['user']){
// Get and set vars (without html characters)
$user = htmlspecialchars(strtolower($_POST["user"]));
$pass = htmlspecialchars($_POST["pass"]);
$permission = 0; // Default: user, until admin changes
$email = htmlspecialchars($_POST["email"]);
$url = htmlspecialchars($_POST["url"]);
// Add dots to date
$joined = $_POST["joined"];
// Create the string to append
$string = "\r\n". $user. "<del>". md5($pass). "<del>". $permission. "<del>". $email. "<del>". $joined;
// Make sure username doesn't already exist
//-----------------------------------------
// Include the flat-file
$file = file("users.php") or die("Problem getting the user details flat-file [users.php]");
// Get the size of file
$totalLines = sizeof($file);
// Get the users details line by line
$line = 0;
$match = 0;
do{
// Check the line isn't a comment
if("//" != substr($file[$line], 0, 2)){
// Break our records up
@list($username, $password, $permission, $email, $url, $joined) = explode("<del>", $file[$line]);
// Check the username and passwords match
if((strtolower($user) == strtolower($username))) $match = 1;
else $match = 0;
}
// Exit loop if match found
if($match) break;
// Increment line count
$line++;
} while($line < $totalLines);
// Only add new user if a match is not found
if($match){
?>
<script language = "javascript" type = "text/javascript">
<!-- // Go back
alert("Username already taken, taking you back to choose another");
history.go(-1);
-->
</script>
<?php
}
else{
// Open the users file
$fp = fopen("users.php", "a+");
// Append the new user to end of users file
fwrite($fp, $string);
// Close the file
fclose($fp);
// Redirect to index
header("location: index.php?new=1");
}
}
else{
?>
<?php
}
?>
<form name="enter" action="">
<table width="451" border = "0" align = "left" cellpadding = "10" cellspacing = "0" style = "height: 80%; text-align: left;">
<tr>
<td height="52" colspan = "3" align="left" valign = "top">
<span class = "bold">Join our member list!</span></td>
</tr>
<tr>
<td width = "162" height = "10" align="left" valign = "top">
<span class = "hilight">Username:</span>
</td>
<td width = "249" height = "10" align="left" valign = "top">
<input name = "user" type = "text" class = "text" id = "user" style = "width: 80%" tabindex = "1" maxlength="20">
</tr>
<tr>
<td width = "162" height = "10" align="left" valign = "top">
<span class = "hilight">Password:</span>
</td>
<td width = "249" height = "10" align="left" valign = "top">
<input name = "pass" type = "password" class = "text" id = "pass" style = "width: 80%" tabindex = "2" maxlength="20">
</td>
</tr>
<tr>
<td width = "162" height = "10" align="left" valign = "top">
<p class="hilight"> Repeat Password:</p></td>
<td width = "249" height = "10" align="left" valign = "top">
<p>
<input name = "pass2" type = "password" class = "text" id = "pass2" style = "width: 80%" tabindex = "3" maxlength="20">
</p></td>
</tr>
<tr>
<td width = "162" height = "10" align="left" valign = "top">
Email:
</td>
<td width = "249" height = "10" align="left" valign = "top">
<input type = "text" id = "email" name = "email" style = "width: 80%" class = "text" tabindex = "4">
</td>
</tr>
<tr>
<td width = "162" height = "10" align="left" valign = "top">
Repeat Email:
</td>
<td width = "249" height = "10" align="left" valign = "top">
<input type = "text" id = "url" name = "url" style = "width: 80%" class = "text" tabindex = "5">
</td>
</tr>
<tr>
<td width = "162" height = "10" align="left" valign = "top">
Join our newsletter:
</td>
<td width = "249" height = "10" align="left" valign = "top"><label>
<input type="checkbox" name="news" id="news" value="news" /></label>
<a href="Javascript:newsletter()" class="Linkage">About newsletter</a></td>
</tr>
<tr>
<td width = "162" height = "10" align="left" valign = "top">
Read and approve privacy policy:
</td>
<td width = "249" height = "10" align="left" valign = "top"><label>
<input type="checkbox" name="privacy" id="privacy" value="privacy" />
</label>
<a href="Javascript:privacy()" class="Linkage">Privacy policy</a></td>
</tr>
<tr>
<th width="199" height="74" scope="row"><p>Enter code from image (case sensitive):</p></th>
<td width="181"><label>
<center>
<span id="captcha"></span><br><br>
<input name="key2" type="text" id="key2" size="10">
</center>
</label>
</td>
</tr>
<tr>
<td width = "100" height = "79" colspan = "3" valign = "top"><input name = "submit" type = "Image" tabindex = "10" onfocus = "return checkFields();" src = "Immagini/Enter/Join.gif" alt = "arrow pointing right: next" align = "middle" onclick="Invia()"/> <input type = "hidden" name = "joined" value = "<?php print(date("d.m.Y H:i:s", mktime())); ?>" /></td>
</tr>
</table>
</form> <!--Form registrazione -->
<script language = "javascript" type = "text/javascript">
<!--// Check field values are correct before submitting
function checkFields(){
var flag = 1; // Return flag
// Check for empty values in important fields first
if(!document.getElementById("user").value || !document.getElementById("pass").value || !document.getElementById("pass2").value || !document.getElementById("email").value ||!document.getElementById("url").value ||!document.getElementById("news").value||!document.getElementById("privacy").value||!document.getElementById("key2").value){
alert("Please enter all values, join the newsletter and approve privacy terms");
document.getElementById("user").focus();
return true;
}
// Check that passwords are the same
else if(document.getElementById("pass").value != document.getElementById("pass2").value){
alert("Please enter two matching passwords");
document.getElementById("pass").value = '';
document.getElementById("pass2").value = '';
document.getElementById("pass").focus();
return true;
}
// Check that email are the same
else if(document.getElementById("email").value != document.getElementById("url").value){
alert("Please enter two matching email");
document.getElementById("email").value = '';
document.getElementById("url").value = '';
document.getElementById("email").focus();
return true;
}
if(document.forms[0].news.checked != true) {
alert("Please join our newsletter");
document.forms[0].news.focus();
return false;
}
if(document.forms[0].privacy.checked != true) {
alert("Please, you need to accept privacy policy");
document.forms[0].privacy.focus();
return false;
}
else flag = 0;
// One final check if the others went through fine
if(!flag){
if(document.getElementById("email").value){
// Finally, check the email
if(document.getElementById("email").value.indexOf("@") == -1 || document.getElementById("email").value.indexOf(".") == -1){
alert("Please make sure email is valid");
document.getElementById("email").focus();
return true;
}
else return false;
}
else return false;
}
}
-->
</script>
<script type="text/javascript">
<!--
function privacy() {
window.open('privacy.html','Privacy','width=400','height=300');
}
-->
</script>
<script type="text/javascript">
<!--
function newsletter() {
window.open('newsletter.html','Newsletter','width=400','height=300');
}
-->
</script>
</div>
<!--Registrazione -->
</div> <!--Contenuti-Finestra centrale --><!-- Menù -->
</div> <!-- Container -->
</body>
</html>
Parliamo del captcha....a me succede questo:
-Compilo il form con campi a caso.
-Faccio il refresh della pagina e i campi mi rimangono in memoria (pass esclusa).
-Sbaglio appositamente la mail o un'altra cosa o ometto un campo, mi visualizza l'alert, clicco ok ed i campi compilati sono ancora li.
-Compilo tutto bene e salto il captcha....stessa storia, alert che manca il campo, ok e tutto è sempre li.
-Compilo tutto bene e sbaglio il captcha.....messaggio di errore che il captcha è sbagliato e quando clicco su ok la pagina si ricarica ma cancellando tutti i campi....
E' un bel pò fastidiosa la cosa....come posso evitarla???? Credo ci sia qualche sbavatura nel javascript del controllo del captcha....ma non so dove....