Announcement Announcement Module
Collapse
No announcement yet.
I need help with PHP!!! Page Title Module
Move Remove Collapse
Search Search Module
Collapse

Advertisement Advertisement Module
Collapse

Featured Images Featured Images Module
Collapse

Mediabistro Creative Sites Mediabistro Creative Sites Module
Collapse
Latest Topics Latest Topics Module
Collapse

  • KitchWitch
    Reply to Created Logo in PS, question about file
    KitchWitch
    Hi Chromez and welcome to GDF.

    We ask all new members to read very important links here and here. These explain the rules, how the forum runs and a few inside jokes. No, you haven't done...
    Today, 02:17 AM
  • Saint-Michel
    Reply to Legal size cardstock for business cards
    Saint-Michel
    Thank you for your answer PrintDriver. Seems like I was misinformed. I'll probably have to buy another printer that can print on thicker card stock then. Do you have any suggestions as to what printer...
    Yesterday, 11:30 PM
  • zablockit
    Reply to Please critique my new game design
    zablockit


    Ok, skeuomorphic looks awesome!

    What do you think now?

    What would you improve?...
    Yesterday, 09:11 PM
  • lowfatgraphics
    Reply to Font Management
    lowfatgraphics
    Thanks.

    I was testing the Font Suitcase and seems to be screwing with my Chrome bowsers...after some googling--looks like its a known issue. FEX it is then.

    Thanks Garricks....
    Yesterday, 08:29 PM
  • <b>
    Comment on RIP: The Necrology Thread
    <b>
    As just a listener of music, his work with Cream, along with Eric Clapton and Ginger Baker, have been among my most favorite pieces of music since I was just a kid. Somehow it always manages to surprise...
    Yesterday, 07:25 PM
Advertisement Advertisement Module
Collapse

Sponsors Sponsors Module
Collapse

X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • I need help with PHP!!!

    I'm doing an EASY online form that should not be that hard, but it's giving me a error:

    Parse error: syntax error, unexpected $end in D:\Hosting\4691023\html\newsletprocess.php on line 55

    I don't understand . . this shouldn't be that hard? Can anybody help me?? What am I doing wrong?

    <?php

    /* Subject and Email Variables */

    $emailSubject = 'Send me the e-newsletter!';
    $webMaster = 'christy@phoenixdesignandprint.com';

    /* Gathering Data Variables */

    $nameField = $_POST['name'];
    $companynameField = $_POST['companyname'];
    $emailField = $_POST['email'];

    $body = <<<EOD
    <br><hr><br>
    Name: $name <br>
    Company Name: $companyname <br>
    Email Address: $email <br>
    EOD;

    $headers = "From: $email\r\n";
    $headers .= "Content-type: text/html\r\n";
    $success = mail($webMaster, $emailSubject, $body, $headers);


    /* Results rendered as HTML */

    $theResults = <<<EOD
    <html>
    <title>Thank you for subscribing to our e-newsletter!</title>

    <style type="text/css">
    <!--
    body p {
    font-family: Verdana, Geneva, sans-serif;
    }
    body p {
    text-align: center;
    }
    body p {
    font-size: 12px;
    }
    -->
    </style>
    <body>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>Thank you for subscribing to our e-newsletter!</p>
    <p><a href="index.html">Click here to go back to home page</a></p>
    </body>
    </html>
    EOD;
    echo "$theResults";
    ?>

  • #2
    I have never seen this EOD thing before but apparently it's acceptable PHP.

    I don't think this line should work:
    $headers = "From: $email\r\n";
    I've seen
    $headers = "From: " . $email . "\r\n";
    and
    $headers = "From: {$email}\r\n";

    This line is definitely not going to work:
    echo "$theResults";
    it should be:
    echo $theResults;

    Your variables you're referencing are not defined, either. You say $name and $companyname, but the names you've given them are $nameField and $companynameField.

    The error unfortunately is very vague - usually it means something's not closed in the code. I would stay away from this EOD stuff and just use double quotes.

    Not to mention using php for the end bit is totally pointless, you can just shut php and write it out:
    Code:
    <?php
    
    /* Subject and Email Variables */
    
    $emailSubject = 'Send me the e-newsletter!';
    $webMaster = 'christy@phoenixdesignandprint.com';
    
    /* Gathering Data Variables */
    
    $name = $_POST['name'];
    $companyname = $_POST['companyname'];
    $email = $_POST['email'];
    
    $body = <<<EOD
    <br><hr><br>
    Name: $name <br>
    Company Name: $companyname <br>
    Email Address: $email <br>
    EOD;
    
    $headers = "From: {$email}\r\n";
    $headers .= "Content-type: text/html\r\n";
    mail($webMaster, $emailSubject, $body, $headers);
    ?>
    <html>
    <title>Thank you for subscribing to our e-newsletter!</title>
    
    <style type="text/css">
    <!--
    body p {
    font-family: Verdana, Geneva, sans-serif;
     text-align: center;
     font-size: 12px;
    }
    -->
    </style>
    <body>
     <p>Thank you for subscribing to our e-newsletter!</p>
    <p><a href="index.html">Click here to go back to home page</a></p>
    </body>
    </html>
    Can I see the HTML for the form? I think you may have just mixed up post variables.
    Last edited by vanishdesign; 08-22-2009, 04:44 AM.
    Swedish Meatball Pornography

    Comment


    • #3
      the <<<EOD bit is a here doc and looks to be formatted correctly...however, the ending EOD; part cannot have any whitespace preceding it or it will throw an error...it's tricky that way...do a hard return after that <br> tag and make sure it rests flush with the side of your code editor by the line numbers...

      and ensure your variable names are the same...
      Monarchs Rule!

      Comment


      • #4
        Each line of the body can be no longer then 70 characters.

        You should get the undefined variables sorted out first though.
        Last edited by tZ; 08-22-2009, 06:54 AM.

        Comment


        • #5
          Can I see the HTML for the form? I think you may have just mixed up post variables.

          http://highpointehs.com/newsletter.html

          Comment


          • #6
            I'll look it over, but one thing I immediately noticed is that size has been used rather then maxlength. The size attribute is visual and does not mean the number of characters. The allowed number of characters is determined by maxlength not size. Even then its only client-side and should always be checked on the server side as well which I don't believe your doing. Doing that will also raise an issue of providing the user information about what fields are invalid and how they can fixed accordingly which also has yet to be addressed.
            Last edited by tZ; 08-22-2009, 11:15 PM.

            Comment


            • #7
              Code:
              $name = $_POST['FieldData0'];
              $companyname = $_POST['FieldData1'];
              $email = $_POST['FieldData2'];

              Comment

              Mediabistro A division of Prometheus Global Media home | site map | advertising/sponsorships | careers | contact us | help courses | browse jobs | freelancers | content | member benefits | reprints & permissions terms of use | privacy policy Copyright © 2014 Mediabistro Inc. call (212) 389-2000 or email us
              Working...
              X