Search the Community
Showing results for tags 'window'.
-
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
- 5 replies
-
- php
- javascript
-
(and 2 more)
Tagged with:
-
Hello peoples. Right, what I'm trying to do is; you fill out a form that generates a HTML page (done with no problems) but you want to preview it before. So essentially, what I'm trying to do it submit a form, but opening another window in doing so, meaning that the entered information on the 1st page stays the same. Here's the code I'm trying: <form action="store_it.php" method="post" id="contact"> <fieldset> <label for="name" >The title of your page:*</label> <input type="text" name="name" value="<?php echo $name; ?>" placeholder="My project" id="name"> <br><label for="body" title="You may use HTML code in this box">The text for your page:*</label> <textarea onfocus="window.lstText=this;" name="body" value="<?php echo $body; ?>" id="body"></textarea><br> <input type="submit" value="Submit" name="submit" class="button" id="submit"><br> <input type="submit" value="Preview" onclick="window.open('store_it.php')"><br> </fieldset> </form> - Thanks, Xanco