Jump to content

NicoleSigaud

New Members
  • Posts

    3
  • Joined

  • Last visited

NicoleSigaud's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I apologyse for not writing English as well as I should, but now you answered one part of what I was asking - "One can't have php code inside a js script." - I did not know that. The method you described later ("have to port all of your curren tphp code from the calling script to the JS-called script.") was something I could not understand, sorry. Let's see... I call a new windows through JS. This new window already exists inside the directory or it's created on the fly? Inside this new window I have a php code, right? Sorry for not undestanding very well...
  2. The problem is: I have a form in a page which has a script that creates as many form fields as the user needs. After creating these (numbered) extra fields, everyone of them needs to send data to a php page that inserts into the database what is in these fields. To accomplish that I assumed that a script in JS would then create/open windows with php code written on-the-fly to insert the data. If I create a static php page this would not work, because the extra fields are numbered and therefore would need to pass the contents to an equally differentiated page.
  3. Hello, I would like to create a window through JavaScript with PHP code that would insert data into a database, but I don't know if it's possible, because I tried everything I could so far and had no results at all. The code I am using is <script language="JavaScript"> <!-- top.consoleRef = new Object(); top.consoleRef.closed = true; function writeConsole(content) { top.consoleRef=window.open('em_branco.php','myconsole','width=350,height=250') top.consoleRef.document.writeln( '<html><head><title>página nova</title></head><body><?php $db = pg_connect("host=localhost dbname=dpf_db user=postgres password=asdasd"); $query = "INSERT INTO tbl_dummy(nome) VALUES(' + '´treco´' + ')"; $result = pg_query($query); if (!$result) { $errormessage = pg_last_error(); echo "Error with query: " . $errormessage; exit(); } printf ("These values were inserted into the database"); pg_close(); ?></body></html>' ) //top.consoleRef.document.close() } //--> </script> Note that line 13 has a sort of aberration, because I'd need three kinds of quotes, and not only two (the +'´treco´' stuff). And I don't know how to circumvent this, because escaping didn't work either. Any help is most welcome, and thank you in advance for your attention. Nicole
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.