Hey everybody,

I've been trying to create a simple sign in script where a user can sign into a website (there's no back-end, just testing communication) without having a new page to load. I've gotten through most of the problems with it but unfortunately the processes load in this order:

1) Main login page, user submits form to a hidden iframe
2) Javascript loads "success.txt" on form "onsubmit"
3) submit.php processes form and saves results in "success.txt"

And of course, I'd like it to be in this order:

1) Main login page
2) user submits form > submit.php
3) back on main page, Javascript loads "success.txt"

For some reference, here's some of the code I'm using:

success.txt: blank txt file

Main login page:
<form action="signup.php" method="post" target="send" id="sign_up" onsubmit="validate(); ">
  <p>E-mail: <input name="email" /></p>
  <p>Password: <input name="password" type="password" /></p>
  <p><input type="submit" onsubmit="" value="Sign Up" /></p>
<iframe name="send" style="position: absolute; left: -1000px; "></iframe>
Javascript for login page:
var validate = function() {
  var xml = xml_request();
  xml.open("GET", "success.txt", true);
  xml.onreadystatechange = function() {
    if (xml.readyState == 4 && xml.status == 200) {
      var ses = xml.responseText;
      if (ses == "1") alert('logged in');
      else alert('not');
*Note: my xml_request() function is a standard initialization of the XML HttpRequest object (no worries here).

if (count($_POST) > 0) {
  $email = $_POST["email"]; $password = $_POST["password"];
  $error = 0;
  if (!filter_var($email, FILTER_VALIDATE_EMAIL)) $error = 1;
  if (strlen($password) < 6) $error = 1;
  $val = $error ? 0 : 1;
  session_start(); $_SESSION["logged"] = $val;
  $h = fopen("success.txt", "w");
  fwrite($h, $val); fclose($h);
*Note: the $_SESSION is used for other pages when page navigation will take place.

This is my first stab at this type of thing, so I guess there's a lot wrong here with my code order, priority, etc. All thoughts are gladly welcomed!