[PHP-DB] Run SQL query when click on OK button of warning message

2008-07-27 Thread Nasreen Laghari
  Hi All,

I am printing a _javascript_warning message. On pressing OK button, I want to run an sql query. Below is the way I have tried but sql query is running either press OK or Cancel button on warning message or even refresh the page (F5). Also redirection, when press OK, also not working.


Am I using the right approach? Could any 1 please help me to sort this problem.


Regards,

Nasreen



trtd
input type="button" DELETE FROM artist where aid = '$id'";mysql_query($sqldel) or die(mysql_error());//header("Location: artist.php");//window.location="http://www.yahoo.com/"?}else{window.location='index.php' }" value="DELETE"
/td/tr  

  

RE: [PHP-DB] Run SQL query when click on OK button of warning message

2008-07-27 Thread Emiliano Boragina
Hi,

 

Why the “if(answer){” is not in the tag ?php?

 

+  _
   // Emiliano Boragina _

   // Diseño  Comunicación //
+  _

   // [EMAIL PROTECTED]  /
   // 15 40 58 60 02 ///
+  _


  _  

De: Nasreen Laghari [mailto:[EMAIL PROTECTED] 
Enviado el: domingo, 27 de julio de 2008 18:04
Para: php-db@lists.php.net
Asunto: [!! SPAM] [PHP-DB] Run SQL query when click on OK button of warning
message

 



 


 


Hi All,

 

I am printing a java script warning message. On pressing OK button, I want
to run an sql query. Below is the way I have tried but sql query is running
either press OK or Cancel button on warning message or even refresh the page
(F5). Also redirection, when press OK, also not working.

 

 

Am I using the right approach? Could any 1 please help me to sort this
problem.

 

 

Regards,

 

Nasreen  

 

 

 

trtd

input type=button onClick=var answer = confirm ('Are you sure you want
to delete this record!!')
 if (answer)
 {
  ?php

   $sqldel = DELETE FROM artist where aid = '$id';
   mysql_query($sqldel) or die(mysql_error());
   //header(Location: artist.php); 
   //window.location= http://www.yahoo.com/ http://www.yahoo.com/;
  ?  
 }
 else
 {
  window.location='index.php'
  } value=DELETE

/td/tr


 

 

 



Re: [PHP-DB] Run SQL query when click on OK button of warning message

2008-07-27 Thread sempsteen
It seems you've a long way to go. Here is what i can say for you.
First of all PHP and JavaScript are two different programming
languages, running in different environments. JavaScript is a
client-side language which your browser interprets it with the page is
loaded. PHP is a server-side language which gets your source code,
interprets it and sends to the browser. There is no any connection
with these two languages. So you cannot write a PHP code and bind it
to a JavaScript code.
You can only make an HTTP request to PHP page by either redirecting or
you can make AJAX requests.
Good luck.

On Sun, Jul 27, 2008 at 10:03 PM, Nasreen Laghari
[EMAIL PROTECTED] wrote:
 Hi All,

 I am printing a java script warning message. On pressing OK button, I want
 to run an sql query. Below is the way I have tried but sql query is running
 either press OK or Cancel button on warning message or even refresh the page
 (F5). Also redirection, when press OK, also not working.


 Am I using the right approach? Could any 1 please help me to sort this
 problem.


 Regards,

 Nasreen



 trtd
 input type=button onClick=var answer = confirm ('Are you sure you want
 to delete this record!!')
  if (answer)
  {
   ?php

$sqldel = DELETE FROM artist where aid = '$id';
mysql_query($sqldel) or die(mysql_error());
//header(Location: artist.php);
//window.location=http://www.yahoo.com/;
   ?
  }
  else
  {
   window.location='index.php'
   } value=DELETE
 /td/tr


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Run SQL query when click on OK button of warning message

2008-07-27 Thread Micah Gersten
While sempsteen is correct, you can achieve the correct effect in this
simple scenario by checking the return value of the confirm button.

input type=submit value=Delete Record onsubmit=return confirm ('Are you 
sure you want to delete this record!!'); /


And then check for the submit...
This is prone to a lot of problems though if this is your only security measure.

You might want to check out this library if you want to do this type of thing 
often and have useful interaction:
http://xajaxproject.org/

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



sempsteen wrote:
 It seems you've a long way to go. Here is what i can say for you.
 First of all PHP and JavaScript are two different programming
 languages, running in different environments. JavaScript is a
 client-side language which your browser interprets it with the page is
 loaded. PHP is a server-side language which gets your source code,
 interprets it and sends to the browser. There is no any connection
 with these two languages. So you cannot write a PHP code and bind it
 to a JavaScript code.
 You can only make an HTTP request to PHP page by either redirecting or
 you can make AJAX requests.
 Good luck.

 On Sun, Jul 27, 2008 at 10:03 PM, Nasreen Laghari
 [EMAIL PROTECTED] wrote:
   
 Hi All,

 I am printing a java script warning message. On pressing OK button, I want
 to run an sql query. Below is the way I have tried but sql query is running
 either press OK or Cancel button on warning message or even refresh the page
 (F5). Also redirection, when press OK, also not working.


 Am I using the right approach? Could any 1 please help me to sort this
 problem.


 Regards,

 Nasreen



 trtd
 input type=button onClick=var answer = confirm ('Are you sure you want
 to delete this record!!')
  if (answer)
  {
   ?php

$sqldel = DELETE FROM artist where aid = '$id';
mysql_query($sqldel) or die(mysql_error());
//header(Location: artist.php);
//window.location=http://www.yahoo.com/;
   ?
  }
  else
  {
   window.location='index.php'
   } value=DELETE
 /td/tr

 

   

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php