This is a discussion on Write to text file within the PHP Language forums, part of the PHP Programming Forums category; Hello I'm a complete php noob and a non-programmer. I would appreciate any help. I have a form ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello
I'm a complete php noob and a non-programmer. I would appreciate any help. I have a form which takes user input. On submit, the form will run a php script that will create a new text file using the user input. I want this text file to popup or open in a new page. The problem is that when the page opens it still shows the old text file, i need to hit refresh for it to show the last user input. the html file (greatly simplified): <html><head> <title>Untitled</title> </head> <body> <form action="action.php" method="post"> <p>Title: <input type="text" name="Title" /></p> <p><input type="submit" /></p> </form> </body> </html> The php file (simplified as well): <?php $spot_code = $_POST['Title']; // Open the file and erase the contents if any $fp = fopen("myfile.3dml", "w"); fwrite($fp, "<TITLE NAME=" . '"'. $spot_code .'"'. " />\n"); fclose($fp); //redirect header( 'Location: http://localhost/mytest/myfile.html' ); ?> the text file, myfile.3dml is embedded in myfile.html (it requires a plugin to view - it's a 3D world). When myfile.html is opened it displays myfile.3dml but it needs to be refreshed to show the current input. how can i ensure the current input is displayed. also, how would i make a popup appear rather than have myfile.html open in a new page. thanks |
|
|||
|
A popup is a new page. You just need to program the new pages title,
size, scroll, and other elements. http://www.askblax.com |
|
|||
|
<jcwmtl@hotmail.com> wrote in message news:1117165799.646274.319090@g14g2000cwa.googlegr oups.com... > Hello > I'm a complete php noob and a non-programmer. > I would appreciate any help. > I have a form which takes user input. On submit, the form will run a > php script that will create a new text file using the user input. > > I want this text file to popup or open in a new page. The problem is > that when the page opens it still shows the old text file, i need to > hit refresh for it to show the last user input. To make the page open up a new page you need to put the following code in the head of your HTML document (e.g. underneath the title). <meta http-equiv="REFRESH" content="0;url=http://www.yoursite.com/newpage.html"> To open a pop-up you'll need to use javascript. -- Richard Quick http://www.chocolatemagazine.co.uk |
|
|||
|
Thanks Richard.
I know how to create a popup using js, but i'm uncertain as to how to combine that with php. Richard Quick wrote: > <jcwmtl@hotmail.com> wrote in message > news:1117165799.646274.319090@g14g2000cwa.googlegr oups.com... > > Hello > > I'm a complete php noob and a non-programmer. > > I would appreciate any help. > > I have a form which takes user input. On submit, the form will run a > > php script that will create a new text file using the user input. > > > > I want this text file to popup or open in a new page. The problem is > > that when the page opens it still shows the old text file, i need to > > hit refresh for it to show the last user input. > > > To make the page open up a new page you need to put the following code in > the head of your HTML document (e.g. underneath the title). > > <meta http-equiv="REFRESH" > content="0;url=http://www.yoursite.com/newpage.html"> > > To open a pop-up you'll need to use javascript. > > -- > Richard Quick > http://www.chocolatemagazine.co.uk |
|
|||
|
<jcwmtl@hotmail.com> wrote in message
news:1117193572.836041.28080@z14g2000cwz.googlegro ups.com... > Thanks Richard. > I know how to create a popup using js, but i'm uncertain as to how to > combine that with php. > You should just be able to get PHP to generate the URL of the page you want to appear in the pop up. eg. if the page you want to display has the url: www.mysite.com/page.php?query=123 and you have a javascript function called makepopup which takes a url as a variable Then you would put the following (or similar) in your html code: makepopup('<?php echo $urlToVisit; ?>') -- Richard Quick http://www.chocolatemagazine.co.uk |
|
|||
|
Thank you so much Richard.
I put the refresh in the php and my file refreshes properly now. Hate to trouble you some more, but if i wanted the html file in a frame rather than a new page...how would i modify the php? the php (simplified) looks like this now: <?php $spot_code = $_POST['Title']; $fp = fopen("myfile.3dml", "w"); fwrite($fp, "<TITLE NAME=" . '"'. $spot_code .'"'. " />\n"); fclose($fp); ?> <meta http-equiv="REFRESH"content="0;url=http://localhost/spotcoder/myfile.html"> the above code takes input from a first html file, writes it to file myfile.3dml which is embedded in myfile.html. myfile.html opens in a new page. could i make it open in a frame..ie. with some target=main attribute? thanks |