<div dir="ltr">Hi Andrew, there are some syntax errors on that page. They mean that your list of books is not being displayed, and actually the PHP code that contains your password is still being served to clients as plain text (you can see this by going to View Source in your browser).<div><br></div><div>The first problem is that the PHP block containing the password starts with a "<script>" tag. Delete "<script>" and replace with "<?php". This will match the closing "?>" tag and mean that the server interprets the code in between as PHP and executes it.</div><div><br></div><div>Once that's sorted, there are syntax errors within the PHP block, including:</div><div>1. function dirmusic lacks a closing brace }</div><div>2. the if <font face="monospace">$_POST($pwd)</font> line should use == not =</div><div>3. the else statement uses ( when it should use {<br></div><div>4. the else statement includes an alert() but this is not PHP at all, it's JavaScript. You can get PHP to output JavaScript code, but for now it is easiest to replace the <font face="monospace">alert("text")</font> with <font face="monospace">echo "text";</font>.</div><div>5. there may be other issues - if you have error reporting enabled in php.ini as per yesterday's emails, PHP will report error messages which should help you fix them</div><div><br></div><div>best wishes</div><div>Matthew</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 15 May 2020 at 10:17, Andrew Ramage <<a href="mailto:andrew.ramage.1963@gmail.com">andrew.ramage.1963@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div>
    <p>I didn't realise that I could use HTML in a php script.  I hand
      have now copied  andrew.html to index.php but only div1 is
      displayed.  How do I get the whole screen displayed ?<br>
    </p>
    <p>On 15/05/2020 09:28, Matthew Rankine wrote:w <br>
    </p>
    <blockquote type="cite">
      
      <div dir="ltr">As Jeremy says, I would ignore AJAX for the moment.
        <div><br>
        </div>
        <div>Andrew, the page you linked (<a href="http://www.andrewnramage.co.uk/andrew.html" rel="noreferrer" target="_blank">www.andrewnramage.co.uk/andrew.html</a>)
          contains some PHP scripts, but it is being served as HTML.
          Instead of the server recognising it as a php page and
          executing the code, it is just treating it as plain text and
          sending it all to the browser.</div>
        <div><br>
        </div>
        <div>That has the consequence that we can all see your PHP code,
          including the (secret) password!</div>
        <div><br>
        </div>
        <div>As a first step, you could rename the file from andrew.html
          to andrew.php; do the same for any other pages containing PHP
          code; and update any links and form actions.</div>
        <div>realisew<br>
        </div>
        <div>Best wishes</div>
        <div>Matthew</div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Fri, 15 May 2020 at 08:43,
          Andrew Ramage <<a href="mailto:andrew.ramage.1963@gmail.com" target="_blank">andrew.ramage.1963@gmail.com</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I
          am trying to set it up so that when a valid login is received,
          a list <br>
          of music on the server will be put up on the right half of the
          screen.  <br>
          See <a href="http://www.andrewnramage.co.uk/andrew.html" rel="noreferrer" target="_blank">www.andrewnramage.co.uk/andrew.html</a><br>
          <br>
          On 14/05/2020 23:58, Jeremy Nicoll wrote:<br>
          > On Thu, 14 May 2020, at 21:35, Swithun Crowe wrote:<br>
          >> Hello<br>
          >><br>
          >> AR> When I use an INPUT form to pass variables to
          a PHP file, echo prints<br>
          >> AR> results on a new screen.  How do I get the
          results printed on the<br>
          >> AR> calling page ?<br>
          >><br>
          >> For this you'll need Javascript. jQuery is quite a
          user friendly<br>
          >> framework.<br>
          >><br>
          >> To have the form submit data to the server without
          refreshing the whole<br>
          >> page, you need to use AJAX, which you can also do
          with jQuery.<br>
          ><br>
          > I think AJAX would be .... ambitious for the OP.   I
          don't think he<br>
          > understands what's going on, now.<br>
          ><br>
          > The HTML form (executing in the user's browser) is NOT
          "passing variables<br>
          > to a PHP file".  The user's browser is making a separate
          (in essence) page<br>
          > fetch, from the webserver, asking it to execute the php
          script on the server<br>
          > and is as part of that, including the 'passed' variables'
          values on the fetch<br>
          > request.   The response from that is another web page
          generated by the<br>
          > php script (on the server) which is sent back to the user
          for their browser<br>
          > to display.<br>
          ><br>
          > /Maybe/ if the generated html page returned by that php
          script also<br>
          > contained a copy of the form, with the results displayed
          somewhere on<br>
          > the page one could /appear/ to have displayed results on
          the original<br>
          > page that contained the form... but it is not the same
          page.<br>
          ><br>
          > The php code on the server is not being called (in the
          sense that most<br>
          > programming languages can call an external function) by
          any of the code<br>
          > (not that there is any) in the original html page.  It's
          the browser that makes<br>
          > the second fetch request, when processing the submit
          action on the form.<br>
          ><br>
          > As Swithin says, if the OP want's (his) program logic to
          affect the way any of<br>
          > his html pages process things, within the user's browser,
          that needs to be<br>
          > done in JavaScript (or any other supported script
          language).  That code<br>
          > though can't 'call' php stuff on the server either.<br>
          ><br>
          ><br>
          > It might help if the OP would describe what he thinks he
          wants the user<br>
          > to do and see on these pages.<br>
          >   <br>
          ><br>
          <br>
          -- <br>
          EdLUG mailing list<br>
          <a href="mailto:EdLUG@lists.edlug.org.uk" target="_blank">EdLUG@lists.edlug.org.uk</a><br>
          <a href="https://lists.edlug.org.uk/mailman/listinfo/edlug" rel="noreferrer" target="_blank">https://lists.edlug.org.uk/mailman/listinfo/edlug</a></blockquote>
      </div>
      <br>
      <fieldset></fieldset>
    </blockquote>
  </div>

</blockquote></div>