this.collision = function(p1, p2, p3, p4)
{
if(this.ballY - this.radius + this.dy <= p1.height && this.ballX + this.dx >= p1.leftPostx - p1.goalPostRadius && this.ballX <= p1.rightPostx + p1.goalPostRadius)
{
this.dy = -this.dy;
this.ballY = p1.height + this.radius;
count++;
score++;
<?php $_SESSION['score'] += 1; ?>
}
else if(this.ballY + this.radius + this.dy >= canvas.height - p2.height && this.ballX + this.dx >= p2.leftPostx - p2.goalPostRadius && this.ballX + this.dx <= p2.rightPostx + p2.goalPostRadius)
{
this.dy = -this.dy;
this.ballY = canvas.height - p2.height - this.radius;
count++;
score++;
<?php $_SESSION['score'] += 1; ?>
}
else if(this.ballX + this.radius + this.dx >= canvas.width - p3.height && this.ballY + this.dy >= p3.topPosty - p3.goalPostRadius && this.ballY + this.dy <= p3.bottomPosty + p3.goalPostRadius)
{
this.dx = -this.dx;
this.ballX = canvas.width - p3.height - this.radius;
count++;
score++;
<?php $_SESSION['score'] += 1; ?>
}
else if(this.ballX - this.radius + this.dx <= p4.height && this.ballY + this.dy >= p4.topPosty - p4.goalPostRadius && this.ballY + this.dy <= p4.bottomPosty + p4.goalPostRadius)
{
this.dx = -this.dx;
this.ballX = p4.height + this.radius;
count++;
score++;
<?php $_SESSION['score'] += 1; ?>
}
else if(this.ballY - this.radius + this.dy < 0 || this.ballY + this.radius + this.dy > canvas.height || this.ballX - this.radius + this.dx < 0 || this.ballX + this.radius + this.dx > canvas.width)
{
checkLives(p1, p2, p3, p4, ball1);
}
}
Also, der Titel sagt alles. In diesem Code versuche ich eine JavaScript-Bedingung zu verwenden, um zu bestimmen, wann ich meine Sitzungsvariable erhöhen werde. Wie kann ich das machen? Vielen Dank im Voraus für die Hilfe alle!Inkrementieren einer PHP-Session innerhalb einer JS-Conidtion
Ich werde schauen in das Morgen, danke! –
Also, hoffentlich verstehe ich das richtig. Dies bucht nun den Wert der JS-Score-Variable in die Datei serverfile.php, die dann die Sitzung aktualisiert, richtig? Brauche ich nicht auch einen session_start() in der serverfile.php oder nein? –
Ich weiß nicht, Ihr Framework, das Sie verwenden, wenn in jeder Datei Ihres Codes vor dieser Datei enthalten Sitzung gestartet wird gestartet dann keine Notwendigkeit, Sitzung zu starten, wenn nicht, dann sollten Sie Sitzung starten. –