0

I recently set up an AWS EC2 instance and installed Apache, PHP, and MySQL on the 64-bit Linux server using yum

Then I uploaded my php files for my contact form in /var/HTML/WWW

It displays fine except parts of my contact form are being displayed. They are PHP— the PHP tags and the code within them are being shown.

Here is a live example: 23.23.152.36

And here is a version on another server where its working fine.

Does anyone have any ideas why this is happening?

2
  • 1
    Please post the code, we generally don't like to visit external sites, especially bare IP addrs. Commented Nov 14, 2012 at 4:07
  • @MichaelBerkowski : Okay, I understand. Here is a paste that contains the body and PHP of my contact-form: pastedump.com/paste/2891 or pastebin.com/RqA2VevQ Commented Nov 14, 2012 at 16:07

4 Answers 4

3

Do you have PHP enabled on your webserver? For Apache, you may need to modify httpd.conf to enable PHP.

Can you run phpmyinfo() on your webserver?

Sign up to request clarification or add additional context in comments.

8 Comments

I didn't remember enabling it, but I guess it is because I ran phpinfo() and it works. You can see the results here: 23.23.152.36/info.php
Try changing <?php=$name;?> to <?php echo $name;?>
Actually you will want to change <?php=$name;?> to <?php echo htmlspecialchars($name, ENT_QUOTES)?> to account for special characters like apostrophe's that may be in the field value.
I made the change and it gets rid of the value as I wanted, but the form is never emailed to me. :-( Here is my code with the changes you suggested: pastebin.com/rqVTdJ9c
My apologies - forgot a semi-colon. Try <?php echo htmlspecialchars($name, ENT_QUOTES);?> and see if that helps
|
2

Enable short_open_tag in you php.ini

   short_open_tag
   Default Value: On
   Development Value: Off
   Production Value: Off

1 Comment

I don't want to enable short_open_tags. I want the input fields to be blank yet I need the form to submit properly and email me the results.
1

shorthand notation is on its way to deprication, i wouldnt suggest building code with shorthand notation anymore.

just use <?php echo ?>

1 Comment

yes, I know that. I don't want to use shorthand notation. I want the input-fields to be blank as in the link to the working-fine example in my question.
0

You want to change <?php=$name;?> to <?= $name ?>. That's what you need to do if you want to use the shorthand notation.

1 Comment

No, i want the input-fields to be blank and the form to still submit correctly and email me the result.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.