Jump to content


Photo

Error with PHP


  • Please log in to reply
2 replies to this topic

#1 patk24

patk24
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 23 September 2006 - 07:22 PM

OK..im tryin to have this from saved to a txt file and heres the 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.";
}
?>

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:
$content = $_POST['Name']."\n".$_POST['Email']."\n".$_POST['Comment']."\n\n\n";

can anyone help?

#2 patk24

patk24
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 23 September 2006 - 08:46 PM

any help??

#3 mb81

mb81
  • Members
  • PipPipPip
  • Advanced Member
  • 120 posts

Posted 23 September 2006 - 08:50 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users