473,813 Members | 3,228 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to save page content to a text file

93 New Member
Hi

I have a popup windows that display the database content and I want to have save button that save content to a text file.

Most code I found is saving a text area.

How do I do that?

Thanks
Oct 22 '07 #1
5 3922
pbmods
5,821 Recognized Expert Expert
Heya, NMA.

Create a new PHP script to load and save the database content and link to that file.

You can tell the browser to display the content as text by using this line:
Expand|Select|Wrap|Line Numbers
  1. header('Content-type: text/plain; charset=characterSetGoesHere');
  2.  
The value of charset is generally 'utf-8', but you might have a long string that begins with 'iso' if you develop on a Windows system.

You can also create a force download script.
Oct 22 '07 #2
nma
93 New Member
Hi,

Sorry I'm a bit blurr on the complete code sinde my deadline is only one day left. Please can someone let me know the complete code.

Should I make a hyperlink text(to activate the save link etc/save button) that will point to another php file say save.php that will contain all the headers information of php?

I attached the code that display the database content

[PHP]
<?php
session_start() ;


if(!isset($_SES SION['user'])) {
header('Locatio n: /Login.html');
die();
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<SCRIPT LANGUAGE="JavaS cript">


function varitext(text){
text=document
print(text)
}

</script>




<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>See All My Notes</title>
<link rel="stylesheet " href="moviebrow ser2.css" type="text/css" title="Default" media="screen"/>
<style type="text/css">
.style2 {color: #FFFFCC}

</style>
</head>

<span class="style2"> </span>
<body bgcolor="#FFFFF F">

<table width="750" border="0">

<?php
include_once('. ./ez_sql.php');
?>

<tr>
<td width="100" align="left" valign="top" class="movieinf o_headtext">Mov ie Title </td>
<td width="300" align="left" valign="top" class="movieinf o_headtext">Not es </td>
<td width="100" align="left" valign="top" class="movieinf o_headtext">Dat e </td>
<td width="150" align="left" valign="top" class="movieinf o_headtext">Eve nt Category </td>
<td width="100" align="center" valign="top" class="movieinf o_headtext">Eve nt No. <br/></td>
</tr>
<?php

$notesDetails = $db->get_results("e xec spShow_Movie_An d_Events_Notes_ By_User " . $_SESSION['user']->userID ." ");


foreach ($notesDetails as $notes)
{
?>
<tr>
<td width="100" align="left" valign="top" class="displayN otesBox1"><?php echo $notes->movieTitle;? ></td>
<td width="300" align="left" class="displayN otesBox1" valign="top"><? php echo $notes->noteText;?></td>
<td width="100" align="left" valign="top" class="displayN otesBox1"><?php echo $notes->noteDate;?></td>
<td width="150" align="left" valign="top" class="displayN otesBox1"><?php echo $notes->EventCategory; ?></td>
<td width="100" align="center" valign="top" class="displayN otesBox1"><?php echo $notes->eventNo;?><b r/></td>
</tr>

<?php
}
?>
<tr>
<td></br></br></br></br></td>
</tr>

<tr>
<td>

<DIV ALIGN="CENTER">
<FORM>
<INPUT NAME="print" TYPE="button" VALUE="Print this Page"
ONCLICK="varite xt()">
</FORM>
</DIV>
<!-- <form method="post">
<input name="save" type="submit" value="Save My Notes"></td>
</form> -->
</td>
</tr>
</table>
</body>
</html>



[/PHP]
Oct 23 '07 #3
nma
93 New Member
Hi
How do I change the code below if I want the filename will depend on username and not hardcode like $myFile = "Notes.txt" ; below? The filename will be say "username.t xt"

Thnask

[PHP]
<?php
session_start() ;

// Make sure users are logged in.
if(!isset($_SES SION['user'])) {
header('Locatio n: /MB2Login.html') ;
die();
}
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Save Notes</title>


</head>
<html>

<?php
include_once('. ./ez_sql.php');
?>

<body>
<?php
//to create a file
$myFile = "Notes.txt" ;

$fh = fopen($myFile, 'w') or die("can't open file");[/PHP]
Oct 25 '07 #4
pbmods
5,821 Recognized Expert Expert
Heya, NMA.

Try this:
Expand|Select|Wrap|Line Numbers
  1. $myFile = "{$_SESSION['user']}.txt";
  2.  
Oct 25 '07 #5
nma
93 New Member
thank you very much!!!!
Oct 26 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
3482
by: Aliza Klein | last post by:
I am new to ASP so please pardon me if this is crazy. I have data that I want to allow the user to be able to save in a format that will then enable the user to open the data in Excel. (I have already read the previous CSV posts and still have a question.) I have an ASP page that takes some data from a previous page,adds some column headings and displays it all in apparent CSV format. All I am trying to do is allow the users to do a...
2
2932
by: RickL | last post by:
I have an ASP application that uploads a specified file to the server. To retrieve the file, I simply assign the filepath and file to a hyperlink on the page. When you click "Save Target As" for some file types, I get the following error messsage: IE can not download <file> from <server>. IE was not able to open this internet site. The requested site is either unavalable or can not be found. Can anyone tell me how to save a file of any type?...
4
2854
by: David W. Simmonds | last post by:
Is there a way I can have a button on a ASP.NET form that when clicked will allow the user to save the image to a file on the client side? I know that the user can simply rclick the image and select Save Target as..., but the button might be a more intuitive way.
7
3710
by: theyas | last post by:
How can I get my code to NOT display two "Open/Save/Cancel/More Info" dialog boxes when using the "Response.WriteFile" method to download a file to IE I've asked about this before and didn't get a satisfactory answer (check your browser) so now that I've had the time to set up a reasonable little test that I can post somewhere, I'll try again. The app I've written has three ASPX pages. One is a combined page which writes a little text...
0
2982
by: Dune | last post by:
Hi there, I have an aspx page that allows users to enter several parameters using drop downs and text boxes. The users then press a button that produces an extract based on the parameters they entered. When this button is pressed and extract is prduced and IE's standard Open/Save dialog should popup so they can navigate to the directory to save the extract in, or if they want, they can choose to open and view the extract without saving it. ...
4
3721
by: Glenn M | last post by:
I have a shared XML file on a server . i also have one xslt file that performs a simple transform on in to view the data. now i want to have another page that lets users modify the shared xml file via some editable controls such as text boxes , option boxes etc. how can i implment this , should i use another xslt file with <INPUT> controls . if so how can i save the result back using the asp.net
8
2708
by: DanB | last post by:
This is probably soooo simple but I can't seem to get it. I have a text file that I want users to download via a web page. I want the file to be saved to a default folder (or one that they choose) on the users / client file system. I have toyed with a Self-Extracting zip file but the contents of my zip file changes each time it is downloaded so that invalidates the exe file. Also the text file is so small it is a waste to zip it.
12
4780
by: =?Utf-8?B?RnJlZU5FYXN5?= | last post by:
Hello, the scenario: There's an ASPX page which shows some text and has three buttons at the bottom: Save, Print and Close. Print and close is done by javascript. But how can I save the page on the client's computer? He/she could do this using the browser (file/save), but I need to have it done by pressing the pushbutton. In my serverside code I get the button-click-event, I also know how to get
3
3689
by: Angus | last post by:
I have a web page with a toolbar containing a Save button. The Save button can change contextually to be a Search button in some cases. Hence the button name searchsavechanges. The snippet of html is: <a class="searchsavechanges btn btn3d tbbtn" href="javascript:" style="position:static"> <div id="TBsearchsavechanges">Search</div> </a>
1
4888
by: chennaibala | last post by:
can any one send me mutiple image upload program and save the file name with extension in mysql table.we must cheak uploaded file type like bmp or any image file while uploading. i develop program,which can upload many file in folder.problem is,am unable to save my file name in to database.because i used same name for all input file type as file. i dont know get name of file.below i presented my coding for ur view.fed up with my coding..pls...
0
9607
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10665
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10406
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9221
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5568
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5704
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3881
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3029
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.