English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Im trying to make my script so that it sends the text from 2 text boxes to the top, but i can only get it to bottom

the send.php

$thedate = date("F d, Y");
$filename = "downloads.php";
$user = $_GET["name"];
$message = $_GET["message"];
$out = fopen($filename, "a");
if (!$out)
{
print("Could not append to file");
exit;
}
fputs ($out,implode,("\n"));
fwrite($out,"$thedate - $name
");
fclose($out);
?>

in html file to send to code:


Admin Add Download



Link Text:


Link:





2007-02-28 15:45:03 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

3 answers

Do this
$thedate = date("F d, Y");
$filename = "downloads.php";
$user = $_GET["name"];
$message = $_GET["message"];
if(fiel_exists($filename))
{
$strContents = file_get_contents($filename);
$strContents = $thedate ."-$name
\r\n".$strContents;
}
else
{
$strContents = $thedate ."-$name
";
}
$out = fopen($filename,"w") or die("cannot open file");
fwrite($out, $strContents);
fclose($out);
?>

2007-02-28 17:56:32 · answer #1 · answered by Atif Majid 3 · 0 0

Er... you do know the meaning of the word "append", I trust?

http://en.wiktionary.org/wiki/append

Solution: read the entire file contents, truncate the file, write the new content, THEN write the old content back. Don't forget to acquire a lock on the file.

2007-02-28 16:32:28 · answer #2 · answered by felixp7 2 · 0 0

you ignored a "dot" (concatenation operator): "t" $password could be: "t" . $password EDIT: playstation : in own abode page you may in basic terms use double costs while you are going to apply variable substitution like this: $form_data = "$firstNamet$lastNamet$emailt$userNam... it extremely is cleanser (and probably swifter) for this line than using concatenation else you ought to use single costs.

2016-11-26 21:26:29 · answer #3 · answered by Anonymous · 0 0

fedest.com, questions and answers