Skip on the php code section for the first time we upload page : <p>So, i am learning how to write php now.I want to build a small shopping website. My index.html looks something like this:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;link href="index.css" rel="stylesheet" /&gt;
      &lt;title&gt;
        eShop
      &lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;div class="topnav"&gt;
      &lt;a class="active" href="#index.html"&gt;Home&lt;/a&gt;
      &lt;a href="loginAdmin.php"&gt;Administrator&lt;/a&gt;
      &lt;a href="loginUser.php"&gt;Register User&lt;/a&gt;
      &lt;a href="newAccount.php"&gt;Register New Account&lt;/a&gt;
    &lt;/div&gt;
    &lt;img class="centerImage" src="eshop.jpg"&gt;
 &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>and the loginAdmin.php file looks like this:</p>

<pre><code>&lt;?php
session_start();
// here is the code that connects to the database. Note that the username
// and password are "hard-coded".
$user="root";
$passwd="";
$database="";

$link = mysqli_connect(localhost,$user,$passwd);
@mysqli_select_db($link,$database) or die ("Unable to select database");

// try to create a new record from the submission
$username =  mysqli_real_escape_string($link,$_REQUEST['username']);
$password= mysqli_real_escape_string($link,$_REQUEST['password']);

if ($username &amp;&amp; $password) {

  // here we define the SQL command
  $query = "SELECT * FROM people WHERE Username='$username' AND Password='$password'";

  // submit the query to the database
  $res=mysqli_query($query);

  // make sure it worked!
  if (!$res) {
    echo mysql_error();
    exit;
  }

  // find out how many records we got
  $num = mysqli_numrows($res);

  if ($num==0) {
    echo "&lt;h3&gt;Invalid login&lt;/h3&gt;\n";
    exit;
  } elseif ($num!=1) {
    echo "&lt;h3&gt;Error - unexpected result!\n";
    exit;
  }

  // valid login, set the session variable
  $_SESSION['userid']=mysql_result($res,0,'userid');
  echo "&lt;h3&gt;Welcome $username&lt;/h3&gt;\n";
?&gt;

&lt;head&gt;
    &lt;link href="login.css" rel="stylesheet" /&gt;
    &lt;title&gt;
        eShop
    &lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
    &lt;div class="login-page"&gt;
        &lt;div class="form"&gt;
            &lt;form class="login-form"&gt;
                &lt;input type="text" placeholder="User Name:" /&gt;
                &lt;input type="password" placeholder="Password:" /&gt;
                &lt;button onclick="writeMsg()"&gt;login&lt;/button&gt;
            &lt;/form&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/body&gt;
</code></pre>

<p>If the user pressed on the loginAdmin link so the php code will be executed, and i dont want that, only after the user pressed on the login button i want the php code block will be executed. How can i do that? Maybe i should seperate the files (php and html) and not user href on the php files in the index.html ? and the index.html file should be index.php?  </p>
