FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » newbie question
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: newbie question [message #170965 is a reply to message #170964] Sun, 12 December 2010 16:07 Go to previous messageGo to previous message
justaguy is currently offline  justaguy
Messages: 16
Registered: December 2010
Karma:
Junior Member
On Dec 12, 10:00 am, Magno <marbar...@gmail.com> wrote:
> On 12/12/2010 11:39 AM, Thomas 'PointedEars' Lahn wrote:
>
>
>
>> justaguy wrote:
>
>>> This is my very first php script and I'm already in trouble.  I'd like
>>> it to do two things:
>>> a) append the email address to the Log.txt file on the server at the
>>> same location;
>>> b) redirect to newlocation.html page
>
>>> The redirection is ok but the email capture failed.  It seems that the
>>> logMessage isn't called.  How can we fix it?
>
>> Just a wild guess, but why not try calling it?
>
>>> Thanks.
>
>>> <?php
>>> $email = $_POST['email'];
>>> // $email = $HTTP_POST_VARS['email'];
>>> echo "$email<br />";
>
>>> function logMessage($email)
>>>     // debug
>>>     echo "email recording function called.";
>>> {
>>> $myFile = "Log.txt";
>>> $contentsOld = file_get_contents($myFile, true);
>>> $fh = fopen($myFile, 'w') or die("couldnt locate log file");
>
>>> $stringData = date("l F j, Y, g:i:s a") . "\nEmail: " . $email . "\n
>>> \n";
>>> fwrite($fh, $contentsOld);
>>> fwrite($fh, $stringData);
>
>> Do you not find it the least bit strange to read the content of a file,
>> replace the content with the content, then write new content, and call that
>> process "appending" the new content to the file?
>
>> You have already discovered the `w' flag for fopen().  Guess what other
>> flags there might be …
>
>> Bottom line: RTFM.
>
> As expected, PointedEars like always waiting for other to answers, and
> comes with his stupid version to insult the OP.
>
> justaguy: don’t pay attention to PointedEars, he is a troll which always
> insults newcomers and treats them like idiots.
> Everybody else has filtered him for the same reason.

Thank you all, probably I didn't word it correctly in that the code
initially by someone else who's much into php and I added the last
element of redirection. Since I didn't know how php works and assumed
he did the right thing and that seemed to stop me from thinking...
Thanks again, problem solved.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Use of Includes
Next Topic: Stats comp.lang.php (last 7 days)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Oct 20 05:50:53 GMT 2024

Total time taken to generate the page: 0.04384 seconds