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

  • Home
  • SEARCH
  • 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 6251853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:41:27+00:00 2026-05-24T13:41:27+00:00

I currently have a html login page which has two textfields for e-mail address

  • 0

I currently have a html login page which has two textfields for e-mail address and password. The HTML contains a form and a button which triggers some javascript to check the data input is valid. If the data is valid, then the data is posted to a php application.

This php application gives a response dependent on whether the login details were valid/invalid.

Here is my php:

if(isset($_POST['username']) && isset($_POST['password'])){
    //connect to database
    $dbh = connect();   
    $user = mysql_real_escape_string($_POST['username']);
    $usertype = mysql_real_escape_string($_POST['usertype']);
    $pass = md5($_POST['password']);
    $query = "";
    if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $user)) {
      if($usertype == "SupportStaff"){      
        $query = "SELECT staffId, fName, lName, gender, email FROM SupportStaff WHERE email = '$user' AND password = '$pass'";
      }else{       
        $date = $_POST['currdate'];     
        $query = "SELECT athleteId, fName, lName, gender, email FROM Athletes WHERE email = '$user' AND password = '$pass'";
      } 

      //make query
      $result = mysql_query( $query ) or die ("didn't query");

      //see if there's an EXACT match
      $num = mysql_num_rows( $result );
      if ($num == 1){
        $row = mysql_fetch_assoc($result);
        if($usertype == "Athlete"){     
          $user = str_replace("@","at",$user);
          $user = str_replace(".","dot",$user);
          $user .= "Entries";
          $query = mysql_query("SELECT * FROM $user WHERE date = '$date'");
          $exists = false;
          if(mysql_num_rows( $query ) == 1){
        $exists = "true"; //to see if questionnaire is complete
          }else{
        $exists = "false";
          }
          $row['complete'] = $exists;               
        }
        echo json_encode($row);
      } else {
        echo ($user." ");
        echo ($pass);
        echo ("&result=invalid");
      }
    }else{
      mysql_close($dbh);
      echo ("&result=false"); //invalid e-mail address
    }
    mysql_close($dbh);
}
?>

If it echos &result=false OR &result=invalid then I would like the user to be served up with the login page again displaying an error message or something similar, if it is successful (echo json_encode($row)) then it should take to home.html (i.e. the homepage)…What is the best way to achieve this?

  • 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-05-24T13:41:29+00:00Added an answer on May 24, 2026 at 1:41 pm

    Either use Ajax or redirect server side after doing the desired processing.

    If you go for the Ajax route (which would be sensible if you are already doing client side scripting), you may want to take a look at jQuery’s Ajax functionality. Specifically, post will probably meet your requirements.

    I’m sure you know, but I should emphasise that client side validation alone is not sufficient to secure your site. Client side validation should be viewed as a way of improving the user experience, not as a form of security. People could easily bypass any client side validation by making requests to the server manually.

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

Sidebar

Related Questions

Currently I have a login page (login.html) with nothing but a login form on
I currently have a product view page that contains an MVCContrib HTML Grid with
I currently have two apps: app1/ app2/ templates/ app1.html app2.html In app1.html, I'm including
Currently I have some xml documents which are converted via xsl into html. The
Say I have one full-page form, but within the form, there are two or
I currently have a login page that sends all authenticated users to a main
I currently have the following MySQL statement to replace the HTML entity for a
I have an html table with many rows. I'm currently grouping several rows inside
I have this command that I run every 24 hours currently. find /var/www/html/audio -daystart
The JavaScript code window.print() can print the current HTML page. If I have a

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.