Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8023945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:42:53+00:00 2026-06-04T22:42:53+00:00

So, in an html page I’m trying to have a php segment echo some

  • 0

So, in an html page I’m trying to have a php segment echo some javascript code, as seen here:

<?php
    echo "This was legitimately hit";
    if(!empty($_POST['name']))
    {
        echo '<script type="text/javascript">alert("We got the name");</script>';
    }
    else
    {
        echo '<script type="text/javascript">alert("We DID NOT get the name");</script>';
    }
?>

and from what I’ve read online, this seems to be a legitimate way of doing things, but the page seems to be reading the first part up until the first closing chevron (seen just below here) as a comment.

<?php
    echo "This was legitimately hit";
    if(!empty($_POST['name']))
    {
        echo '<script type="text/javascript">

Then it reads the else and next echo as plain text, and puts it on the webpage. the next javascript code block then gets read as a regular javascript code block, so the page does a pop-up saying it did not get the name. The closing bracket and closing chevron then just get output as more text.

So in the end the page just ends up having

alert("We got the name")'; } else { echo ''; } ?>

printed on it as plain text, and has a pop-up that says we received no name.

What is going wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T22:42:55+00:00Added an answer on June 4, 2026 at 10:42 pm

    Sounds like the file isn’t being processed as PHP. Does the file name end in .php? Are you sure PHP is installed and hooked up correctly to the web server?

    edit: To handle the Facebook requests in the same page:

    <?php
    
    if (isset($_POST['facebook_request_field'])) {
      // handle the Facebook request, output any necessary response
      // then exit
      exit;
    }
    
    ?>
    <!-- display the web page normally here -->
    

    So for your test page:

    <?php
    
    if (isset($_POST['name'])) {
      echo '<script type="text/javascript">alert("got a name!");</script>';
      exit;
    }
    
    ?>
    <script type="text/javascript">alert("No name.");</script>
    

    (That’s actually identical in function to what you already have, so maybe I’m misunderstanding the purpose.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have create a HTML page with some JavaScript code. Here is the code
In my html page i have code something like this, where i have installed
My html page loads beautifully, but I have some JavaScript that adds a few
i have this html page: Code: <html> <!-- ... -->or explicity set the background-color
My HTML page displays an image with the following code (using Flickr) <?php echo
My index.html page for my project needs some Ruby code so I need to
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a generated HTML page with flash content in it. I am trying
I have this HTML page, and I want to create a jQuery method that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.