Subscribe to my Newsletter

Discussion in 'PHP' started by bengaluru, Jun 9, 2008.

  1. bengaluru

    bengaluru Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #21
    You must be losing patience by now with my silly questions. This is what I did as per your instructions and it does not work.

    Put this code in a file and called it newsletter.php

    <?php
    // File Name
    $filename = "newsletter.php";

    //Name
    $name = $_REQUEST['name'];
    //Email
    $email = $_REQUEST['email'];

    //Write To File
    $emails = fopen("emails.txt","a");
    fwrite($emails, $name." | ".$email."\n");
    fclose($emails);

    // If They've Filled Out The Form
    if(isset($name)) {
    // Tell them this.
    echo "Thank You ".$name.". Your email has been added to our mailing list.";
    }


    ?>

    And this code at the place where I want the form to appear
    <form action="<? echo $filename; ?>" method="POST">
    Name: <input name="name">
    Email: <input name="email">
    <input type="submit">
    </form>



    Did I do this right or not ?? I can see that there is something wrong because I dont understand how the form will call for the php file when there is no reference.
     
    bengaluru, Jun 13, 2008 IP
  2. coffeesonnow

    coffeesonnow Peon

    Messages:
    34
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #22
    hmm ok. In the filename field, try putting the full web address of the php file. :)
     
    coffeesonnow, Jun 13, 2008 IP
  3. bengaluru

    bengaluru Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #23
    :mad: Sorry my friend Nothing is working. Maybe it is something I am not doing right.

    I think I wasted too much of your time and do not wish to take any more. You have been a great help and thanks for all the help and your precious time.
     
    bengaluru, Jun 14, 2008 IP