Page 1 sur 1

une variable de formulaire qui n'est pas recuperee

Posté : 24 nov. 2007, 00:09
par choubix
hello,

j'ai le script suivant.
je fais passer 2 variables par l'url (id_gifts et tickets)

j'essaie de faire un print de $tickets mais ca ne passe pas :(

je suis persuade que c'est une ereur bete de ma part mais qq un a une idee du pourquoi svp?
je crois quej 'ai mange trop de code aujourd'hui ;)

merci!
<?php 
session_start();

if (isset($_SESSION['id_clients']) && $_SESSION['level'] == 0 || $_SESSION['level'] == 1) {
}
else {
$_SESSION['error'] = 5;
header("Location: ../message.php");
exit();
}

require('../includes/config.php');

//get the type of game the client plays for: sponsored games or redeem points
$id_gifts = $_GET['id_gifts'];
$id_gifts = mysql_real_escape_string(htmlentities($id_gifts, ENT_QUOTES)); 

//if we are dealing with "redeem points" game. this is how many tickets the clients wants to play for
$tickets = (isset($_GET['tickets']))?$_GET['tickets']:'';
$tickets = mysql_real_escape_string(htmlentities($tickets, ENT_QUOTES)); 


//get info for all games depending on the ID
$query = sprintf("SELECT id_advertiser, type FROM gifts WHERE id_gifts = '%s' ",
		mysql_real_escape_string($id_gifts)
		);
$result = mysql_query($query) or die('Invalid query: ' . mysql_error());

$row = mysql_fetch_assoc($result);

$time = time();

//if we are dealing with a sponsored game:
if ($row['type'] = 1)
{
//update the counter_view (total page view of the ad)
$query = sprintf("INSERT INTO gifts_played (id_gifts, id_advertiser, id_clients, date_played) 
		VALUES ('%s', '%s', '%s', '$time')",
		mysql_real_escape_string($id_gifts),
		mysql_real_escape_string($row['id_advertiser']),
		mysql_real_escape_string($_SESSION['id_clients'])
		);		
mysql_query($query) or die('Invalid query: ' . mysql_error());
}

//if we are dealing with a "redeem points" game
else
{
print "$tickets";
}

mysql_close();
?>

ps: si je remonte le print "$tickets"; jsute en dessous de $tickets = mysql_real_escape_string(htmlentities($tickets, ENT_QUOTES)); et que je supprime tout le reste du code: $tickets s'affiche.

Posté : 24 nov. 2007, 00:26
par h0_noMan
Recuperes ticket grave a la superglobale $_GET.

$ticket = $_GET['tickets'] ;

Posté : 24 nov. 2007, 00:31
par choubix
ben, c'est pas ca que j'ai dons mon code?

le truc c'est que si mon code c'est ca ca marche:
<?php 
session_start();

if (isset($_SESSION['id_clients']) && $_SESSION['level'] == 0 || $_SESSION['level'] == 1) {
}
else {
$_SESSION['error'] = 5;
header("Location: ../message.php");
exit();
}

require('../includes/config.php');

//get the type of game the client plays for: sponsored games or redeem points
$id_gifts = $_GET['id_gifts'];
$id_gifts = mysql_real_escape_string(htmlentities($id_gifts, ENT_QUOTES)); 

//if we are dealing with "redeem points" game. this is how many tickets the clients wants to play for
$tickets = (isset($_GET['tickets']))?$_GET['tickets']:'';
$tickets = mysql_real_escape_string(htmlentities($tickets, ENT_QUOTES)); 


print "$tickets";
mysql_close();
?>

Posté : 24 nov. 2007, 00:34
par h0_noMan
if ($row['type'] = 1)
Ta condition est toujours rempli donc ton print ne s'excute jamais.
Rajoute encore un =

Posté : 24 nov. 2007, 00:44
par choubix
super merci!! :)

au fait: a voir ta signature, t'as trop bu d'Ajax? a ce qu'il parait ca decape bien ;)

Posté : 24 nov. 2007, 00:58
par h0_noMan
Ajax c'est devenu "à la mode", on en met à toutes les sauces et pour n'importe quoi.
MAis ce n'est pas le débat ici.

Penses à "Mettre Résolu" ton problème.