[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.8

PHP Form issue, subscribe into txt form

Asked by MasterMitch in PHP Scripting Language

Tags: form, php, rsvp

Ok so I was working on an RSVP form for a websote, trying to emulate easyletter.php that I downloaded as you can see below. The original basically subscribes and unsubscribes a user from an email newsletter. I want to keep that functionality for this RSVP form. I added "phone", "email" to the vars and to the form as well.
I think the problem is around the lines of

                                else {
            $disp="no";
            $newfile = fopen($filelocation,"a+");
            $add = "%".$name;
            $add = "%".$phone;
            $add = "%".$email;
            fwrite($newfile, $add);
            fclose($newfile);

Where it doesnt write the name, phone and email into the text file called subscribers.txt. I wanted it comma seperated so I could import the entire txt list into excel for easy viewing and printing. I am sure this is an easy fix, can someone help me with this issue please. The whole php is below, it is one inclusive file.


<title>944 Magazine RSVP List</title>
<?php
/*
      EasyLetter 1.2
      This script is part of Onlinetools
      http://www.onlinetools.org/tools/easyletter.php
*/
$vars=explode(",","pw,send,subject,message,name,phone,email,action");
foreach($vars as $v){
if ($HTTP_GET_VARS[$v]!=""){$$v=$HTTP_GET_VARS[$v];}
if ($HTTP_POST_VARS[$v]!=""){$$v=$HTTP_POST_VARS[$v];}
}
# Set the password for the eMail List editor!
$pass="studio944";

# Where is your newsletter located? (For deletion link)
$newsletterlocation="http://www.944.biz/rsvp";

# Name of the datafile
$filelocation="subscribers.txt";

# Title of the newsletter, will be displayed in the FROM field of the mailclient
$lettername="944 RSVP";

# Your email, will be the reply-to mail,
$youremail="mitch@944.biz";

# pattern for filtering out own emails
$pattern = "bar.com";

$welcomemessage = "<center>RSVP for the latest parties, events and gigs from 944 Magazine</center>";

# Sorrymessage for failed subscription, will be followed by the email!
$sorrysignmessage = "<div class=\"warning\">Sorry, but there is already an entry for $email</div>";

# Sorrymessage for blank email
$sorryblankmailmessage = "<div class=\"warning\">Sorry, but with a blank mail I get lost in cyberspace</div>";

# Sorrymessage for invalid emails
$sorryoddmailmessage = "<div class=\"warning\">Sorry, but \"$email\" that does not look like an email to me</div>";

# Sorrymessage if someone entered your own mail
$sorryownmailmessage = "<div class=\"warning\">Sorry, but I don't really want to get my own RSVP!</div>";

# Subscribemessage, will be shown when someone subscribes.
$subscribemessage = "<div class=\'thanks\'>Thank you for your RSVP, a confirmation email is on its way! You may close this window now.</div>";

# Subscribemail, will be sent when someone subscribes.
$subscribemail = "Thank you for the RSVP to the 944 Magazine event.";

# Unsubscribemessage for deletion, will be followed by the email!
$unsubscribemessage = "<div class=\"thanks\">We deleted the email. We are sorry to see you go. You can always rejoin at a later date. You may close this window now.</div>";

# Unsubscribemessage for failed deletion, will be followed by the email!
$failedunsubscriptionmessage = "<div class=\"warning\">Sorry, you cannot unsubscribe as we didn't find an entry for $email. You may close this window now.</div>";

if (!file_exists($filelocation)) {
      $newfile = fopen($filelocation,"w+");
      fclose($newfile);
      }
$newfile = fopen($filelocation,"r");
$content = fread($newfile, filesize($filelocation));
fclose($newfile);
$content=stripslashes($content);
$out="";
$lines = explode("%",$content);
foreach($lines as $l){
      if ($l != $email){$out .= "%".$l;}
      else{$found=1;}
}
if ($action=="sign"){                  
      if ($found==1 or $email=="" or !checkmail($email) or preg_match("/".$pattern."/",$email)){
            if ($email==""){echo $sorryblankmailmessage;}
            else if ($found==1){echo $sorrysignmessage;}
            else if (!checkmail($email)){echo $sorryoddmailmessage;}
            else if (preg_match("/".$pattern."/",$email)){echo $sorryownmailmessage;}
            $disp="yes";
      }
      else {
            $disp="no";
            $newfile = fopen($filelocation,"a+");
            $add = "%".$name;
            $add = "%".$phone;
            $add = "%".$email;
            fwrite($newfile, $add);
            fclose($newfile);
            echo $subscribemessage;
            mail ($youremail,"New RSVP subscriber.",$email."\nDelete? $newsletterlocation?action=delete&email=".$email,"From: RSVP\nReply-To: $email\n");
            $submailheaders = "From: $lettername subscription form\n";
            $submailheaders .= "Reply-To: $youremail\n";
            mail ($email,$lettername." subscription",$subscribemail,$submailheaders);
      }
}
if ($action=="delete"){            
      $disp="no";
      if ($found == 1){
            $newfile = fopen($filelocation,"w+");
            fwrite($newfile, $out);
            fclose($newfile);
            echo $unsubscribemessage;
            $disp="no";
      }
      if ($found != 1){
            echo $failedunsubscriptionmessage;
            $disp="YES";
      }
}
if ($pw      == $pass){
      if ($send != "yes" && $send != "test"){
            print'<form method="post"><input type="hidden" name=pw value='.$pass.' /><input type="hidden" name="send" value="yes">
            <br /><b>RSVP editor:</b><br /><br />
            Subject:<br />
            <input type="text" class="input" name="subject" size="20"><br />
            Message:<br />
            <textarea cols="50" rows="10" class="input" wrap="virtual" name="message"></textarea>&#160;
            <input type="submit" value="send" />
            </form>';
      }
      $mailheaders = "From: $lettername\n";
      $mailheaders .= "Reply-To:$youremail\n";

# If you want to send HTML mail, uncomment this line!
$mailheaders .= "Content-Type: text/html; charset=iso-8859-1\n";
      if ($send == "yes"){
            $message="".stripslashes($message);
            $subject=stripslashes($subject);
            $lines = explode("%",$content);
            foreach ($lines as $l){mail ($l,$subject,$message,$mailheaders);}
            print "<b>The following email has been sent!</b>";
            print "<pre>$mailheaders\n$subject\n$message</pre>";
      }
}
if ($pw != $pass && $disp != "no"){
      
      print $welcomemessage;
      print'
      <center><form method="post">
      Your name:&#160;<input type="text" name="name" class="inputsmall" value="" size="20" />&#160;<br>
      Your phone #:&#160;<input type="text" name="phone" class="inputsmall" value="" size="20" />&#160;<br>
      Your email:&#160;<input type="text" name="email" class="inputsmall" value="" size="20" />&#160;<br>
      <input type="radio" name="action" value="sign" checked="checked" />subscribe
      <input type="radio" name="action" value="delete" />unsubscribe&#160;
      <p><input type="submit" value=" Send! " class="button" /> </center>
      </form>
      ';


}
print "<!-- RSVP by Mitch Palmer -->";

function checkmail($string){
      return preg_match("/^[^\s()<>@,;:\"\/\[\]?=]+@\w[\w-]*(\.\w[\w-]*)*\.[a-z]{2,}$/i",$string);
}
?>

<body bgcolor="#CCCCCC" text="#000000">
[+][-]07/01/03 01:05 PM, ID: 8835681Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: PHP Scripting Language
Tags: form, php, rsvp
Sign Up Now!
Solution Provided By: shmert
Participating Experts: 1
Solution Grade: B
 
 
Loading Advertisement...
20091021-EE-VQP-81