Recommend page to friend does not go to confirmation page

Hello

I'm not a php programmer. I barely manage to reconfigure php with mucho help from Experts-Exchange.

Here is the page in question:

http://www.sloanusa.com/recommend.php

When I modified the generic version of the above script (it's a one page php script, no other files, no config file etc.) I was able to give the page a "look" that matched the rest of the site.

But in doing so I must have deleted code that properly sends the web  visitor to a confirmation page.

If you fill out the form you indeed go to the page where on the bottom there is the confirmation but it's hidden below the repeat of the previous page.

Can you modify the code for me so that it goes to a generic thank you page, and then I'll add the HTML to decorate the thank you page to look like the rest of the site.   One additional request, please include the basic html structure in the thank you/confirmation page, so I have a HTML playground to work in.  I.e. <html><head></head><body></body></html>

Thanks for any help!

Rowby
LVL 9
Rowby GorenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rowby GorenAuthor Commented:
P.S. Here is the untouched code (or almost untouched code)  downloaded from the orignal site.

<?  
/************* PHPRecommend v 1.3 ***************/
/************************************************/
/*  written by A. Gianotto - 3/28/2000          */
/*  To find out if this is the latest version   */
/*  of this script, email snipe@snipe.net, or   */
/*  visit http://www.snipe.net                  */
/************************************************/
/************************************************/
/*  PHPRecommend may be used freely for private */
/*  or commercial use.  All I ask is that you   */
/*  don't include it in any collections without */
/*  my permission.                              */
/************************************************/
/************************************************/
/*  DESCRIPTION:                                */
/* PHP "Recommend this page to a friend" script */
/*                                              */
/************************************************/
/************************************************/
/* NEW IN VERSION 1.3 - Multiple Email Address Support*/
/* ADDED 6/12/01                                */
/*  
/************************************************/
/************************************************/
/* URL LOGGING:
/* If you wish to use this feature, the only    */
/* additional step you must take is to upload   */
/* a blank text file into the same directory as */
/* this script lives.  For our purposes, we     */
/* have named it "url-log.txt".  You may name   */
/* it whatever you like, but if you change the  */
/* name, be sure to change it in the variable   */
/* below, where it's marked                     */
/*                                              */
/* Also BE SURE TO CHMOD THE TEXT FILE TO 666   */
/* so that the sever can open the file and      */
/* write to it.                                 */
/* ENJOY!                                       */
/************************************************/
/************************************************/
/*  INSTALLATION:                               */
/*  There is no readme or install file with     */
/*  script, because it's so easy to install,    */
/*  you just have to follow the comments in the */
/*  first part of the code                      */
/************************************************/
/************************************************/

// Change the variable below to "no" if you do not wish to write
// the data to a text log
$logging="no";

// Enter the website administrators email address here
$adminaddress = "rowby@rowby.com";

// Enter the company name or site name here
$sitename = "Sloan Management - Jeffrey Sloan";

// Enter the address of your website here
$siteaddress ="http://www.sloanusa.com";


// Unless you are changing the verbage of the printed message,
// there are no further configurations that need to be done  
// past this point, except editing the path to your footer includes

// If you do not use header and footer files, you can just replace
// the include calls with your HTML, but be sure to close the PHP tags
// before and after the HTML, so you don't get parse errors.

?>
<html>
<head>
<title>Sloan Management - Jeffrey Sloan</title>



<?php
IF ($action=="") {
?>

<?
$referer = getenv("HTTP_REFERER");  

?>
<p>To send a link to Jeffery Sloan's Management page and a brief message fill out the  
form below.  All fields except the comments are required.
</p>
<FORM METHOD=POST ACTION="<? echo "$PHP_SELF"; ?>">
  <TABLE BORDER="0" CELLSPACING="3" CELLPADDING="3">
<TR>
    <TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif" SIZE="-
1">Your Name:</FONT></TD>
    <TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif"  
SIZE="3"><INPUT TYPE="text" NAME="yname"></FONT></TD>
</TR>
<TR>
    <TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif" SIZE="-
1">Your Email:</FONT></TD>
    <TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif"  
SIZE="3"><INPUT TYPE="text" NAME="yemail"></FONT></TD>
</TR>
<TR>
    <TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif" SIZE="-
1">Friend  Name:</FONT></TD>
    <TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif"  
SIZE="3"><INPUT TYPE="text" NAME="fname[1]"></FONT></TD>
</TR>
<TR>
    <TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif" SIZE="-
1">Friend  Email:</FONT></TD>
    <TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif"  
SIZE="3"><INPUT TYPE="text" NAME="femail[1]"></FONT></TD>
</TR>

<TR>
    <TD VALIGN="TOP" COLSPAN="2"><FONT FACE="Arial, Helvetica, Verdana, Sans  
Serif" SIZE="-1">Additional Comments:</FONT></TD>
</TR>
<TR>
    <TD VALIGN="TOP" COLSPAN="2"><FONT FACE="Arial, Helvetica, Verdana, Sans  
Serif" SIZE="3"><textarea NAME="comments" rows="3"></TEXTAREA></FONT></TD>
</TR>
<TR>
    <TD VALIGN="TOP" COLSPAN="2"><FONT FACE="Arial, Helvetica, Verdana, Sans  
Serif" SIZE="3"><INPUT TYPE="hidden" NAME="url" VALUE="<? echo "$referer"; ?>"><INPUT  
TYPE="submit" NAME="action" VALUE="Send"></FONT></TD>
</TR>
</TABLE>

</FORM>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>


<?

} ELSEIF ($action="Send") {

    if (($yname=="") || ($fname=="")  || ($femail=="")|| ($yemail==""))  {
print "Please use your back button and complete all of the required form fields, then resubmit.<br><br><br><br><br><br><br><br><br><br><br>";
} else {
        print "Your recmmendation to the following people has been sent:<br><br> ";
            // cycle through the emal addresses and names
        $items="5";
        $tally="";
        for ($numitems=0; $numitems < $items; $numitems++) {
              if (($fname[$numitems]!="") && ($femail[$numitems]!=""))  {
                mail("$femail[$numitems]","$yname went to $sitename and recommended you check this out","$fname[$numitems] \n\n $yname stopped by $sitename and thought you would find the following URL of interest:\n \nURL: $url \n\n Additional Comments: \n------------------------------------ \n$comments \n------------------------------------\n\nThank you! \n$sitename \n$adminaddress \n$siteaddress","FROM:$yemail");


            // NEW IN VERSION 1.2 - LOGGING TO A TEXT FILE - 7/31/00
            // this writes the url, comments, and email address
            // to a text database so you can easily track which
            // pages are being recommended most often

            // Be sure to upload the blank text file that the
            // data will write to.  In this case, we named it url-log.txt
            // If you name your blank file url-log.txt, no changes are needed here.
            // If you decide to use a different filename, you must change the
            // variable below.
               
                IF ($logging=="yes") {
                $filename="url-log.txt";

                // Nothing needs ot be changed here

                $fl=fopen($filename,"a+");
                // sets the pipe delimiters
                fwrite($fl,"'$url'|'$femail[$numitems]'|'$yemail'|'$comments'\n");
                fclose($fl);
                }
              $tally.="$fname[$numitems], ";
              }
         }

?>
<P>Your recommendation has been sent to <?php echo "$tally"; ?> </p>

    <p><B><A HREF="<? echo "$url"; ?>">GO BACK</A></B> </p>
    <BR>
    <BR>
<?
}

}




// end of script

// *********************************************
// Making it work on your page:
// Just put a link to phprecommend.php (or whatever you name
// the above file), and the script  
// does the rest!

?>


0
matt_mcswainCommented:
First thing I see:
Change:

} ELSEIF ($action="Send") {

TO:

} ELSEIF ($action=="Send") {
0
Rowby GorenAuthor Commented:
Hi I made that change.  Thanks

The page still remains the same except for what should be the confirmation page on the bottom of the page.

Again, an alternative is, upon submit, to go to a different confirmaiton page (instead of staying on the recommend.php) page -- if that's the easier solution.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

matt_mcswainCommented:
Sorry, for the delay. This scripts a mess. I changed loads, so let me know if you have any problems.
I moved the form mailer above, and if the forms filled out it tries to send the mails and redirects to confirmation.php
If not, it stays at the current page and displays an error message.

<?php
/************* PHPRecommend v 1.3 ***************/
/************************************************/
/*  written by A. Gianotto - 3/28/2000          */
/*  To find out if this is the latest version   */
/*  of this script, email snipe@snipe.net, or   */
/*  visit http://www.snipe.net                  */
/************************************************/
/************************************************/
/*  PHPRecommend may be used freely for private */
/*  or commercial use.  All I ask is that you   */
/*  don't include it in any collections without */
/*  my permission.                              */
/************************************************/
/************************************************/
/*  DESCRIPTION:                                */
/* PHP "Recommend this page to a friend" script */
/*                                              */
/************************************************/
/************************************************/
/* NEW IN VERSION 1.3 - Multiple Email Address Support*/
/* ADDED 6/12/01                                */
/*  
/************************************************/
/************************************************/
/* URL LOGGING:
/* If you wish to use this feature, the only    */
/* additional step you must take is to upload   */
/* a blank text file into the same directory as */
/* this script lives.  For our purposes, we     */
/* have named it "url-log.txt".  You may name   */
/* it whatever you like, but if you change the  */
/* name, be sure to change it in the variable   */
/* below, where it's marked                     */
/*                                              */
/* Also BE SURE TO CHMOD THE TEXT FILE TO 666   */
/* so that the sever can open the file and      */
/* write to it.                                 */
/* ENJOY!                                       */
/************************************************/
/************************************************/
/*  INSTALLATION:                               */
/*  There is no readme or install file with     */
/*  script, because it's so easy to install,    */
/*  you just have to follow the comments in the */
/*  first part of the code                      */
/************************************************/
/************************************************/

// Change the variable below to "no" if you do not wish to write
// the data to a text log
$logging="no";

// Enter the website administrators email address here
$adminaddress = "rowby@rowby.com";

// Enter the company name or site name here
$sitename = "Sloan Management - Jeffrey Sloan";

// Enter the address of your website here
$siteaddress ="http://www.sloanusa.com";


// Unless you are changing the verbage of the printed message,
// there are no further configurations that need to be done  
// past this point, except editing the path to your footer includes

// If you do not use header and footer files, you can just replace
// the include calls with your HTML, but be sure to close the PHP tags
// before and after the HTML, so you don't get parse errors.
if (isset($_POST['action'])) {

    if (empty($_POST['yname']) || empty($_POST['fname'][1])  || empty($_POST['femail'][1]) || empty($_POST['yemail']) )  {
 $errMsg = "Please complete all of the required form fields, then resubmit.<br><br><br><br><br><br><br><br><br><br><br>";
} else {
     
       
            // cycle through the emal addresses and names
        $items="5";
        $tally="";
        for ($numitems=0; $numitems < $items; $numitems++) {
              if (isset($_POST['fname'][$numitems]) && isset($_POST['femail'][$numitems]))  {
                $subject = $_POST['yname']." went to $sitename and recommended you check this out";
                        $message = $_POST['fname'][$numitems]." \n\n {$_POST['yname']} stopped by $sitename and thought you would find the following URL of interest:\n \nURL: $url \n\n Additional Comments: \n------------------------------------ \n$comments \n------------------------------------\n\nThank you! \n$sitename \n$adminaddress \n$siteaddress";
                        @mail($_POST['femail'][$numitems],$subject,$message,"FROM:{$_POST['yemail']}");


            // NEW IN VERSION 1.2 - LOGGING TO A TEXT FILE - 7/31/00
            // this writes the url, comments, and email address
            // to a text database so you can easily track which
            // pages are being recommended most often

            // Be sure to upload the blank text file that the
            // data will write to.  In this case, we named it url-log.txt
            // If you name your blank file url-log.txt, no changes are needed here.
            // If you decide to use a different filename, you must change the
            // variable below.
               
                IF ($logging=="yes") {
                $filename="url-log.txt";

                // Nothing needs ot be changed here

                $fl=fopen($filename,"a+");
                // sets the pipe delimiters
                fwrite($fl,"'$url'|'".$_POST['femail'][$numitems]."'|'".$_POST['yemail']."'|'$comments'\n");
                fclose($fl);
                }
              $tally.=$_POST['fname'][$numitems].", ";
              }
         }
             header('Location: confirmation.php');
             exit;
               
  }

}

?>
<html>
<head>
<title>Sloan Management - Jeffrey Sloan</title>

</head>
<body>
<?
$referer = getenv("HTTP_REFERER");  
echo isset($errMsg) ? $errMsg : '';
?>
<p>To send a link to Jeffery Sloan's Management page and a brief message fill out the  
form below.  All fields except the comments are required.
</p>
<FORM METHOD=POST ACTION="<? echo $_SERVER['PHP_SELF']; ?>">
  <TABLE BORDER="0" CELLSPACING="3" CELLPADDING="3">
<TR>
    <TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif" SIZE="-
1">Your Name:</FONT></TD>
    <TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif"  
SIZE="3"><INPUT TYPE="text" NAME="yname"></FONT></TD>
</TR>
<TR>
    <TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif" SIZE="-
1">Your Email:</FONT></TD>
    <TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif"  
SIZE="3"><INPUT TYPE="text" NAME="yemail"></FONT></TD>
</TR>
<TR>
    <TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif" SIZE="-
1">Friend  Name:</FONT></TD>
    <TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif"  
SIZE="3"><INPUT TYPE="text" NAME="fname[1]"></FONT></TD>
</TR>
<TR>
    <TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif" SIZE="-
1">Friend  Email:</FONT></TD>
    <TD VALIGN="TOP"><FONT FACE="Arial, Helvetica, Verdana, Sans Serif"  
SIZE="3"><INPUT TYPE="text" NAME="femail[1]"></FONT></TD>
</TR>

<TR>
    <TD VALIGN="TOP" COLSPAN="2"><FONT FACE="Arial, Helvetica, Verdana, Sans  
Serif" SIZE="-1">Additional Comments:</FONT></TD>
</TR>
<TR>
    <TD VALIGN="TOP" COLSPAN="2"><FONT FACE="Arial, Helvetica, Verdana, Sans  
Serif" SIZE="3"><textarea NAME="comments" rows="3"></TEXTAREA></FONT></TD>
</TR>
<TR>
    <TD VALIGN="TOP" COLSPAN="2"><FONT FACE="Arial, Helvetica, Verdana, Sans  
Serif" SIZE="3"><INPUT TYPE="hidden" NAME="url" VALUE="<? echo "$referer"; ?>"><INPUT  
TYPE="submit" NAME="action" VALUE="Send"></FONT></TD>
</TR>
</TABLE>

</FORM>
    <BR>
    <BR>
    <BR>
    <BR>
    <BR>
</body>
</html>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rowby GorenAuthor Commented:
HI  

I put up the page, and added the thankyou page url, and the email does get sent, but the page goes not redirtect to the confirmatin/thank you page.  Below is where I added the URL:

  <TD VALIGN="TOP" COLSPAN="2"><FONT FACE="Arial, Helvetica, Verdana, Sans  
Serif" SIZE="3"><INPUT TYPE="hidden" NAME="thankyou.htm" VALUE="<? echo "$referer"; ?>"><INPUT  
TYPE="submit" NAME="action" VALUE="Send"></FONT></TD>
</TR>

Below is the link to the page:
http://sloanusa.com/recommend.php
0
matt_mcswainCommented:
So, you want to send it to thankyou.htm?
Just change this line.

header('Location: confirmation.php');

to

header('Location: thankyou.htm');
0
Rowby GorenAuthor Commented:
Perfecto Matt!

I appreciate your Expert Help!

Rowby
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Fonts Typography

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.