par
Truc » 24 nov. 2005, 01:45
c vrai un peu bordelique c sur
alors le probleme vien du faite que tu recharge plusieurs fois la page donc tu perds la variable passée en GET lors du 2nd chargement !!
tu peut l'ajouter dans l'action du formulaire (ou champ caché comme dit):
<?php echo $_SERVER['PHP_SELF']."?n=".$text_crypt;?>
voila une proposition plus "propre" avec une séparation PHP / HTML:
<?php
$member= $_SESSION['nom'];
$text_crypt =isset($_GET['n']) ? $_GET['n'] : "" ;
if(isset($_POST['envoi']))
{
$title =isset($_POST["title"]) ? $_POST["title"] : "" ;
$message=isset($_POST["message"])? $_POST["message"]: "" ;
//ici test comme au-dessus avec isset pour les champs hidden
// => pour $nameto, $firstnameto, $countryto sinon de meme ces variables ne vont plus exister lors de la validation du formulaire
// et que les test (if) suivant et verifié
if($title ==''||$message == '')
{
?>
<table border="0" width="800" height="600" cellspacing="0" cellpadding="0">
<tr>
<td>
<b>Incompletes Informations</b>
<br>
<table>
<tr>
<td>
<ol>
<?php
if ($title == '')
print "<li>Give a title for your message please</li>\n";
if ($message == '')
print "<li>Fill the message please</li>\n";
?>
</ol>
</td>
</tr>
</table>
<br /><br />
</td>
</tr>
<tr>
<td>
<FORM action="<?php echo $_SERVER['PHP_SELF']."?n=".$text_crypt; ?>" method="post">
<center>
<table BORDER="1">
<tr>
<td >
<center>Your Amigo</center>
</td>
<td>
<center>
<? echo $nameto." ".$firstnameto." ".$countryto; ?>
</center>
</td>
<td>
<a href='engine.php'>
<center>Find</center>
</a>
</td>
</tr>
<tr>
<td>
<center>Title</center>
</td>
<td colspan=2>
<center>
<input TYPE='text' SIZE='50' NAME='title' value='<? echo $title; ?>'>
</center>
</td>
</tr>
<tr>
<td>
<center>Text</center>
</td>
<td colspan=2>
<center>
<textarea rows='10' NAME='message' cols='50'><?php echo $message;?></textarea>
</center>
</td>
</tr>
<tr>
<td colspan=3>
<CENTER>
<input TYPE='submit' class='bouton' name='envoi' value='Send' >
</center>
</td>
</tr>
</table>
</center>
</FORM>
</td>
</tr>
</table>
<?php
/**********SECONDE PARTIE ***********/
}
else
{
?>
<table border='0' width='800' height='600' cellspacing='0' cellpadding='0'>
<tr>
<td>
<?php
include ('ko55.php');
/* infos expediteur */
$querya = "SELECT idworld FROM atlantis_b25 where member='".$member."'";
$resulta = mysql_query($querya) or die;
if($rows= mysql_fetch_assoc($resulta))
{
$from_idworld = $rows["idworld"];
$query= "select name, firstname, country from atlantis_world where idworld='".$from_idworld."'";
$result = mysql_query($query) or die;
if($row= mysql_fetch_assoc($result))
{
$name=$row["name"];
$firstname=$row["firstname"];
$country=$row["country"];
}
}
/* infos destinataire */
// PROBLEME ICI $_GET['n']; ne recupere pas la valeur ****************
$key = "Lepassword";
$to_idworld2 =MCRYPT_ECB(MCRYPT_3DES, $key, base64_decode($text_crypt),MCRYPT_DECRYPT );
$to_idworld = rtrim($to_idworld2);
$query2= "select name, firstname, country from atlantis_world where idworld='$to_idworld'";
$result2 = mysql_query($query2) or die;
if($row2= mysql_fetch_assoc($result2))
{
$nameto=$row2["name"];
$firstnameto=$row2["firstname"];
$countryto=$row2["country"];
}
// insere dans une autre base les infos
include ('ko556.php');
$date=gmdate("Y-m-d H:i", time());
$query3 = "select from_idworld, date, title from atlantis_mymsgs where date_format(date,'Y-m-d H')=date_format('$date','Y-m-d H') and from_idworld='$from_idworld' and title='$title'";
$result3 = mysql_query($query3) or die;
$exist = mysql_num_rows($result3);
if ($exist >= 1)
{
?>
<center><b>Your message have been post yet</b></center>
<br></br>
<center>
Go back to the <a href='post.php'>Post</a>
</center>
<?php
}
else
{
$query1 = "insert into atlantis_mymsgs (msg_type, title, from_idworld, from_name, from_firstname, to_idworld, date)"
. "values ('0',$title, $from_idworld, $name, $firstname, $to_idworldx, $date)";
$result1 = mysql_query($query1) or die;
$query2 = "insert into atlantis_mymsgs (msg_id, idworld, message)"
. "values (LAST_INSERT_ID(), $from_idworld, $message)";
$result2 = mysql_query($query2) or die;
$query3 = "commit";
$result3 = mysql_query($query3) or die;
mysql_close($link);
}
?>
</td>
</tr>
</table>
<?PHP
}
}
else
{
/**********TROISIEME PARTIE ***********/
?>
<table border='0' width='800' height='600' cellspacing='0' cellpadding='0'>";
<tr>
<td>
<?php
include ('ko55.php');
/* infos expediteur */
$querya = "SELECT idworld FROM atlantis_b25 where member='".$member."'";
$resulta = mysql_query($querya) or die;
if($rows= mysql_fetch_assoc($resulta))
{
$from_idworld = $rows["idworld"];
$query= "select name, firstname, country from atlantis_world where idworld='$from_idworld'";
$result = mysql_query($query) or die;
if($row= mysql_fetch_assoc($result))
{
$name=$row["name"];
$firstname=$row["firstname"];
$country=$row["country"];
}
}
$key = "Lepassword";
$to_idworld2 =MCRYPT_ECB(MCRYPT_3DES, $key, base64_decode($text_crypt),MCRYPT_DECRYPT );
$to_idworld = rtrim($to_idworld2);
$query2= "select name, firstname, country from atlantis_world where idworld='".$to_idworld."'";
$result2 = mysql_query($query2) or die;
if($row2= mysql_fetch_assoc($result2))
{
$nameto=$row2["name"];
$firstnameto=$row2["firstname"];
$countryto=$row2["country"];
}
?>
<FORM action='<?php echo $_SERVER['PHP_SELF']."?n=".$text_crypt;?>' method='post'>
<center>
<table BORDER="1">
<tr>
<td >
<center>Your Amigo</center>
</td>
<td>
<center>
<b><?php echo $nameto." ".$firstnameto."</b> <i>".$countryto."</i>";?>
</center>
</td>
<td>
<a href='engine.php'>
<center>Find</center>
</a>
</td>
</tr>
<tr>
<td>
<center>Title</center>
</td>
<td colspan=2><center>
<input TYPE='text' SIZE='50' NAME='title' /></center></td></tr>
<tr>
<td>
<center>Text</center>
</td>
<td colspan=2><center><textarea rows='10' NAME='message' cols='50'/></textarea>
</center>
</td>
</tr>
<tr>
<td colspan=3>
<CENTER><input TYPE='submit' class='bouton' name='envoi' value='Send' /> <input type='reset' class='bouton' value='Reset' /></center>
</td>
</tr>
</table>
</center>
</FORM>
<?php
}
?>
</td>
</tr>
</table>
</html>
Remarques:
tu devras placer les variables $nameto, $firstnameto et $countryto dans des champs cachés (dans le formulaire de la partie 3) pour les récupèrer apres validation du formulaire (2eme PARTIE).
j'ai aussi corrigé 2-3 bricoles, nottament ouverture et fermeture de <td> oubliées apres les <table><tr>..X...
ajout de test de retour des fonctions mysql_fetch_assoc()
c vrai un peu bordelique c sur :wink:
alors le probleme vien du faite que tu recharge plusieurs fois la page donc tu perds la variable passée en GET lors du 2nd chargement !!
tu peut l'ajouter dans l'action du formulaire (ou champ caché comme dit):
[php]<?php echo $_SERVER['PHP_SELF']."?n=".$text_crypt;?>[/php]
voila une proposition plus "propre" avec une séparation PHP / HTML:
[php]
<?php
$member= $_SESSION['nom'];
$text_crypt =isset($_GET['n']) ? $_GET['n'] : "" ;
if(isset($_POST['envoi']))
{
$title =isset($_POST["title"]) ? $_POST["title"] : "" ;
$message=isset($_POST["message"])? $_POST["message"]: "" ;
//ici test comme au-dessus avec isset pour les champs hidden
// => pour $nameto, $firstnameto, $countryto sinon de meme ces variables ne vont plus exister lors de la validation du formulaire
// et que les test (if) suivant et verifié
if($title ==''||$message == '')
{
?>
<table border="0" width="800" height="600" cellspacing="0" cellpadding="0">
<tr>
<td>
<b>Incompletes Informations</b>
<br>
<table>
<tr>
<td>
<ol>
<?php
if ($title == '')
print "<li>Give a title for your message please</li>\n";
if ($message == '')
print "<li>Fill the message please</li>\n";
?>
</ol>
</td>
</tr>
</table>
<br /><br />
</td>
</tr>
<tr>
<td>
<FORM action="<?php echo $_SERVER['PHP_SELF']."?n=".$text_crypt; ?>" method="post">
<center>
<table BORDER="1">
<tr>
<td >
<center>Your Amigo</center>
</td>
<td>
<center>
<? echo $nameto." ".$firstnameto." ".$countryto; ?>
</center>
</td>
<td>
<a href='engine.php'>
<center>Find</center>
</a>
</td>
</tr>
<tr>
<td>
<center>Title</center>
</td>
<td colspan=2>
<center>
<input TYPE='text' SIZE='50' NAME='title' value='<? echo $title; ?>'>
</center>
</td>
</tr>
<tr>
<td>
<center>Text</center>
</td>
<td colspan=2>
<center>
<textarea rows='10' NAME='message' cols='50'><?php echo $message;?></textarea>
</center>
</td>
</tr>
<tr>
<td colspan=3>
<CENTER>
<input TYPE='submit' class='bouton' name='envoi' value='Send' >
</center>
</td>
</tr>
</table>
</center>
</FORM>
</td>
</tr>
</table>
<?php
/**********SECONDE PARTIE ***********/
}
else
{
?>
<table border='0' width='800' height='600' cellspacing='0' cellpadding='0'>
<tr>
<td>
<?php
include ('ko55.php');
/* infos expediteur */
$querya = "SELECT idworld FROM atlantis_b25 where member='".$member."'";
$resulta = mysql_query($querya) or die;
if($rows= mysql_fetch_assoc($resulta))
{
$from_idworld = $rows["idworld"];
$query= "select name, firstname, country from atlantis_world where idworld='".$from_idworld."'";
$result = mysql_query($query) or die;
if($row= mysql_fetch_assoc($result))
{
$name=$row["name"];
$firstname=$row["firstname"];
$country=$row["country"];
}
}
/* infos destinataire */
// PROBLEME ICI $_GET['n']; ne recupere pas la valeur ****************
$key = "Lepassword";
$to_idworld2 =MCRYPT_ECB(MCRYPT_3DES, $key, base64_decode($text_crypt),MCRYPT_DECRYPT );
$to_idworld = rtrim($to_idworld2);
$query2= "select name, firstname, country from atlantis_world where idworld='$to_idworld'";
$result2 = mysql_query($query2) or die;
if($row2= mysql_fetch_assoc($result2))
{
$nameto=$row2["name"];
$firstnameto=$row2["firstname"];
$countryto=$row2["country"];
}
// insere dans une autre base les infos
include ('ko556.php');
$date=gmdate("Y-m-d H:i", time());
$query3 = "select from_idworld, date, title from atlantis_mymsgs where date_format(date,'Y-m-d H')=date_format('$date','Y-m-d H') and from_idworld='$from_idworld' and title='$title'";
$result3 = mysql_query($query3) or die;
$exist = mysql_num_rows($result3);
if ($exist >= 1)
{
?>
<center><b>Your message have been post yet</b></center>
<br></br>
<center>
Go back to the <a href='post.php'>Post</a>
</center>
<?php
}
else
{
$query1 = "insert into atlantis_mymsgs (msg_type, title, from_idworld, from_name, from_firstname, to_idworld, date)"
. "values ('0',$title, $from_idworld, $name, $firstname, $to_idworldx, $date)";
$result1 = mysql_query($query1) or die;
$query2 = "insert into atlantis_mymsgs (msg_id, idworld, message)"
. "values (LAST_INSERT_ID(), $from_idworld, $message)";
$result2 = mysql_query($query2) or die;
$query3 = "commit";
$result3 = mysql_query($query3) or die;
mysql_close($link);
}
?>
</td>
</tr>
</table>
<?PHP
}
}
else
{
/**********TROISIEME PARTIE ***********/
?>
<table border='0' width='800' height='600' cellspacing='0' cellpadding='0'>";
<tr>
<td>
<?php
include ('ko55.php');
/* infos expediteur */
$querya = "SELECT idworld FROM atlantis_b25 where member='".$member."'";
$resulta = mysql_query($querya) or die;
if($rows= mysql_fetch_assoc($resulta))
{
$from_idworld = $rows["idworld"];
$query= "select name, firstname, country from atlantis_world where idworld='$from_idworld'";
$result = mysql_query($query) or die;
if($row= mysql_fetch_assoc($result))
{
$name=$row["name"];
$firstname=$row["firstname"];
$country=$row["country"];
}
}
$key = "Lepassword";
$to_idworld2 =MCRYPT_ECB(MCRYPT_3DES, $key, base64_decode($text_crypt),MCRYPT_DECRYPT );
$to_idworld = rtrim($to_idworld2);
$query2= "select name, firstname, country from atlantis_world where idworld='".$to_idworld."'";
$result2 = mysql_query($query2) or die;
if($row2= mysql_fetch_assoc($result2))
{
$nameto=$row2["name"];
$firstnameto=$row2["firstname"];
$countryto=$row2["country"];
}
?>
<FORM action='<?php echo $_SERVER['PHP_SELF']."?n=".$text_crypt;?>' method='post'>
<center>
<table BORDER="1">
<tr>
<td >
<center>Your Amigo</center>
</td>
<td>
<center>
<b><?php echo $nameto." ".$firstnameto."</b> <i>".$countryto."</i>";?>
</center>
</td>
<td>
<a href='engine.php'>
<center>Find</center>
</a>
</td>
</tr>
<tr>
<td>
<center>Title</center>
</td>
<td colspan=2><center>
<input TYPE='text' SIZE='50' NAME='title' /></center></td></tr>
<tr>
<td>
<center>Text</center>
</td>
<td colspan=2><center><textarea rows='10' NAME='message' cols='50'/></textarea>
</center>
</td>
</tr>
<tr>
<td colspan=3>
<CENTER><input TYPE='submit' class='bouton' name='envoi' value='Send' /> <input type='reset' class='bouton' value='Reset' /></center>
</td>
</tr>
</table>
</center>
</FORM>
<?php
}
?>
</td>
</tr>
</table>
</html>
[/php]
Remarques:
tu devras placer les variables $nameto, $firstnameto et $countryto dans des champs cachés (dans le formulaire de la partie 3) pour les récupèrer apres validation du formulaire (2eme PARTIE).
j'ai aussi corrigé 2-3 bricoles, nottament ouverture et fermeture de <td> oubliées apres les <table><tr>..X...
ajout de test de retour des fonctions mysql_fetch_assoc()