SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Shiver me timbers!! anthony_irl's Avatar
    Join Date
    Aug 1999
    Location
    Dublin, Ireland
    Posts
    495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Mail problem...

    Hi guys,

    You're probably going to solve this problem in about a minute but since I'm new to PHP I'm having a spot of bother. I'm trying to make a dynamic page that gives a form that is then submitted and the details are mailed to me using the mail function in PHP. Something's going wrong though and it says I have a parse error on the last line. Please help if you can.

    Here's the code:

    <? if (!isset($submitok)): ?>
    <html>
    <head>
    <title>Email Us</title>
    </head>
    <body>
    <h3>Email us</h3>
    <p><font color=orangered size=+1><TT><B>*</B></TT></font> indicates a required field</p>
    <form method=post action="<?=$PHP_SELF?>">
    <table border=0 cellpadding=0 cellspacing=5>
    <tr>
    <td align=right><p>Your Email Address</p></td>
    <td><input name=email type=text maxlength=100 size=25><font color=orangered size=+1><TT><B>*</B></TT></font></td>
    </tr>
    <tr>
    <td align=right><p>Name</p></td>
    <td><input name=theirname type=text maxlength=100 size=25><font color=orangered size=+1><TT><B>*</B></TT></font></td>
    </tr>
    <tr>
    <td align=right><p>Subject</p></td>
    <td><select name="subject"><option name="Select one">Select one</option><option name="Link suggestion" value="Link suggestion">Link suggestion</option><option name="General comments" value="General comments">General Comments</option></select><font color=orangered size=+1><TT><B>*</B></TT></font></td>
    </tr>
    <tr valign=top>
    <td align=right><p>Message</p></td>
    <td><textarea wrap name=newnotes rows=5 cols=30></textarea></td>
    </tr>
    <tr>
    <td align=right colspan=2><hr noshade color=black><input type=reset value="Reset Form"> <input type=submit name=”submitok” value=" OK "></td>
    </tr>
    </table>
    </form>
    </body>
    </html>
    <? else:
    $message1 = "The visitors name is " . $theirname . " and the said " . $message;
    mail("anthony@irishstudentnet.com", $subject, $message1, $email);
    ?>
    <html>
    <head>
    <title>Email sent</title>
    </head>
    <body>
    <p><strong>Your email was sent!</strong></p>
    <p>Thanks for your mail <?=$theirname?>. We enjoy recieving feedback from our users and we also provide a forum and chat room where users can get to know each other. Check it out now if you like in the <a href="community.html">Community</a> section.</p>
    </body>
    </html>
    <?phpendif;?>

    I'm only testing this page, hence why it isn't formatted or any of that. Thanks in advance for any help you might be able to offer.
    Anthony - How's tings?

    24 hours in a day, 24 beers in a case. Coincidence? I think not.
    Contact me by: PM ¦ Email ¦ NEW! Carrier Pigeon

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I rewrote parts of your code and it works fine for me now.

    PHP Code:
    <? if (!$submitok) { ?> 
        <html> 
        <head> 
        <title>Email Us</title> 
        </head> 
        <body> 
        <h3>Email us</h3> 
        <p><font color=orangered size=+1><TT><B>*</B></TT></font> indicates a required field</p> 
        <form method=post action="<?=$PHP_SELF?>"> 
        <table border=0 cellpadding=0 cellspacing=5> 
        <tr> 
        <td align=right><p>Your Email Address</p></td> 
        <td><input name=email type=text maxlength=100 size=25><font color=orangered size=+1><TT><B>*</B></TT></font></td> 
        </tr> 
        <tr> 
        <td align=right><p>Name</p></td> 
        <td><input name=theirname type=text maxlength=100 size=25><font color=orangered size=+1><TT><B>*</B></TT></font></td> 
        </tr> 
        <tr> 
        <td align=right><p>Subject</p></td> 
        <td><select name="subject"><option name="Select one">Select one</option><option name="Link suggestion" value="Link suggestion">Link suggestion</option><option name="General comments" value="General comments">General Comments</option></select><font color=orangered size=+1><TT><B>*</B></TT></font></td> 
        </tr> 
        <tr valign=top> 
        <td align=right><p>Message</p></td> 
        <td><textarea wrap name=newnotes rows=5 cols=30></textarea></td> 
        </tr> 
        <tr> 
        <td align=right colspan=2><hr noshade color=black><input type=reset value="Reset Form"> <input type=submit name="submitok" value=" OK "></td> 
        </tr> 
        </table> 
        </form> 
        </body> 
        </html>
         
    <? } else { 
        
    $message1 "The visitors name is $theirname and the said $message"
        
    mail("louis@uniquefocus.com"$subject$message1$email); 
    ?> 
        <html> 
        <head> 
        <title>Email sent</title> 
        </head> 
        <body> 
        <p><strong>Your email was sent!</strong></p> 
        <p>Thanks for your mail <?=$theirname?>. We enjoy recieving feedback from our users and we also provide a forum and chat room where users can get to know each other. Check it out now if you like in the <a href="community.html">Community</a> section.</p> 
        </body> 
        </html> 
    <? ?>
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Addict manipura's Avatar
    Join Date
    Apr 2001
    Location
    Calgary,AB
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It took less then a minute....
    <?phpendif;?>
    change to:
    <?php endif;?>

  4. #4
    Shiver me timbers!! anthony_irl's Avatar
    Join Date
    Aug 1999
    Location
    Dublin, Ireland
    Posts
    495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys. I knew you'd be quick to find it. Thanks again.
    Anthony - How's tings?

    24 hours in a day, 24 beers in a case. Coincidence? I think not.
    Contact me by: PM ¦ Email ¦ NEW! Carrier Pigeon


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
  •