Jump to content

Recommended Posts

hi,

 

Is some possibility to create backup from text, mean to have a „last saved” text when somebody write a text and save it time after time. (as in word)

 

$query = mysql_query("INSERT INTO `text` (`text`) VALUES ('".$_POST['text']."')");

 

 

thnxs

I'm pretty sure you can have do this with AJAX.

 

I dont know the ajax - I want to do this with PHP if its possible, somehow - on every "save" to have a „backup” written ’till time pushed the submit button.

Oh sorry, Thought you meant as they type a new letter it saves it into the database. I really don't understand your question, could you please be more specific? Thanks.

 

I hope I can explain (my motherlanguage is hungarian) - I want backup like word do the backup when you write an text, and push the save, then create an backup-file where is the „last saved” text.

 

I want a same but the back-up is not a file just a column in database (backup_text).

 

I hope ist clearly now

Yes that's fine, what part do you want help with?? Are you planing on having the user hit save for this?

 

I got user(s) who write his text, and in a one moment delete text from textarea form, than push the „save” button... the text is dissapear afcourse :) ... so, if its possible, I want to keep a safe backup („last saved”) in a database in some column, no need another table.

In which case you need to create a form (with the textarea)

 

The save button should submit the form to the page stated in the action attribute of the form.

 

on this second page you take the text from the textarea (posted to the page) and run an sql query to save it to the database.

 

You can then push the user back to the previous page with the text in the textarea.

In which case you need to create a form (with the textarea)

 

The save button should submit the form to the page stated in the action attribute of the form.

 

on this second page you take the text from the textarea (posted to the page) and run an sql query to save it to the database.

 

You can then push the user back to the previous page with the text in the textarea.

 

I count  reloads. At first reload is nothing to do, at second reload is

 

$query = mysql_query("INSERT INTO `text` (`text`) VALUES ('".$_POST['text']."')");

 

and if the reload is bigger than 2 cames the updates. So that is all what is doing on the page, form is working at self (PHP_SELF) no other page.

 

So after everi pageloads need a plus (previous) backup...

I'm not really sure what you want...

 

Post your code and I'll see if I can help

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php 
// Connect to dBase
include "mysql_connect.php";
error_reporting(E_ERROR);
@ini_set('display_errors', '1');

// Reload ++
$_REQUEST['reload']++;
?>


<?php 
// Reload == 2
if($_REQUEST['reload'] == "2") {

$TextUpload = $_POST['text'];

$TextUpload = str_replace("  "," ", $TextUpload);

// Insert into dBase
$query = mysql_query("INSERT INTO `sn_text` (
	`sn_text_godina`,
	`sn_text_broj`,
	`sn_text_nadnaslov`,
	`sn_text_naslov`,
	`sn_text_podnaslov`,
	`text`,
	`sn_text_author`,
	`sn_text_datetime`,
	`sn_text_ip`
) VALUES (
	'".date("Y")."',
	'".$_POST['sn_text_broj']."',
	'".$_POST['sn_text_nadnaslov']."',
	'".$_POST['sn_text_naslov']."',
	'".$_POST['sn_text_podnaslov']."',
	'".$TextUpload."',
	'".$UsrID."',
	'".date("Y-m-d H:i:s")."',
	'".getenv("REMOTE_ADDR")."'
)");

// Check query
if(!$query){
	print mysql_error();
	exit;
}

// Retrieves the last ID
$sn_text_id = mysql_insert_id();

// Reload from dBase
$query_return = mysql_query("SELECT * FROM `sn_text` WHERE `sn_text_id` = '".$sn_text_id."'");

// Check query
if(!$query_return){
	print mysql_error();
	exit;
}

// Request query
$request = mysql_fetch_array($query_return);


} // End of Reload
?>












<?php 
if($_REQUEST['reload'] > "2") {

$TextUpload = $_POST['text'];

$TextUpload = str_replace("  "," ", $TextUpload);

// Update database
$query_update = mysql_query("UPDATE `sn_text` SET
	`sn_text_godina` = '".date("Y")."',
	`sn_text_broj` = '".$_POST['sn_text_broj']."',
	`sn_text_nadnaslov` = '".$_POST['sn_text_nadnaslov']."',
	`sn_text_naslov` = '".$_POST['sn_text_naslov']."',
	`sn_text_podnaslov` = '".$_POST['sn_text_podnaslov']."',
	`text` = '".$TextUpload."',
	`sn_text_datetime_modify` = '".date("Y-m-d H:i:s")."',
	`sn_text_ip` = '".getenv("REMOTE_ADDR")."'
WHERE
	`sn_text_id` = '".$_POST['sn_text_id']."'
");


// Reload from dBase
$query_return = mysql_query("SELECT * FROM `sn_text` WHERE `sn_text_id` = '".$_POST['sn_text_id']."'");

// Check query
if(!$query_return){
	print mysql_error();
	exit;
}

// Request query
$request = mysql_fetch_array($query_return);

} // End of Reload
?>





<!-- TxtInpt -->
<div><form action="<?php print $_SERVER['PHP_SELF'];?>" method="post" name="main" id="main" >
<div class="ConterExplain">Text: <textarea name="text" cols="75" rows="50" class="TxTInptAra1"><?php print $request['text'];?></textarea></div>
<div class="SnmiButton"><input type="submit" name="submitbutton" value="SUBMIT" class="WrdSaveBtton" /></div>
<div><input type="hidden" name="reload" value="<?php print $_REQUEST['reload'];?>" /></div>
<div><input type="hidden" name="sn_text_id" value="<?php print $request['sn_text_id'];?>" /></div>
</form></div>
<!-- # TxtInpt # -->
</body>
</html>

 

 

well:

 

1. at Reload == 1

 

nothing to do, just begin user to write text

 

example: "ABCDE"

 

 

1. he push the submit, this is the Reload == 2

- the text saved in to `text` column

- in the database `text` coloum is the text: "ABCDE".

- the user continue writing text "ABCDEFGHIJKL".

 

1. he push the submit, this is the Reload > 2

- the text "ABCDEFGHIJKL" goes into `text_backup` column (this is not in code yet)

- and the text "ABCDEFGHIJKL" goes into `text`

- the user continue writing text "ABCDEFGHIJKLMNOPQRST"

 

 

1. he push the submit, this is the Reload > 2

- the text "ABCDEFGHIJKL" goes into `text_backup` column (this is not in code yet)

- and the text "ABCDEFGHIJKLMNOPQRST" goes into `text`

 

 

1. he push the submit, this is the Reload > 2

- the text "ABCDEFGHIJKLMNOPQRST" goes into `text_backup` column (this is not in code yet)

- and the text "ABCDEFGHIJKLMNOPQRSTABDCDEFG" goes into `text`

 

 

1. he push the submit, this is the Reload > 2

- the text "ABCDEFGHIJKLMNOPQRSTABDCDEFG" goes into `text_backup` column (this is not in code yet)

- and the text "ABCDEFGHIJKLMNOPQRSTABDCDEFGHIJKLMAN" goes into `text`

 

...

 

Just like in Windows Word, I need a safe backup from the wrting text on every pushed submit button. Not a same text as goes into `text` column, I need the previous saved.

 

 

Hey, I GOT THE SOLUTION, BUT I still need Your help, at first to tell me is that a good solution, at second, I dont know something:

 

The solution:

 

I use the "Reloads"...

 

1. reload = nothing happened

2. reload = text goes into `text` and `backup_text` column

3. reload = text goes only in `text` column

4. reload = text goes into `text` and `backup_text` column

5. reload = text goes only in `text` column

6. reload = text goes into `text` and `backup_text` column

7. reload = text goes only in `text` column ...

 

so I nedd next:

 

if($_REQUEST['reload'] == uneven number) {

text goes into `text` column

}

 

if($_REQUEST['reload'] == even number) {

text goes into `text` and `backup_text` column

}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.