Quick Programming Help

by 7 replies
8
Hey I have a website perfectballhandling.com and I want the user to be able to press the get updates button enter their email and it saves to mail.php on my server. can you tell me what i'm doing wrong?
#programming #programming #quick
  • Hi,

    Its probably something to do with your mail.php file. Have you edited it to email the input to your email address?

    If you are not sure you could post the mail.php content here and someone might be able to give you a better idea as to what you've done wrong.

    Cheers

    Max
  • what i want the site to do is save the email address's imputed to the mail.php file. so all the emails will be in the file
    • [1] reply
    • Do you have a database like MySql? Or do you just want the emails emailed to you?
  • i just want the emails saved to mail.php. but if it's easier then yeah i'll have them emailed to me
    • [1] reply
    • Create a 'email.txt' file and change it's permission to writable.
      Place this script in mail.php

      -----------------------------------------------------------------------
      <?php
      $fp = fopen('email.txt','r+');
      if(!$fp)
      {
      echo "Create the file first.";
      }else{
      $present = FALSE;
      while (!feof($fp))
      {
      $email = fgets($fp);
      if ($_POST['email'] == trim($email)){
      $present = TRUE;
      }
      }
      if (!$present){
      fwrite($fp, $_POST['email']."\n");
      echo "Email :".$email.' added.';
      }
      fclose($fp);
      }
      ?>
      -----------------------------------------------------------------------

      The only assumption in this script is that it expects 'email' in a post request.Make sure it receives one or edit the script to your needs.

      The emails are stored in the 'email.txt' file you just created.
      Let me know if you have a problem.
  • oh my god dude it worked! thanks !!!
    • [1] reply

Next Topics on Trending Feed

  • 8

    Hey I have a website perfectballhandling.com and I want the user to be able to press the get updates button enter their email and it saves to mail.php on my server. can you tell me what i'm doing wrong?