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

  • MichaelWied
    Comment on Company Logo Rebranding Critique
    MichaelWied
    Cant' see it for some reason.
    Today, 04:15 AM
  • Buda
    Reply to Please help with company logo
    Buda
    Is the company name still The Fitness Doctors? The latest logo doesn't show this.
    Today, 03:38 AM
  • Buda
    Reply to Happy Last Friday of July!!!!
    Buda
    Oh lala, if your summer is ending, that means my winter is ending.

    Amazing pirate mermaid wedding! I went to a pirate birthday party on a boat once but that doesn't even compare to a wedding....
    Today, 03:35 AM
  • salsa
    Reply to Freelance Advice - Family Conflict
    salsa
    If it were me, I'd just write off all the work done so far as pro bono. Like several others already mentioned, I do all family work for free and if they want to pay me then that's an extra bonus.
    ...
    Today, 03:23 AM
  • Kayekaye
    Reply to Freelance Advice - Family Conflict
    Kayekaye
    I had inlaws approach me for a logo and website. What a nightmare. They are a married professional couple and said "Of course we would pay you, $___ (an amount that barely covers 2 hours of work)...
    Today, 03:07 AM
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

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