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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:26:19+00:00 2026-06-04T01:26:19+00:00

I’m working with a .html and a .php. In the default.html the user must

  • 0

I’m working with a .html and a .php. In the default.html the user must enter some info and when the button is clicked the html does a post to the default2.php.
In default2.php the data is checked and if it’s correct it redirects the user to another page. The problem I’m having is when the data entered is wrong.
I’m having two issues here:

  1. When the data is wrong I’m redirecting the user to the default.html, because if I don’t do that, it will stay in default2.php and default2.php has nothing important for the user to see. I don’t know if this is the best way to do this.
  2. When the data entered is wrong, I want an echo message to the user in default.html. But I don’t know how to trigger this from default2.php.

How can I solve these two issues?
Thanks…


default.html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">

</script>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP4</title>
<style type="text/css">
body {
    background-color: #CCC;
}
</style>
</head>

<body>


<p>&nbsp;</p>

<form id="form1" name="form1" method="post" action="default2.php">
  <p>
    <label for="textfield1">User Name</label>
    <input type="text" name="username" id="username" />
  </p>
  <p>
    <label for="textfield2">Password</label>
    <input type="password" name="password" id="password" />
  </p>
  <p>
    <input type="submit" name="button1" id="button1" value="Submit"  />
    <br />
    <br />
  <label id="label1">
  </label></p>
  <p>&nbsp;</p>  
</form>
<p>&nbsp;</p>


</body>
</html>

default2.php:

<?php
require 'connection.php';

  if (isset($_POST['button1'])) {

    $username_v = $_POST['username'];
    $password_v = $_POST['password'];

    // Then you can prepare a statement and execute it.    
    $stmt = $dbh->prepare("CALL login(?, ?)");
    $stmt->bindParam(1, $username_v, PDO::PARAM_STR); 
    $stmt->bindParam(2, $password_v, PDO::PARAM_STR); 

    // call the stored procedure
    $stmt->execute();

    if ($row = $stmt->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_NEXT)) 
    {
          header("Location: main.php");
    }
    else
    {
        header("Location: default.html");
    }

  }
?>
  • 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-06-04T01:26:21+00:00Added an answer on June 4, 2026 at 1:26 am

    Just add some parameter to

    header("Location: default.html?test=failed");
    

    And in html use Javascript to display something sensible when variable test is set to failed. You can find a tutorial how to get value of url parameter with javascript here.

    Hope that helps.

    Other than that you can use PHP in your default.html and perhaps even AJAX request to do validation without leaving the page and highlighting validation errors.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.