Page 1 of 1

Tell Friend PHP Scripts

Posted: Tue May 06, 2003 9:42 pm
by jackoo
Hi folks,
I have been looking for a tell friend php scripts for a while ... i did find something but they were somehow not working ... I am not looking for a fancy one with control panel and all this cool stuff .. all i am looking for is a basic php file that can do the task and I can add a link to in my homepage...
I got this one http://www.phpscriptcenter.com/tellfriend.php but when I installed it I got the following error
Warning: Cannot modify header information - headers already sent by (output started at /home/admin/public_html/tellfriend.php:11) in /home/sadmin/public_html/tellfriend.php on line 131


I checked the file and I could not find anything wrong with it...
please help me out.
Thanks

Jackoo
[/url]

Posted: Tue May 06, 2003 9:50 pm
by r337ard
make sure the header information its trying to send is at the very top of the page, if other commands are executed it cant send the header info

as described here:
viewtopic.php?t=1157
Warning: Cannot add header information - headers already sent by (output started at file.php:23)

Have you ever gotten that warning message in PHP? Wonder what it's all about? Well, we can cover this very easily.

You are trying to send header information AFTER you have sent output to the browser.

Posted: Tue May 06, 2003 10:07 pm
by jackoo
Thanks r337ard! I went over the info but i could not understand a word. I moved the php script to the top of the page but still the same error ..
Here is the script:

Code: Select all

<?php

///////////////////////////////////////////////
//                                           //
// Tell Friend v 1.1                         //
// ----------------------------------------- //
// by Graeme (webmaster@phpscriptcenter.com) //
// http://www.phpscriptcenter.com            //
//                                           //////////////////////////////
// PHP Script CENTER offers no warranties on this script.                //
// The owner/licensee of the script is solely responsible for any        //
// problems caused by installation of the script or use of the script    //
//                                                                       //
// All copyright notices regarding Tell Friend, must remain              //
// intact on the scripts and in the HTML for the scripts.                //
//                                                                       //
// (c) Copyright 2001 PHP Script CENTER                                  //
//                                                                       //
// For more info on Tell Friend,                                         //
// see http://www.phpscriptcenter.com/tellfriend.php                     //
//                                                                       //
///////////////////////////////////////////////////////////////////////////


// number of friend feilds to put on the page
$tellnumber = "3";

// subject of email
$subject = "I just found a cool site";

// Message sent in the email
$message = "Checkout this cool site i found http://www.phpscriptcenter.com";

// url to redirect user to once they click submit
$thankyouurl = "http://www.phpscriptcenter.com";




//////////////////////////////////////////////////////////////////////////////////
//                         DO NOT EDIT BELOW THIS LINE                          //
//////////////////////////////////////////////////////////////////////////////////


if($submitform) &#123;

$num=0;
while($num < $tellnumber) &#123;
$num++;
$temail = "femail"."$num";
$tname = "fname"."$num";

if($$tname OR $$temail) &#123;
if(!$$tname) &#123;
$error .= "Missing Friends Name,  Friend $num<BR>";
&#125;
if(!$$temail) &#123;
$error .= "Missing Friends Email,  Friend $num<BR>";
&#125;

&#125;
if($$temail) &#123;
if(!ereg("@",$$temail)) &#123; $error .= "Invalid Email Address, Friend $num<BR>"; &#125;
if(!ereg("\.",$$temail)) &#123; $error .= "Invalid Email Address, Friend $num<BR>"; &#125;
&#125;
&#125;
if(!$tname) &#123;
$error .= "Missing your name<BR>";
&#125;
if(!ereg("@",$email)) &#123; $error .= "Invalid Email Address<BR>"; &#125;
if(!ereg("\.",$email)) &#123; $error .= "Invalid Email Address<BR>"; &#125;

if($error) &#123;
?>
<P><CENTER><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
  <TR>
    <TD WIDTH="100%" BGCOLOR="#004080">
    <TABLE WIDTH="394" BORDER="0" CELLSPACING="1" CELLPADDING="2">
      <TR>
        <TD WIDTH="26%" BGCOLOR="#004080">
        <B><FONT COLOR="#ffffff" SIZE="-1" FACE="Verdana">Error</FONT></B></TD>
      </TR>
      <TR>
        <TD WIDTH="26%" BGCOLOR="#ffffff">
        <FONT COLOR="#000000" SIZE="-1" FACE="Verdana"><?php echo $error; ?></FONT></TD> 
      </TR>
    </TABLE></TD>
  </TR>
</TABLE></CENTER>
<P><CENTER>&nbsp;</CENTER></P>
<P><CENTER><FONT SIZE="-2" FACE="Verdana"><B>Powered by:</B> <A HREF="http://www.phpscriptcenter.com/tellfriend.php">Tell Friend</A> Version 1.1</FONT></CENTER></P>
</BODY></HTML>
<?php
exit();
&#125;


$num=0;
while($num < $tellnumber) &#123;
$num++;
$temail = "femail"."$num";
$tname = "fname"."$num";
$then = $$tname;
if($$temail AND $$tname) &#123;
mail($$temail,"$subject","
Hi, $then

$message

From
$name

---------------------
Powerd by Tell Friend v1.1 (http://www.phpscriptcenter.com/tellfriend.php)

","From: $name <$email>");
&#125;

&#125;

header("Location: $thankyouurl");
exit();

&#125; else &#123;

$num=0;
while($num < $tellnumber) &#123;
$num++;
$theboxes .= " <TR>
        <TD WIDTH="49%" BGCOLOR="#ffffff">
        <P><CENTER><B><FONT COLOR="#000000" SIZE="-1" FACE="Verdana">$num</FONT></B></CENTER></TD>
        <TD WIDTH="26%" BGCOLOR="#ffffff">
        <P><CENTER><INPUT NAME="fname$num" TYPE="text" SIZE="25"></CENTER></TD>
        <TD WIDTH="25%" BGCOLOR="#ffffff">
        <INPUT NAME="femail$num" TYPE="text" SIZE="25">
</TD> 
      </TR>";
&#125;


?>
<P><CENTER><FONT FACE="Verdana"><B>Tell your friend about our site</B></FONT></CENTER></P>
<FORM ACTION="tellfriend.php" METHOD="POST"><P><CENTER><TABLE BORDER="0" CELLSPACING="0" 
CELLPADDING="0">
  <TR>
    <TD WIDTH="100%" BGCOLOR="#004080">
    <TABLE WIDTH="394" BORDER="0" CELLSPACING="1" CELLPADDING="2">
      <TR>
        <TD WIDTH="26%" BGCOLOR="#004080">
        <P><CENTER><B><FONT COLOR="#ffffff" SIZE="-1" FACE="Verdana">Your Name</FONT></B></CENTER></TD>
        <TD WIDTH="25%">
        <P><CENTER><B><FONT COLOR="#ffffff" SIZE="-1" FACE="Verdana">Your Email</FONT></B></CENTER></TD>
      </TR>
      <TR>
        <TD WIDTH="26%" BGCOLOR="#ffffff">
        <P><CENTER><INPUT NAME="name" TYPE="text" SIZE="25"></CENTER></TD>
        <TD WIDTH="25%" BGCOLOR="#ffffff">
        <INPUT NAME="email" TYPE="text" SIZE="25">
</TD>
      </TR>
    </TABLE></TD>
  </TR>
</TABLE></CENTER></P><P><CENTER><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
  <TR>
    <TD WIDTH="100%" BGCOLOR="#004080">
    <TABLE WIDTH="394" BORDER="0" CELLSPACING="1" CELLPADDING="2">
      <TR>
        <TD WIDTH="49%" BGCOLOR="#004080"></TD>
        <TD WIDTH="26%" BGCOLOR="#004080">
        <P><CENTER><B><FONT COLOR="#ffffff" SIZE="-1" FACE="Verdana">Friends name</FONT></B></CENTER></TD>
        <TD WIDTH="25%">
        <P><CENTER><B><FONT COLOR="#ffffff" SIZE="-1" FACE="Verdana">Friends email</FONT></B></CENTER></TD> 
      </TR><?php echo $theboxes; ?></TABLE></TD>
  </TR>
</TABLE></CENTER></P>
<P><CENTER><INPUT NAME="submitform" TYPE="submit" VALUE="Submit"></CENTER></FORM>
<P><CENTER>&nbsp;</CENTER></P>
<P><CENTER><FONT SIZE="-2" FACE="Verdana"><B>Powered by:</B> <A HREF="http://www.phpscriptcenter.com/tellfriend.php">Tell Friend</A> Version 1.1</FONT></CENTER></P>
</BODY></HTML>
<?php
exit();

&#125;

?>

Posted: Tue May 06, 2003 10:32 pm
by r337ard
about halfway down the page you posted is the header(), but im honestly not sure how to fix the code because

Code: Select all

$num=0;
while($num < $tellnumber) &#123;
$num++;
$temail = "femail"."$num";
$tname = "fname"."$num";
$then = $$tname;
if($$temail AND $$tname) &#123;
mail($$temail,"$subject","
Hi, $then

$message

From
$name

---------------------
Powerd by Tell Friend v1.1 (http://www.phpscriptcenter.com/tellfriend.php)

","From: $name <$email>");
&#125;

&#125;

header("Location: $thankyouurl");
exit();

&#125; else &#123;

$num=0;
while($num < $tellnumber) &#123;
$num++;
$theboxes .= " <TR>
        <TD WIDTH="49%" BGCOLOR="#ffffff">
        <P><CENTER><B><FONT COLOR="#000000" SIZE="-1" FACE="Verdana">$num</FONT></B></CENTER></TD>
        <TD WIDTH="26%" BGCOLOR="#ffffff">
        <P><CENTER><INPUT NAME="fname$num" TYPE="text" SIZE="25"></CENTER></TD>
        <TD WIDTH="25%" BGCOLOR="#ffffff">
        <INPUT NAME="femail$num" TYPE="text" SIZE="25">
</TD>
      </TR>";
&#125;