0

Hi having a bit of a problem what I'm trying to do is once a user has clicked a button the button should show a popup of a form so they might enter a value which is a date so it may be used for future uses and the popup has a submit button so process the action with this code:

     if (isset($_POST['unenroll'])){
        $sql1="Update tbl_enroll SET status='unEnrolled' , counter='0' 
              period='$pweek";
                    $pow = mysql_query($sql1) or die (mysql_error());
                    } 

I am having a problem on how to create the popup so far i have this:

     onclick="window.open‘unenroll.php’,‘Unenroll’,
   ‘menubar=no,width=200,height=100,toolbar=no’)"

So far it just not creating the popup form. would appreciate any help.

Anton
  • 429
  • 4
  • 17

3 Answers3

1

You use the wrong quotes and also a bracket is missing. Try this here:

onclick="window.open('unenroll.php', 'Unenroll', 'menubar=no,width=200,height=100,toolbar=no')"

Note that this must be in one line and also care about the php variable $pweek If that comes from the client you open a blind sql injection hole.

In your SQL statement is also a quote and a comma missing:

$sql1="Update tbl_enroll SET status='unEnrolled', counter='0', period='$pweek'";
rekire
  • 47,260
  • 30
  • 167
  • 264
  • Thank you that helped, but wasn't expecting the output it looks ugly. =( need to disable the maximize button and center it is that possible? – Anton Sep 14 '12 at 11:50
  • @Tony For putting the popup in the middle of the screen read please: [Center a popup window on screen?](http://stackoverflow.com/questions/4068373/center-a-popup-window-on-screen). To disable the maximize is so far I know not possible. – rekire Sep 14 '12 at 11:55
  • Do you think there is better way in doing this because i was imagining this looking like a Onclick=Confirm return, else i just have to make due with this. – Anton Sep 14 '12 at 11:59
  • I don't know what your `unenroll.php` is displaying, but of cause you could use a confirm box too. With `onclick="if(confirm('msg')) doSomething();"` you can do what you want. – rekire Sep 14 '12 at 12:04
  • My bad for not telling, I think i can't do that because the onclick it would show a form that can submit the entered data on that **form**. – Anton Sep 14 '12 at 12:09
  • I'm not sure how you can slove that problem. Maybe with the [target attribute](http://www.w3schools.com/tags/att_form_target.asp) on the form, but this is not standard conform. – rekire Sep 14 '12 at 12:13
0

the popup wont be a better option because its either blocked by browse or by users so the i think better approach will be make a div and show the div on click

html

<div id="demo"></div>

jquery

 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
 <script type="text/javascript">
   $(document).ready(function(){
     $("#demo").hide();
     $(document).live("click",function(){
          $("#demo").show();

      }) 
  })
</script>
NullPoiиteя
  • 56,591
  • 22
  • 125
  • 143
0

Your onclick should be like this

onclick="window.open('unenroll.php', 'Unenroll', 'menubar=no,resizable=no,width=200,height=100,toolbar=no,left='+((screen.width/2)-50)+',top='+((screen.height/2)-50))"

resizable=no will disable maximize button.

left = (screen.width/2)-50;
top = (screen.height/2)-50;

should center the popup in your case...

Srinivas
  • 727
  • 4
  • 14