Jump to content

forms, Post


Recommended Posts

I've not been able to get an answer to the below elsewhere. So I have found may way here. This code posts to existing files although I need to:

 

a)Limit bytes written or added.

 

b) How to add the following to record the date in MySQL:

<input type="hidden" name="RetEdit" value="<?php echo date('Y-m-d', strtotime("+0 days")); ?>">

 

<?php

// umask to maintain file permissions during next procedure

umask(000);

$filename = $row_Recordset_rs['ReID'].'__r.txt';

$fullfilename=$_SERVER['DOCUMENT_ROOT']."/file3/".$filename;

if (file_exists($fullfilename)) {

if (isset($_POST['submit']) && isset($_POST['contents'])) {

if (is_writable($fullfilename)) {

if ($fp = fopen($fullfilename, 'wb')) {

$bytes = fwrite($fp, $_POST['contents']);

if ($bytes === false) {

echo "Error: could not write to file '{$fullfilename}'";

}

else {

echo "{$bytes} bytes written to file '{$fullfilename}'";

}

fclose($fp);

}

else {

echo "Error: could not open file '{$fullfilename}' for writing";

}

}

else {

echo "Error: file '{$fullfilename}' is not available for writing";

}

}

else {

if (is_readable($fullfilename)) {

echo '<form action= "' . $_SERVER['PHP_SELF'] . '" method="post">'

. '<textarea name="contents" rows="15" cols="80">'

//for PHP 4.3.0 or newer, which this server has

. htmlspecialchars(file_get_contents($fullfilename))

 

. '</textarea><br />'

. '<input type="submit" name="submit" value="Update Q"></form>' ;

 

}

else {

echo "Error: could not open file '{$fullfilename}' for reading";

}

}

}

?>

Link to comment
Share on other sites

With ref the above here are two example of hidden fiels with different date formats.

 

<form name="form1" method="post" action="your_script.php">

 

<p>

<input name="date in sql" type="hidden" id="date/in/sql" value="<?php echo date("n/j/Y g:i:s A"); ?>">

 

<input name="dateinrfcformat" type="hidden" id="date/in/rfc/format" value=" <?php echo date("r"); ?>">

</p>

<p>

<input type="submit" name="Submit" value="Submit">

</p>

</form>

 

 

Link to comment
Share on other sites

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.