Jump to content

Posting to 'PHP_SELF' Suddenly NOT working


JOECICIO

Recommended Posts

I am using two different systems:

IIS 7 on Vista and IIS 6 on XP Prof

The code worked until I reinstalled PHP - followed all recommendations

Here is the code:

<?php # Script 12.7 - login.php

// This is the login page for the site.

 

// Include the configuration file for error management and such.

//require_once ('config.inc');

 

// Set the page title and include the HTML header.

$page_title = 'Login';

include ('header.html');

if (isset($_POST['submit']))

  { // Check if the form has been submitted.

  include ('mysql_connect.php'); // Connect to the database.

  $u = $_POST['username'];

  $p = $_POST['password'];

  $query = "SELECT user_id, first_name FROM users WHERE first_name='$u' AND '$p'=DECODE(password,'joepass')";

    if($result = @mysqli_query ($mysqli,$query)){

      $row = mysqli_fetch_row($result);

      $_SESSION['first_name'] = $row[1];

      $_SESSION['user_id'] = $row[0];

      mysqli_free_result($result);

      header ("Location:  http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/index.php"); // redirect to home page

    echo 'posted';

  } else{// No result -- match was made.

          echo '<p><font color="red" size="+1">The username and password entered do not match those on file.</font></p>';

  }

  mysqli_close($mysqli);// close connection

}

?>

 

<h1>Login</h1>

<p>Your browser must allow cookies in order to login.</p>

<form onsubmit="return validatelogin(this)"  method="post" action="login.php"><!--  action="http://localhost/mysql-php/login.php" -->

<fieldset>

<p><b>User Name:</b> <input type="text" name="username" size="10" maxlength="20" value="larry" /></p>

<p><b>Password:</b> <input type="password" name="password" size="20" maxlength="20" value="happytime" /></p>

<div align="center"><input type="submit" name="submit" value="Login" /></div>

</fieldset></form><!-- End of Form -->

 

<?php // Include the HTML footer.

include ('footer.html');

?>

 

=====================\

The posted data should go to login.php but now i get a server error. It doesn't matter whether I leave "Action" empty or simple (as shown) or fully qualified. Before  clicking submit, the form is properly rendered . It appears certain that the post is being directed to the correct file (login.php - ITSELF) because I get a status message "Waiting for (http://localhost/mysql-php/login.php)

Where should I look for the problem???

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.