Jump to content

Archived

This topic is now archived and is closed to further replies.

patk24

Error with PHP

Recommended Posts

OK..im tryin to have this from saved to a txt file and heres the code:
[code][<form method='post'>
    Name: <input name='Name' type='text' /><br />
    Email: <input name='Email' type='text' /><br />
    Comment: <input name='Comment' type='text' /><br />
    <input type='submit' name='Confirm' />
</form>
<?php

if(isset($_POST))
{
    $filename = "subscribers.txt";
    $content = $_POST['Name']."\n".$_POST['Email']."\n".$_POST['Comment']."\n\n\n";
    $fp = fopen($filename, "a");
    $fw = fwrite( $fp, $content );
    fclose( $fp );
   
    if(!$fw) echo "Couldn't write the entry.";
    else echo "Successfully wrote to the file.";
}
?>[/code]

I get an "undifened index" error for 'Name' 'Comment' and 'Email'
How can i fix this? BTW it says that its been successfully wrote to a file i just get that error and it says its on line 273 and that line is this one:
[code]$content = $_POST['Name']."\n".$_POST['Email']."\n".$_POST['Comment']."\n\n\n";[/code]

can anyone help?

Share this post


Link to post
Share on other sites
The first problem you have is the way you are checking for $_POST variables. $_POST is always set, although sometimes it is empty. Change isset($_POST) to sizeof($_POST)>0, then give it a shot.

Share this post


Link to post
Share on other sites

×

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.