SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard bronze trophy
    Join Date
    Apr 2003
    Posts
    4,095
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP email script troubles

    Hello, all who are watching,

    I've got a PHP script that sends email, and although all of the code looks correct, I get a PHP parse error saying that there an extra $ on the end of the script. There isn't.

    Here's the script:

    PHP Code:
    <?php
    $success
    =$_REQUEST["success"];
    if(
    $success=="yes"):
    ?>
    <html>
    <head>
    <title>CyberCory.net: Contact: Thank You</title>
    <meta name="description" content="CyberCory's digital abode on the Internet is CyberCory.net. From a journal to games to a bio, this site is your spot for all things CyberCory." />
    <meta name="keywords" content="Kids, the Internet, games, bios, journals, writings, personal Web sites." />
    <link rel="stylesheet" media="screen" type="text/css" href="<A href="http://www.cybercory.net/css-bin/styling.css">http://www.cybercory.net/css-bin/styling.css" />
    </head>
    <body>
    <div id="page">
    <div id="header_image"><img src="<A href="http://www.cybercory.net/jpg-bin/header.jpg">http://www.cybercory.net/jpg-bin/header.jpg" /></div>
    <div id="header_text">Thank You</div>
    <div id="top_info"><a id="link" href="<A href='http://www.cybercory.net/index.php">CyberCory.nethttp://www.cybercory.net/index.php">CyberCory.net</a>: Thank You | <a id="link" href="#thank_you">Thank You</a></div>
    <div id="sidebar">
    <img src="<A href="http://www.cybercory.net/jpg-bin/sidebar.jpg">http://www.cybercory.net/jpg-bin/sidebar.jpg" />
    </div>
    <div id="navigation_bar">
    <?php include("[url=http://www.cybercory.net/php-bin/includes/sidebar.php]http://www.cybercory.net/php-bin/includes/sidebar.php[/url]");?>
    </div>
    <div id="content_frame">
    <div id="heading"><a name="thank_you">Thank You</a></diV>
    <div id="paragraph">
    Thank you, <?php 
    $first_name
    =$_REQUEST["first_name"];
    echo(
    "$first_name");?> (<?php
    $email_address
    =$_REQUEST["email_address"];
    echo(
    "$email_address");?>)! Your message to <?php
    $recipient
    =$_REQUEST["recipient"];
    echo(
    "$recipient");?> has been received by CyberCory.net's server and will be rerouted to its final destination momentarily. You should receive a response within 48 hours.
    </div>
    <br />
    <div id="paragraph">
    You may view a copy of the message below.
    </div>
    <br />
    <img id="line" src="<A href="http://www.cybercory.net/gif-bin/line.gif">http://www.cybercory.net/gif-bin/line.gif" />
    First name: <?php
    $first_name
    =$_REQUEST["first_name"];
    echo(
    "$first_name");
    ?>
    <br />
    <br />
    Email address: <?php
    $email_address
    =$_REQUEST["email_address"];
    echo(
    "$email_address");
    ?>
    <br />
    <br />
    Recipient: <?php
    $recipient
    =$_REQUEST["recipient"];
    echo(
    "$recipient");
    ?>
    <br />
    <br />
    Subject: <?php
    $subject
    =$_REQUEST["subject"];
    echo(
    "$subject");
    ?>
    <br />
    <br />
    Priority: <?php
    $priority
    =$_REQUEST["priority"];
    echo(
    "$priority");
    ?>
    <br />
    <br />
    Message:
    <br />
    <br />
    <?php
    $message
    =$_REQUEST["message"];
    echo(
    "$message");
    ?>
    <br />
    <?php include("[url=http://www.cybercory.net/php-bin/includes/footer.php]http://www.cybercory.net/php-bin/includes/footer.php[/url]");?>
    </div>
    </div>
    </body>
    </html>
    <?php 
    $success
    =$_REQUEST["success"];
    elseif(
    $success=="no"):?>
    <html>
    <head>
    <title>CyberCory.net: Contact: Oops</title>
    <meta name="description" content="CyberCory's digital abode on the Internet is CyberCory.net. From a journal to games to a bio, this site is your spot for all things CyberCory." />
    <meta name="keywords" content="Kids, the Internet, games, bios, journals, writings, personal Web sites." />
    <link rel="stylesheet" media="screen" type="text/css" href="<A href="http://www.cybercory.net/css-bin/styling.css">http://www.cybercory.net/css-bin/styling.css" />
    </head>
    <body>
    <div id="page">
    <div id="header_image"><img src="<A href="http://www.cybercory.net/jpg-bin/header.jpg">http://www.cybercory.net/jpg-bin/header.jpg" /></div>
    <div id="header_text">Oops</div>
    <div id="top_info"><a id="link" href="<A href='http://www.cybercory.net/index.php">CyberCory.nethttp://www.cybercory.net/index.php">CyberCory.net</a>: Oops | <a id="link" href="#oops">Oops</a></div>
    <div id="sidebar">
    <img src="<A href="http://www.cybercory.net/jpg-bin/sidebar.jpg">http://www.cybercory.net/jpg-bin/sidebar.jpg" />
    </div>
    <div id="navigation_bar">
    <?php include("[url=http://www.cybercory.net/php-bin/includes/sidebar.php]http://www.cybercory.net/php-bin/includes/sidebar.php[/url]");?>
    </div>
    <div id="content_frame">
    <div id="heading"><a name="oops">Oops</a></diV>
    <div id="paragraph">
    Oops! It appears that you forgot to fill in one or more of the required fields on the contact form. Remeber, required fields are marked with a star (<img src="<A href="http://www.cybercory.net/gif-bin/star.gif">http://www.cybercory.net/gif-bin/star.gif" />). Please check the following list of the one(s) you forgot.
    </div>
    <br />
    <img id="line" src="<A href="http://www.cybercory.net/gif-bin/line.gif">http://www.cybercory.net/gif-bin/line.gif" />
    <?php
    $email_address
    =$_REQUEST["email_address"];
    if(!
    $email_address):
    ?>
    Email address
    <br />
    <br />
    <?php endif;?>
    <?php
    $recipient
    =$_REQUEST["recipient"];
    if(!
    $recipient):
    ?>
    Recipient
    <br />
    <br />
    <?php endif;?>
    <?php
    $message
    =$_REQUEST["message"];
    if(!
    $message):
    ?>
    Message
    <?php endif;?>
    <img id="line" src="<A href="http://www.cybercory.net/gif-bin/line.gif">http://www.cybercory.net/gif-bin/line.gif" />
    <div id="paragraph">
    To rectify this error, you may either click the "Back" button on your browser toolbar to try again, or you may <a id="link" href="<A href='http://www.cybercory.net/php-bin/contact.php">go'>http://www.cybercory.net/php-bin/contact.php">go back to the contact form</a> and try again.
    </div>
    <br />
    <?php include("[url=http://www.cybercory.net/php-bin/includes/footer.php]http://www.cybercory.net/php-bin/includes/footer.php[/url]");?>
    </div>
    </div>
    </body>
    </html>
    <?php endif;?>
    <?php
    $process
    =$_REQUEST["process"];
    if(
    $process=="yes"):
    ?>
    <?php
    $first_name
    =$_REQUEST["first_name"];
    $email_address=$_REQUEST["email_address"];
    $recipient=$_REQUEST["recipient"];
    $subject=$_REQUEST["subject"];
    $priority=$_REQUEST["priority"];
    $message=$_REQUEST["message"];
    if(
    $email_address="" or $recipient="" or $message=""):
    ?>
    <?php header
    ("location: [url=http://www.cybercory.net/php-bin/contact.php?success=no&email_address=$email_address&recipient=$recipient&message=$message]http://www.cybercory.net/php-bin/contact.php?success=no&email_address=$email_address&recipient=$recipient&message=$message[/url]");?>
    <?php 
    else:?>
    <?php 
    if($recipient=="Coder"):?>
    <?php $recipient_email_address
    ="[email=coder@cybercory.net]coder@cybercory.net[/email]";?>
    <?php 
    elseif($recipient=="CyberCory"):?>
    <?php $recipient_email_address
    ="[email=cybercory@cybercory.net]cybercory@cybercory.net[/email]";?>
    <?php 
    endif;?>
    <?php
    mail
    ($recipient_email_address,$subject,$message,
    "From: $email_address\r\n"
    ."Reply-To: $email_address");
    header("location: [url=http://www.cybercory.net/php-bin/contact.php?success=yes&first_name=$first_name&email_address=$email_address&recipient=$recipient&subject=$subject&priority=$priority&message=$message]http://www.cybercory.net/php-bin/contact.php?success=yes&first_name=$first_name&email_address=$email_address&recipient=$recipient&subject=$subject&priority=$priority&message=$message[/url]");
    ?>
    <?php 
    if(!$process):?>
    <html>
    <head>
    <title>CyberCory.net: Contact</title>
    <meta name="description" content="CyberCory's digital abode on the Internet is CyberCory.net. From a journal to games to a bio, this site is your spot for all things CyberCory." />
    <meta name="keywords" content="Kids, the Internet, games, bios, journals, writings, personal Web sites." />
    <link rel="stylesheet" media="screen" type="text/css" href="<A href="http://www.cybercory.net/css-bin/styling.css">http://www.cybercory.net/css-bin/styling.css" />
    </head>
    <body>
    <div id="page">
    <div id="header_image"><img src="<A href="http://www.cybercory.net/jpg-bin/header.jpg">http://www.cybercory.net/jpg-bin/header.jpg" /></div>
    <div id="header_text">Contact</div>
    <div id="top_info"><a id="link" href="<A href='http://www.cybercory.net/index.php">CyberCory.nethttp://www.cybercory.net/index.php">CyberCory.net</a>: Contact | <a id="link" href="#introduction">Introduction</a> | <a id="link" href="#to_send_email">To Send Email</a></div>
    <div id="sidebar">
    <img src="<A href="http://www.cybercory.net/jpg-bin/sidebar.jpg">http://www.cybercory.net/jpg-bin/sidebar.jpg" />
    </div>
    <div id="navigation_bar">
    <?php include("[url=http://www.cybercory.net/php-bin/includes/sidebar.php]http://www.cybercory.net/php-bin/includes/sidebar.php[/url]");?>
    </div>
    <div id="content_frame">
    <div id="heading"><a name="introduction">Introduction</a></diV>
    <div id="paragraph">
    So, you want to send someone at CyberCory.net some email, eh? Well, here's news for you: no matter who you send it to, it will be received by the same person! (Even though there are two email addresses at CyberCory.net, both are the same person, because there's only one person at CyberCory.net!)
    </div>
    <br />
    <div id="paragraph">
    Despite this, there are two email addresses, depending on the type of email you want to send. For technical emails, select "Coder". For content issues, select "CyberCory.
    </div>
    <br />
    <div id="heading"><a name="to_send_email">To Send Email</a></div>
    <div id="paragraph">
    To send email, just fill out the form below, and then click the "Send" button. The required form fields are marked with a star(<img src="<A href="http://www.cybercory.net/gif-bin/star.gif">http://www.cybercory.net/gif-bin/star.gif" />). My neat little PHP email script will then process the email, send it if it's complete, or ask you to try again if it's not. Happy emailing!
    </div>
    <br />
    <img id="line" src="<A href="http://www.cybercory.net/gif-bin/line.gif">http://www.cybercory.net/gif-bin/line.gif" />
    <form action="[url=http://www.cybercory.net/php-bin/contact.php?process=yes]http://www.cybercory.net/php-bin/contact.php?process=yes[/url]" method="post">
    First name: <input type="text" name="first_name">
    <br />
    <br />
    Email address: <input type="text" name="email_address"><img src="<A href="http://www.cybercory.net/gif-bin/star.gif">http://www.cybercory.net/gif-bin/star.gif" />
    <br />
    <br />
    Recipient: <select name="recipient"><img src="<A href="http://www.cybercory.net/gif-bin/star.gif">http://www.cybercory.net/gif-bin/star.gif" />
    <?php
    $recipient
    =$_REQUEST["recipient"];
    if(
    $recipient=="Coder"):
    ?>
    <option></option>
    <option>CyberCory</option>
    <option selected>Coder</option>
    <?php
    $recipient
    =$_REQUEST["recipient"];
    if(
    $recipient=="CyberCory"):
    ?>
    <option></option>
    <option selected>CyberCory</option>
    <option>Coder</option>
    <?php else:?>
    <option></option>
    <option>CyberCory</option>
    <option>Coder</option>
    <?php endif;?>
    </select>
    <br />
    <br />
    Subject: <input type="text" name="subject">
    <br />
    <br />
    Priority: <select name="priority">
    <option>Highest</option>
    <option>High</option>
    <option selected>Normal</option>
    <option>Low</option>
    <option>Lowest</option>
    </select>
    <br />
    <br />
    Message: <textarea></textarea><img src="<A href="http://www.cybercory.net/gif-bin/star.gif">http://www.cybercory.net/gif-bin/star.gif" />
    <br />
    <br />
    <input type="submit" value="Send"><input type="reset">
    <br />
    <?php include("[url=http://www.cybercory.net/php-bin/includes/footer.php]http://www.cybercory.net/php-bin/includes/footer.php[/url]");?>
    </div>
    </div>
    </body>
    </html>
    <?php endif;?>
    <?php 
    endif;?>
    Thanks,
    compuwhiz7
    Last edited by weirdbeardmt; May 16, 2003 at 10:36.

  2. #2
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I edited your code to make it a bit more readable. It's still hard to tell because it is such a mishmash of things in there.

    The error you received is normally occurs when you jump in and out of PHP using if/else constructs. Like you do a lot. It is possible you have closed an if too early, or you have left one open.

    TBH, the whole page needs rewriting and tidying, starting with code formatting -- it is incredibly difficult to read.

    Sorry I couldn't be more help
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Apr 2003
    Posts
    4,095
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by weirdbeardmt
    I edited your code to make it a bit more readable. It's still hard to tell because it is such a mishmash of things in there.

    The error you received is normally occurs when you jump in and out of PHP using if/else constructs. Like you do a lot. It is possible you have closed an if too early, or you have left one open.

    TBH, the whole page needs rewriting and tidying, starting with code formatting -- it is incredibly difficult to read.

    Sorry I couldn't be more help [img]images/smilies/frown.gif[/img]
    Thanks, weirdbeardmt! I'll be sure to try that.

    I personally find the code easy to read, but that might be just because I wrote it...

  4. #4
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by compuwhiz7
    I personally find the code easy to read, but that might be just because I wrote it...
    Probably
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •