Javascript:window.open not sending PHP variables

Please guide me on how to send PHP variables through javascript open window function.

<a href='javascript:window.open("Untitled-3.php?id= <?PHP print ($id); ?> ", "_blank", "height=600, width=1100, left=100, top=50, status=yes, toolabar=no, //scrollbar=yes, menubar=no");;void(0)' target="_self"><img src='images/27648.png' alt='Report Completed' title='Report Completed' border='0' width='16' height='16'>
</a>

When I get the values, either id or msg is displayed:

<?PHP
$id=$_REQUEST['id'];
echo "id is '. $id";
?>
<?PHP
echo $id;
$report=$_REQUEST['msg'];
$query=mysql_query("UPDATE task SET report='$report' WHERE task_id='".$id."'");
echo "Task Reported..";
print_r("UPDATE task SET report='$report' WHERE task_id='".$id."'");
?>

Please help me out!!

pass the msg varibable in the url

Like this
<a href=‘javascript:window.open("Untitled-3.php?id= <?PHP print ($id); ?>&msg=<?php echo $msg?> ", “_blank”, “height=600, width=1100, left=100, top=50, status=yes, toolabar=no, //scrollbar=yes, menubar=no”);;void(0)’ target=“_self”><img src=‘images/27648.png’ alt=‘Report Completed’ title=‘Report Completed’ border=‘0’ width=‘16’ height=‘16’>
</a>

I cant pass $msg though that link because it is in the next page where the other form is situated.
I just want to make a form where user can report a task and submit a msg as well.
So open window function is used to open another form.The id of the task is in that link.
Hope I am sounding clear.

you want to print msg after submitting the form

am i write?

no insert in database.

can you write here the form code…

main page:

<?PHP
$user_id=$_SESSION[‘user_id’];
$query=mysql_query
(“SELECT
task.userlevel,
task.task_from,
task.timestamp,
task.start_date,
task.due_on,
task.status,
task.task,
task.task_id,
user.fname
FROM task
INNER JOIN
user ON
task.user_id=user.user_id
WHERE
task.user_id=$user_id”);
if(mysql_num_rows($query) > 0)
{
echo “<table align=‘center’ border=‘0’ width=‘1000’>
<tr class=‘style1’ align=‘center’>
<td>Assigned To</td>
<td>Assigned By</td>
<td>Task</td>
<td>Start Date</td>
<td>Due On</td>
<td>Status</td>
</tr>”;
while($row=mysql_fetch_array($query))
{
if($row!=0)
{
$id=$row[‘task_id’];
$userlevel=$row[‘task_from’];
if($userlevel==1)
{
$userlevel=“Manager”;
}
elseif($userlevel==2)
{
$userlevel=“Administrator”;
}
elseif($userlevel==3)
{
$userlevel=“Programmer”;
}
elseif($userlevel==12)
{
$userlevel=“Business Dev. Officer”;
}
elseif($userlevel==31)
{
$userlevel=“Marketing Executive”;
}
echo “<tr align=‘center’>
<td class=‘style3’>”; echo $row[‘fname’]; echo “</td>
<td class=‘style3’>”; echo $userlevel; echo “</td>
<td class=‘style3’>”; echo $row[‘task’]; echo “</td>
<td class=‘style3’>”; echo $row[‘start_date’]; echo “</td>
<td class=‘style3’>”; echo $row[‘due_on’]; echo “</td>”; ?>
<?PHP
$status=$row[‘status’];
if($status==0)
{
echo “<td class=‘style3’>”; ?>
<a href=‘javascript:window.open(“Untitled-3.php?id= <? echo $id ?>”, “_blank”, “height=150, width=250, left=800, top=300, status=yes, toolabar=no, //scrollbar=yes, menubar=no”);;void(0)’ target=“_self”><img src=‘images/27648.png’ alt=‘Report Completed’ title=‘Report Completed’ border=‘0’ width=‘16’ height=‘16’>
</a> <?PHP echo “</td>”;
}
elseif($status==1)
{
echo “<td class=‘style3’>Reported</td>”;
}
elseif($status==2)
{
echo “<td class=‘style3’>Completed</td>”;
}
?>

Untitled-3.php

<?PHP
$id=$_REQUEST[‘id’];
echo “id is '. $id”;
?>
<?PHP
echo $id;
$report=$_REQUEST[‘msg’];
$query=mysql_query(“UPDATE task SET report=‘$report’ WHERE task_id=‘$id’”);
print_r(“UPDATE task SET report=‘$report’ WHERE task_id=‘$id’”);
?>
<html>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8” />
<title>Untitled Document</title>
<style type=“text/css”>
.menu_form_body
{width: 200px;height:100px;border: 1px solid black;background: url(‘images/form.png’) no-repeat left bottom;}
</style>
</head>
<body>
<form action=“<?php echo $_SERVER[‘PHP_SELF’]; ?>” method=“post” name=“report”>
<table align=“center” class=“menu_form_body”>
<tr>
<td align=“center”>
<textarea name=“msg” cols=“15” rows=“”></textarea></td>
</tr>
<tr>
<td align=“center”>
<input name=“submit” type=“submit” /></td>
</tr>
</table>
</form>
</body>
</html>

Do u want to send the msg to one id or want to store in the database mm

I want to set status of that particular message as “Completed” and save the message provided by user to database so that it can be seen by the administrator.

try this code…
<?PHP
if(isset($_POST[‘submit’])){
$id=$_REQUEST[‘id’];
echo $id;
$report=$_REQUEST[‘msg’];
$query=mysql_query(“UPDATE task SET report=‘$report’ WHERE task_id=‘$id’”);
print_r(“UPDATE task SET report=‘$report’ WHERE task_id=‘$id’”);

}
?>
<html>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8” />
<title>Untitled Document</title>
<style type=“text/css”>
.menu_form_body
{width: 200px;height:100px;border: 1px solid black;background: url(‘images/form.png’) no-repeat left bottom;}
</style>
</head>
<body>
<form action=“<?php echo $_SERVER[‘PHP_SELF’]; ?>” method=“post” name=“report”>
<table align=“center” class=“menu_form_body”>
<tr>
<td align=“center”>
<textarea name=“msg” cols=“15” rows=“”></textarea></td>
</tr>
<tr>
<td align=“center”>
<input name=“submit” type=“submit” /></td>
</tr>
<input type=“hidden” value=“<?=$_REQUEST[‘id’]?>” name=“id”>
</table>
</form>
</body>
</html>

for Untitled-3.php page…

I tried isset & hidden before but wasn’t working.
Can you please explain me how it had worked now??
Its amazingly working!!

Have u got it

yeh finally!!
Thanks Karthikseo.And welcome to sitepoint!! :slight_smile:

Thank u dear…

First time when pop is opened you are getting the id by $_REQUEST[‘id’].

But when you are submitting the form the value of id lost.

to preserve the value of id put it in hidden field…

:):):slight_smile:

Okey.I got it now!!