SitePoint Sponsor

User Tag List

Results 1 to 17 of 17
  1. #1
    SitePoint Addict anita_86's Avatar
    Join Date
    Aug 2010
    Location
    Nagpur, India
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    javascript:window.open not sending PHP variables

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

    HTML Code:
    <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 Code:
    <?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!!
    It's easy once you know how...

  2. #2
    SitePoint Zealot RishikeshJha's Avatar
    Join Date
    Mar 2009
    Location
    INDIA
    Posts
    146
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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>

  3. #3
    SitePoint Addict anita_86's Avatar
    Join Date
    Aug 2010
    Location
    Nagpur, India
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.
    It's easy once you know how...

  4. #4
    SitePoint Zealot RishikeshJha's Avatar
    Join Date
    Mar 2009
    Location
    INDIA
    Posts
    146
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you want to print msg after submitting the form

    am i write?

  5. #5
    SitePoint Addict anita_86's Avatar
    Join Date
    Aug 2010
    Location
    Nagpur, India
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no insert in database.
    It's easy once you know how...

  6. #6
    SitePoint Zealot RishikeshJha's Avatar
    Join Date
    Mar 2009
    Location
    INDIA
    Posts
    146
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can you write here the form code...

  7. #7
    SitePoint Addict anita_86's Avatar
    Join Date
    Aug 2010
    Location
    Nagpur, India
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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>
    It's easy once you know how...

  8. #8
    SitePoint Member
    Join Date
    Feb 2011
    Location
    Tamil Nadu,India
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do u want to send the msg to one id or want to store in the database mm

  9. #9
    SitePoint Addict anita_86's Avatar
    Join Date
    Aug 2010
    Location
    Nagpur, India
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.
    It's easy once you know how...

  10. #10
    SitePoint Zealot RishikeshJha's Avatar
    Join Date
    Mar 2009
    Location
    INDIA
    Posts
    146
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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>

  11. #11
    SitePoint Zealot RishikeshJha's Avatar
    Join Date
    Mar 2009
    Location
    INDIA
    Posts
    146
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    for Untitled-3.php page...

  12. #12
    SitePoint Addict anita_86's Avatar
    Join Date
    Aug 2010
    Location
    Nagpur, India
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried isset & hidden before but wasn't working.
    Can you please explain me how it had worked now??
    Its amazingly working!!
    It's easy once you know how...

  13. #13
    SitePoint Member
    Join Date
    Feb 2011
    Location
    Tamil Nadu,India
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have u got it

  14. #14
    SitePoint Addict anita_86's Avatar
    Join Date
    Aug 2010
    Location
    Nagpur, India
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeh finally!!
    Thanks Karthikseo.And welcome to sitepoint!!
    It's easy once you know how...

  15. #15
    SitePoint Member
    Join Date
    Feb 2011
    Location
    Tamil Nadu,India
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank u dear..

  16. #16
    SitePoint Zealot RishikeshJha's Avatar
    Join Date
    Mar 2009
    Location
    INDIA
    Posts
    146
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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...


  17. #17
    SitePoint Addict anita_86's Avatar
    Join Date
    Aug 2010
    Location
    Nagpur, India
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okey.I got it now!!
    It's easy once you know how...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •