Désolé, je pense que vous le faites mal. Vous avez besoin générer une URL avec le JavaScript et y envoyer l'utilisateur.
window.location.href = "page.php?x=" + msg;
Puis page.php serait prendre cette variable, il assainir et faire le montage de la base de données.
Par exemple, dans votre page actuelle/pup-up, vous devez :
<script>
function msg()
{
var message=prompt("Please enter your msg","<? echo $user;?>");
if (msg!=null)
{
window.location.href = "page.php?x=" + msg;
}
}
</script>
- <script>
- function msg()
- {
- var message=prompt("Please enter your msg","<? echo $user;?>");
- if (msg!=null)
- {
- window.location.href = "page.php?x=" + msg;
- }
- }
- </script>
et puis en page.php, vous auriez le code suivant :
<?php
$x1 = "message"; /*this has to be hard set. it works*/
$x2 = sanitize($_GET['x']);
$database->name($user, $x1, $x2);
?>
- <?php
- $x1 = "message"; /*this has to be hard set. it works*/
- $x2 = sanitize($_GET['x']);
- $database->name($user, $x1, $x2);
- ?>
Ce que vous avez maintenant :
<script>
function msg()
{
var message=prompt("Please enter your msg","<? echo $user;?>");
if (msg!=null)
{
x="" + msg + "";
<? $x1= "message"; /*this has to be hard set. it works*/
$x2= $x ;
$database->name($user, $x1, $x2);?>
}
}
</script>
- <script>
- function msg()
- {
- var message=prompt("Please enter your msg","<? echo $user;?>");
- if (msg!=null)
- {
-
- x="" + msg + "";
- <? $x1= "message"; /*this has to be hard set. it works*/
- $x2= $x ;
- $database->name($user, $x1, $x2);?>
- }
- }
- </script>
1. Pour définir une variable en javascript, je pense que vous devez le mot var devant le nom de la variable
var x = msg ;2. Vous essayez d'utiliser une variable JavaScript dans votre PHP. PHP n'a pas de variable
$x mettre, alors sa juste blanc (surpris vous n'obtenez pas une erreur)
EDIT :
<script>
function msg()
{
var message=prompt("Please enter your msg","<? echo $user;?>");
if (msg!=null)
{
x="" + msg + "";
[b]<?[/b] $x1= "message"; /*this has to be hard set. it works*/
$x2= $x ;
$database->name($user, $x1, $x2);?>
}
}
</script>
I think you put the starting PHP tags too early... I think you meant to put them here....
<script>
function msg()
{
var message=prompt("Please enter your msg","<? echo $user;?>");
if (msg!=null)
{
[b]<?[/b] x="" + msg + "";
$x1= "message"; /*this has to be hard set. it works*/
$x2= $x ;
$database->name($user, $x1, $x2);?>
}
}
</script>
- <script>
- function msg()
- {
- var message=prompt("Please enter your msg","<? echo $user;?>");
-
- if (msg!=null)
- {
-
- x="" + msg + "";
- [b]<?[/b] $x1= "message"; /*this has to be hard set. it works*/
- $x2= $x ;
- $database->name($user, $x1, $x2);?>
- }
- }
- </script>
-
- I think you put the starting PHP tags too early... I think you meant to put them here....
-
- <script>
- function msg()
- {
- var message=prompt("Please enter your msg","<? echo $user;?>");
-
- if (msg!=null)
- {
-
- [b]<?[/b] x="" + msg + "";
- $x1= "message"; /*this has to be hard set. it works*/
- $x2= $x ;
- $database->name($user, $x1, $x2);?>
- }
- }
- </script>