PHP - Php, Open New Window With Javascript
Hi everyone.
i need to open a new window in php using a bit of javascript.. or maybe not, with an id number. any help would be appreciated. This code doesn't do anything even though there are no errors. Any ideas on how why? Code: [Select] <input type="submit" name="SaveData" id="SaveData" value="Save" /> <?php if (isset($_POST['SaveData'])) { $loc = "saveddata.php?IDNumber=" . $IDNumber; echo "<script LANGUAGE='JavaScript'>"; echo "window.open($loc,'mywin','left=20,top=20,width=500,height=500,toolbar=0,resizable=1')"; echo "</script>"; } ?> Similar TutorialsScenario :
I would like to open the main program window and at the same time, if a condition is met, open a second - popup window to alert the user of previous information stored in the database.
This is an easy exercise if I use a hyperlink to open th second (popup) window but this is not the process required .
Can someone point me in the right direction ?
Cheers and thanks
I would like to open a new IE window. But, failed to do that. Is there any wrong with my statements? Code: [Select] <?php $url='http://www.google.com'; $browser = new COM("InternetExplorer.Application"); $browser->Visible = true; $browser->Navigate($url); ?> Can anyone help me with this pls? Thank you. Regards, juzz hi there i have a basic image gallery. it displays smaller thumbnails in a folder and when you click on them it displays a larger image. how can i make the larger image open in a seperate window of 640x480 when the thumbnail is clicked? thanks here is the code: <?php include('connect.php'); $images = "images/"; # Location of small versions $big = "big/"; # Location of big versions (assumed to be a subdir of above) $cols = 4; # Number of columns to display if ($handle = opendir($images)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != rtrim($big,"/")) { $files[] = $file; } } closedir($handle); } $colCtr = 0; echo '<table width="50%" cellspacing="3" align=center ><tr>'; foreach($files as $file) { if($colCtr %$cols == 0) echo '</tr><tr><td colspan="10" ></td></tr><tr>'; echo '<td ><a href="' . $images . $big . $file . '" ><img src="' . $images . $file . '" /></a></td>'; $colCtr++; } echo '</table>' . "\r\n"; ?> Hi, I was just wondering if it were possible (and if so how) to open a page in a new window when submitting a form via php? E.g. I have a poll on my website that is directed to the reults page by $insertGoTo = "results.php";. This all works but what I want to happen is for when the user clicks submit that the results page displays in a new window (or at the very least a new tab), similar to what would happen when you put a target=_blank on a html link. Any help would be very appreciated. Thanks. Was wondering if its possible to open up a header in a new browser window? with html you add a target to do this. Can this be done with a header? header("Location: evaluate.php" target="_blank"); Hello: I wrote the following script. It is working fine, I just need the links to open in a blank window. Any help will be appreciated. <html> <body> <?php $connection = mysql_connect("localhost", "username", "password"); mysql_select_db("articles", $connection); $query="SELECT * FROM articles WHERE id=1"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <table border="1" cellspacing="2" cellpadding="2"> <tr> <th><font face="Arial, Helvetica, sans-serif">Article</font></th> <th><font face="Arial, Helvetica, sans-serif">Year</font></th> <th><font face="Arial, Helvetica, sans-serif">Description</font></th> <th><font face="Arial, Helvetica, sans-serif">Location</font></th> </tr> <?php $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"article"); $f2=mysql_result($result,$i,"year"); $f3=mysql_result($result,$i,"description"); $f4=mysql_result($result,$i,"location"); $f5=mysql_result($result,$i,"link") ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo "<a href=".$f5.">".$f4."</a>"; ?></font></td> </tr> <tr> </tr> <?php $i++; } ?> </body> </html> I'm working on customizing an open-source PHP CRM system (SugarCRM) and need some straightforward PHP help. I'm working thru an old example of writing changes to a log file and I'd like to take it one step further and open a new browser window once the save/write is done. Using the code below, could someone please direct me how to open the new window?. I basically want to pop open a new browser window from within the function below. I tried fopen, but it times out when going to a test URL such as http://www.cnn.com function UserToLog($strText){ $File = 'C:\wamp\www\log.txt'; $Handle = fopen($File, 'a'); $Data = $strText . "\n"; if($Handle){ fwrite($Handle, $Data); fclose($Handle); } //WANT TO OPEN NEW BROWSER WINDOW HERE...or wherever is correct. } All assistance is greatly appreciated. Thanks! Scenario. I have a simple form and on the same page a link to open a popup window. The client completes the form then click the upload link. In the popup window the client uploads a file. Problem On closing the popup window the main page is refreshed (to indicate the upload was successful) As the form was not initially submitted - All Form Data is then Lost Question Is there a way of submitting the form and opening a popup window at the same time (to preserve the data entered by the client) or is there another fix for this problem ? Any help is greatly appreciated. Cheers This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=320945.0 I'm trying to open a URL using fopen() and I keep getting this error: Code: [Select] Failed to open stream: Permission deniedI can not work out what is wrong, it's not a firewall as far as I can tell. As the topic sais i have a problem trying to send variables to a javascript popup window, i think the problem is on line 38. I would very much appreciate some help Code: [Select] <html> <head> <script type="text/javascript"> function newPopup(url) { popupWindow = window.open(url,'popUpWindow','height=700,width=400,left=10,top=10,resizable=no,scrollbars=no,toolbar=yes,menubar=no,location=no,directories=no,status=yes') } </script> </head> <?php error_reporting(E_ALL); require_once 'GameQ.php'; $servers = array( 'server 1' => array('cs', 'd2o.warzone.nu', '27015'), 'server 2' => array('cs', 'd2o.warzone.nu', '27017'), 'server 3' => array('cs', 'wc3.warzone.nu', '27017'), 'server 4' => array('cs', 'aim.warzone.nu', '27015'), 'server 5' => array('cs', '83.255.249.204', '27025'), 'server 6' => array('tf2', 'tf2.warzone.nu', '27015'), 'server 7' => array('tf2', '83.255.249.200', '27015'), 'server 9' => array('cssource', 'css.warzone.nu', '27015'), 'server 10' => array('cssource', 'css.warzone.nu', '27017') ); $gq = new GameQ(); $gq->addServers($servers); $gq->setOption('timeout', 200); $gq->setFilter('normalise'); $gq->setFilter('sortplayers', 'gq_ping'); $results = $gq->requestData(); echo "<a href='steam://connect/d2o.warzone.nu:27015'>" . $results["server 1"]['gq_hostname'] . "</a><p>"; echo $results["server 1"]['gq_mapname'] . "<br>"; echo $results["server 1"]['gq_numplayers'] . "/" . $results["server 1"]['gq_maxplayers']; ?> // I think the problem is the line below this one <a href='JavaScript:newPopup("players.php?address=<?php echo="$results['server 1']['gq_address']"; ?>&port=<?php echo="$results['server 1']['gq_port']"; ?>");'> players online </a>"; <?php echo "<p><p>"; echo "<a href='steam://connect/d2o.warzone.nu:27017'>" . $results["server 2"]['gq_hostname'] . "</a><p>"; echo $results["server 2"]['gq_mapname'] . "<br>"; echo $results["server 2"]['gq_numplayers'] . "/" . $results["server 2"]['gq_maxplayers'] . " players online <p>"; echo "<p><p>"; echo "<a href='steam://connect/wc3.warzone.nu:27017'>" . $results["server 3"]['gq_hostname'] . "</a><p>"; echo $results["server 3"]['gq_mapname'] . "<br>"; echo $results["server 3"]['gq_numplayers'] . "/" . $results["server 3"]['gq_maxplayers'] . " players online <p>"; echo "<p><p>"; echo "<a href='steam://connect/aim.warzone.nu:27015'>" . $results["server 4"]['gq_hostname'] . "</a><p>"; echo $results["server 4"]['gq_mapname'] . "<br>"; echo $results["server 4"]['gq_numplayers'] . "/" . $results["server 4"]['gq_maxplayers'] . " players online <p>"; echo "<p><p>"; echo "<a href='steam://connect/83.255.249.204:27025'>" . $results["server 5"]['gq_hostname'] . "</a><p>"; echo $results["server 5"]['gq_mapname'] . "<br>"; echo $results["server 5"]['gq_numplayers'] . "/" . $results["server 5"]['gq_maxplayers'] . " players online <p>"; echo "<p><p>"; echo "<a href='steam://connect/tf2.warzone.nu:27015'>" . $results["server 6"]['gq_hostname'] . "</a><p>"; echo $results["server 6"]['gq_mapname'] . "<br>"; echo $results["server 6"]['gq_numplayers'] . "/" . $results["server 6"]['gq_maxplayers'] . " players online <p>"; echo "<p><p>"; echo "<a href='steam://connect/83.255.249.200:27015'>" . $results["server 7"]['gq_hostname'] . "</a><p>"; echo $results["server 7"]['gq_mapname'] . "<br>"; echo $results["server 7"]['gq_numplayers'] . "/" . $results["server 7"]['gq_maxplayers'] . " players online <p>"; echo "<p><p>"; echo "<a href='steam://connect/tf2.warzone.nu:27015'>" . $results["server 8"]['gq_hostname'] . "</a><p>"; echo $results["server 8"]['gq_mapname'] . "<br>"; echo $results["server 8"]['gq_numplayers'] . "/" . $results["server 8"]['gq_maxplayers'] . " players online <p>"; echo "<p><p>"; echo "<a href='steam://connect/css.warzone.nu:27015'>" . $results["server 9"]['gq_hostname'] . "</a><p>"; echo $results["server 9"]['gq_mapname'] . "<br>"; echo $results["server 9"]['gq_numplayers'] . "/" . $results["server 9"]['gq_maxplayers'] . " players online <p>"; echo "<p><p>"; echo "<a href='steam://connect/css.warzone.nu:27017'>" . $results["server 10"]['gq_hostname'] . "</a><p>"; echo $results["server 10"]['gq_mapname'] . "<br>"; echo $results["server 10"]['gq_numplayers'] . "/" . $results["server 10"]['gq_maxplayers'] . " players online <p>"; ?> </html> Not to say that this occurs in every php software out there, but I far too occasionally notice that the application is written with scattered php open and close tags, for instance
<?php if(true) ?> <?php { ?> Blah blah blah, because it's true <?php } else { ?> because it's not true <?php } ?>To me, it is extremely irritating. Regardless, I see a lot of open source software written this way and I can't help but think that there must be some underlying reason for it. Magento, for example, is written exactly in this manner. The templates are infested with these opened and closed php snippets. Obscurity is not security so I'm ruling security reasons out. Maybe it is more efficient? -- But I couldn't understand why, if so. It seems like that would put more of a drag on the system itself causing php to start and stop parsing continually and excessively, then again, I'm no expert in the field of memory consumption and other operating system complexities. Honestly, in my opinion, it is stupid. i would never write a program that way.. HEREDOCs are much more useful and eye pleasing than that awful <?php { ?> I had the misfortune a few months ago when I purchased an invoicing/customer maintenance system that I didn't know was written for PHP 5.2 or something lower, one that allowed short tags; and thus short tags were used in the same manner as I've described. Is this just plain disorganization or is there some deep-seated inner lining advantage that I'm not aware of? I'm wondering what makes a pop-up login window run differently than inside a webpage. I can't seem to get my login system to bring the user back to the page (brings them to a page can't be found) when clicking a form submit button when it is included in the webpage. But if your in the popup page that I'm trying to include, it works no problem so I was wondering if it changes anything. Or if there is some sort of work around (such as embedding a popup window into the webpage). Thanks a lot! It might be a funny question, but I hope the pro can help me. I want to use ?id= to display the other page/url instead of showing the full address due to certain reasons. What do I mean is like there are 2 different static page e.g. main.php and subpage.php I would like to use id to display as the url for subpage.php i.e. main.php?id=1 actually is displaying subpage.php Any idea?? Help!! Thanks! I am new to website development. I can't figure out how to open a new tab for the following javasript. I went through related questions but nothing worked for me. I want the browser to open a new tab when someone clicks on the link (example.com) below. The code target="_blank doesn't work here... What code should I add and where should I place that code?
Hi i have been working on a cow management program PHP based. it works beautifull but now i'm stuck , and i hope i post it in the right forum. On demand php has to generate an export.txt file with basic cow information (tag#, transponder#, Bdate) this will be read by the parlour computer an Eprom based computer serial connected. I finished the script and it creates a beautifull TXt file exxept it's php http://localhost/tmp/test.php if i open that URL in notepad, it prints the txt file: Quote DH9900010090000624000900002080 VH990001 Dairy Comp 305 20100203 DN99000200312008080003000020800030000303000300035 08000300357080003001940800030003308000300036020 VN99000200001034000014010052009112620100922201102 042001111706 VN99000200001061000009420032010032820100906????????2007120101 VN99000200001083000067850032010061720100927????????2002030706 VN99000200001104000055440052009062720100817201101 032002080605 VN99000200001116000078540042010083120110207????????2002082205 VN990002000011470000816800220101226????????????????2003010806 VN99000200001153000070120032010030420100906????????2003020305 but when i enter that URL in the sync.BAT nothing happends.. my question is, doe anyone know if there is a way to fool DOS for accepting a PHP url?. OR is there a way for Apache to treat one TXT file as an PHP file? my script: Code: [Select] <?php //request sql cow info $db_host = 'localhost'; $db_user = ''; $db_pwd = ''; $database = 'cowdbase'; $table = 'cows'; if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); // sending query $result = mysql_query("SELECT * FROM {$table}"); if (!$result) { die("Query to show fields from table failed"); } //quiery alle info $query="SELECT * FROM {$table}"; $result=mysql_query($query); // hoeveel rijen zijn er? $num=mysql_numrows($result); //Type the header from the text file echo "DH9900010090000624000900002080" . PHP_EOL ; echo "VH990001 Dairy Comp 305 20100203" . PHP_EOL ; echo "DN9900020031200808000300002080003000030300030003508000300357080003001940800030003308000300036020" . PHP_EOL ; mysql_close(); $i=0; while ($i < $num) { $cowtag=mysql_result($result,$i,"cowTag"); $bdate=mysql_result($result,$i,"Bdate"); $group=mysql_result($result,$i,"group"); $alpro=mysql_result($result,$i,"Alpro_trans"); // LIST ALLE KOEIEN KOE VOOR KOE /// unknown cowtag unknown-0000 #### Alpro tag 00 Group 20 Fresh dateyymmdd 20 Heatdate yymmdd, Drydate YYYYMMDD, Birthdate YYYYMMDD Lactation number ## echo "VN9900020000" . str_pad($cowtag, 4, "0", STR_PAD_LEFT) . "0000" . str_pad($alpro, 4, "0", STR_PAD_LEFT) . "00" . "$group" . "20" . "0000" . "????????????????" . "00000000" . "01" . PHP_EOL ; $i++; } echo "EN" . PHP_EOL ; echo "ZN" . PHP_EOL ; ?> Hi, I need to open an RTF File on client side. When user submit form, the system will write some data in database and at the end, it has to open an rtf file in order to user be able to print it. Any ideas? Thanks Hugo Hi I am trying to get the structure of some folders/files on my server to create an xml "Feed" which then goes to a flash file. I keep getting the error message that I can't open the folder (it is set to 755) ERROR: Could not open folder: http://www.name/templates/bluezoo/mp3s What am I doing wrong please. Many thanks in advance Edward Here's some php: Code: [Select] $directoryLocation="http://www.name/templates/bluezoo/mp3s"; // XML Doctype $xml = new DomDocument('1.0', 'UTF-8'); $xml->xmlStandalone = false; // XML Root element $root = $xml->createElement('mp3s'); $root = $xml->appendChild($root); // Grab a list of folders from the specified directory if ($dir = @opendir($directoryLocation)) { while (false !== ($file = readdir($dir))) { if (is_dir($directoryLocation . DIRECTORY_SEPARATOR . $file) && $file != '.' && $file != '..') { // If it is a folder, put it in the folders array $folders[] = $file; } } I have this code: $shell = new COM('WScript.Shell'); $shell->Run("C:\WINDOWS\system32\cmd.exe /K ".$ini['indexer']['command'], 0, false); When it runs, it opens the command line, but then when it is done, it leaves the process open. How can I close it when the process is complete? I had some errors in my script but I solved the most of them except two: Warning: require_once(/home/a3443899/smarty/libs/Smarty.class.php) [function.require-once]: failed to open stream: No such file or directory in /home/a3443899/public_html/include/config.php on line 32 Fatal error: require_once() [function.require]: Failed opening required '/home/a3443899/smarty/libs/Smarty.class.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/a3443899/public_html/include/config.php on line 32 And I checked the map what he couldn't open the map names are just good Here is the config.php script: Code: [Select] <? $config = array(); // Begin Configuration // This Template was Downloaded From GrabTemplates.com $config['basedir'] = 'something'; $config['baseurl'] = 'something'; $DBTYPE = 'mysql'; $DBHOST = 'my host'; $DBUSER = 'my username'; $DBPASSWORD = 'my pass'; $DBNAME = 'my dbname'; // End Configuration ini_set('session.save_path', $config['basedir']. '/temporary/sessions'); session_start; $config['adminurl'] = $config[baseurl].'/administrator'; $config['cssurl'] = $config[baseurl].'/css'; $config['imagedir'] = $config[basedir].'/images'; $config['imageurl'] = $config[baseurl].'/images'; $config['picdir'] = $config[basedir].'/pics'; $config['picurl'] = $config[baseurl].'/pics'; $config['tpicdir'] = $config[basedir].'/pics/thumbs'; $config['tpicurl'] = $config[baseurl].'/pics/thumbs'; $config['membersprofilepicdir'] = $config[imagedir].'/membersprofilepic'; $config['membersprofilepicurl'] = $config[imageurl].'/membersprofilepic'; $config['mbgdir'] = $config[imagedir].'/mbg'; $config['mbgurl'] = $config[imageurl].'/mbg'; require_once($config[basedir].'/smarty/libs/Smarty.class.php'); require_once($config[basedir].'/libraries/mysmarty.class.php'); require_once($config[basedir].'/libraries/SConfig.php'); require_once($config[basedir].'/libraries/SError.php'); require_once($config[basedir].'/libraries/adodb/adodb.inc.php'); require_once($config[basedir].'/libraries/phpmailer/class.phpmailer.php'); require_once($config[basedir].'/libraries/SEmail.php'); function strip_mq_gpc($arg) { if (get_magic_quotes_gpc()) { $arg = str_replace('"',"'",$arg); $arg = stripslashes($arg); return $arg; } else { $arg = str_replace('"',"'",$arg); return $arg; } } $conn = &ADONewConnection($DBTYPE); $conn->PConnect($DBHOST, $DBUSER, $DBPASSWORD, $DBNAME); @mysql_query("SET NAMES 'UTF8'"); $sql = "SELECT * from config"; $rsc = $conn->Execute($sql); if($rsc){while(!$rsc->EOF) { $field = $rsc->fields['setting']; $config[$field] = $rsc->fields['value']; STemplate::assign($field, strip_mq_gpc($config[$field])); @$rsc->MoveNext(); }} if ($_REQUEST['language'] != "") { if ($_REQUEST['language'] == "english") { SESSION_REGISTER("language"); $_SESSION[language] = "english"; } elseif ($_REQUEST['language'] == "spanish") { SESSION_REGISTER("language"); $_SESSION[language] = "spanish"; } elseif ($_REQUEST['language'] == "french") { SESSION_REGISTER("language"); $_SESSION[language] = "french"; } } if ($_SESSION['language'] == "") { SESSION_REGISTER("language"); $_SESSION[language] = "english"; } if ($_SESSION['language'] == "english") { include("lang/english.php"); } elseif ($_SESSION['language'] == "spanish") { include("lang/spanish.php"); } elseif ($_SESSION['language'] == "french") { include("lang/french.php"); } else { include("lang/english.php"); } for ($i=0; $i<count($lang)+1; $i++) { STemplate::assign('lang'.$i, $lang[$i]); } STemplate::assign('baseurl', $config['baseurl']); STemplate::assign('basedir', $config['basedir']); STemplate::assign('adminurl', $config['adminurl']); STemplate::assign('cssurl', $config['cssurl']); STemplate::assign('imagedir', $config['imagedir']); STemplate::assign('imageurl', $config['imageurl']); STemplate::assign('picdir', $config['picdir']); STemplate::assign('picurl', $config['picurl']); STemplate::assign('tpicdir', $config['tpicdir']); STemplate::assign('tpicurl', $config['tpicurl']); STemplate::assign('membersprofilepicdir', $config['membersprofilepicdir']); STemplate::assign('membersprofilepicurl', $config['membersprofilepicurl']); STemplate::assign('mbgdir', $config['mbgdir']); STemplate::assign('mbgurl', $config['mbgurl']); STemplate::setCompileDir($config['basedir']."/temporary"); STemplate::setTplDir($config['basedir']."/themes"); ?> |