array

  • Creatore Discussione Creatore Discussione claire
  • Data di inizio Data di inizio

claire

Nuovo Utente
20 Feb 2007
10
0
1
salve, spero che qualcuno possa aiutarmi perchè sto diventando matta.
tema: un guestbook.
L'utente lascia un messaggio e il suo indirizzo e mail.
nella pagina si visualizza il messaggio e una gif clikkando sulla quale si manda una mail all'utente in questione.
il prblema è che le mail vengono madate tutte all'indirizzo del primo utente che ha scritto :(
ho una pagina index.php dalla quale al clik sulla gif viene aperta la pagina mail.php.
un po' di codice:

nella index:
<script language="JavaScript" type="text/javascript">
function apri() {
window.open('mail.php?mail= <?php echo "$array[4]"; ?>', 'Invia', 'toolbar,width=550,height=450,left=200,top=100,resizable=no');
}

</script>
<?php
if ($array[4] == "") {
$mail = "";
} else {
$mail = "<a href=\"javascript:apri();\" title=\"Invia una e-mail a $array[0]\"><img src=\"img/email.gif\" title=\"Invia una e-mail a $array[0]\" border=\"0\" alt=\"\"></a>";
}
$array[0] = str_replace("%&", ",", $array[0]);
$array[1] = str_replace("%&", ",", $array[1]);
$array[4] = str_replace("%&", ",", $array[4]);
//$result =$array[4];\\
//echo $result.'<br>';\\
$array[0] = str_replace("<", "&lt;", $array[0]);
$array[0] = str_replace(">", "&gt;", $array[0]);
$array[1] = str_replace(";:;", "<", $array[1]);
$array[1] = str_replace(":;:", ">", $array[1]);
$array[1] = wordwrap($array[1],13,"\n",1);
$array[1] = ereg_replace("(((http|ftp|https)://)|(www\.))+(([a-zA-Z0-9\._-]+\.[a-zA-Z]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(/[a-zA-Z0-9\&%_\./-~-]*)?","<a href=\"http://\\0\" target=\"".$target."\_blank\">\\0</a>", $array[1]);
$array[1] = stripslashes($array[1]);
echo "<table width=\"100%\" border=\"0\">
<tr>
<td width=\"100%\" valign=\"top\"><b>$array[0]:&nbsp;</b>$array[1]&nbsp;$mail<br>$array[3] del $array[2]</td>
</tr>
</table>";
}
}
}
?>

se stampo a video $array[4] vicinoa ogni messaggio vedo regolarmete l'indirizzo e mail dell'utente.

in mail.php:

<?php
if (!$_POST['testo']) {
?>
<form method="post" action="<?php echo "mail.php?mail=$mail"; ?>" name="form"><div align="center">
<p><font class="title"><span class="Stile1">Scrivi una mail</span></font><br>
<br>
<span class="Stile1">Tutti i campi sono obbligatori</span><br>
<br>
</p>
<table width="400" border="0" align="center">
<tr class="main">
<td width="100%" align="center"><font class="Stile1"><b>Oggetto</b></font></td>
</tr>
<tr>
<td height="20" align="center" width="100%"><input name="oggetto" type="text" class="Stile3" size="30"></td>
</tr>
</table>
<span class="Stile2"></span>
<table width="400" border="0" align="center">
<tr class="main">
<td width="50%" align="center"><font class="Stile1"><b>Nome</b></font></td>
<td width="50%" align="center"><font class="Stile1"><b>Tua mail</b></font></td>
</tr>
<tr>
<td height="20" align="center"><input name="autore" type="text" class="Stile3"></td>
<td height="20" align="center"><input name="email" type="text" class="Stile3"></td>
</tr>
</table>
<table width="400" border="0" align="center">
<tr class="main">
<td width="100%" align="center"><font class="Stile1"><b>Messaggio</b></font></td>
</tr>
<tr>
<td height="20" align="center"><textarea name="testo" cols="50" rows="6" class="Stile3"></textarea></td>
</tr>
<tr class="main">
<td width="100%" align="center"><font class="Stile1"><b>Conferma</b></font></td>
</tr>
<tr>
<td align="center"><input name="invia" type="submit" class="Stile1" value="Invia mail"></td>
</tr>
</table></div></form>
<?php
} else {
$autore = $_POST['autore'];
$testo = $_POST['testo'];
$email = $_POST['email'];
$oggetto = $_POST['oggetto'];
if (trim($autore) == "" OR trim($testo) == "" OR trim($email) == "" OR trim($oggetto) == "") {
header("location: mail.php?mail=$mail");
exit(); //evito di andare avanti con lo script
}
mail($mail, $oggetto, $testo, "From: $autore - $email");
//$result =mail($mail, $oggetto, $testo, "From: $autore - $email");\\
//echo $result.'<br>';\\
?>
<div align="center"><font class="title"><?php echo "$guestbook"; ?></font><br>
<br>E-mail inviata con sucesso. Grazie</div>
<?php echo "$mail"; ?>
</body>
</html>


<?php echo "$mail"; ?>
mi restituisce sempre lo stesso indirizzo e mail, cioè quello del primo utente che ha postato.

non so che fare.. qualcuno mi aiuta ?
 

Discussioni simili