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 975287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:33:45+00:00 2026-05-16T03:33:45+00:00

Here is my login PHP code. <?php // rnlogin.php include_once ‘rnheader.php’; echo <h3>Member Log

  • 0

Here is my login PHP code.

<?php // rnlogin.php
include_once 'rnheader.php';
echo "<h3>Member Log in</h3>";
$error = $user = $pass = "";

if (isset($_POST['user']))
{
 $user = sanitizeString($_POST['user']);
 $pass = sanitizeString($_POST['pass']);

 if ($user == "" || $pass == "")
 {
  $error = "Not all fields were entered<br />";
 }
 else
 {
  $query = "SELECT user,pass FROM rnmembers
      WHERE user='$user' AND pass='$pass'";

  if (mysql_num_rows(queryMysql($query)) == 0)
  {
   $error = "Username/Password invalid<br />";
  }
  else
  {
   $_SESSION['user'] = $user;
   $_SESSION['pass'] = $pass;
   die("You are now logged in. Please
      <a href='rnmembers.php?view=$user'>click here</a>.");
  }
 }
}

echo <<<_END
<form method='post' action='rnlogin.php'>$error
Username <input type='text' maxlength='16' name='user'
 value='$user' /><br />
Password <input type='password' maxlength='16' name='pass'
 value='$pass' /><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<input type='submit' value='Login' />
</form>
_END;
?>

As you can see the error message is printed with echo.
Is there a way that I can put this error message in a control and display it only if there is error?

It sounds like I have to combine PHP with JavaScript?

The following code is used by Gmail to display error message.
It works even if JavaScript is turned off.
In other words, they use some techniques independent of JS.

Any idea, how I can do similar thing here?

<code>
                <td align="left">
                  <div id="errormsg_0_Passwd" class="errormsg">
                  The username or password you entered is incorrect.
                  [<a target="_blank" name="helpLink" href="http://www.google.com/support/accounts/bin/answer.py?answer=27444&amp;hl=en&amp;ctx=ch_ServiceLoginAuth&amp;p=mail">?</a>]
                  </div>
                  </td>
</code>

Thank you

  • 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-16T03:33:46+00:00Added an answer on May 16, 2026 at 3:33 am

    Is there a way that I can put this error message in a control and display it only if there is error?

    in PHP you can do anything. Want to put this error message in a control? Put it into control

    if ($error) $error = "<control>$error</control>";
    

    You have to distinguish string operation from echoing.
    echoing a string is not the only way of string manipulations.
    you can prepare your string first and then echo it out.
    So, you can prepare all parts of the string first, and then print them all together.

    Also, there is another way to output HTML, a preferred one.

    <?php
    // your php code here
    //before output we close PHP tag and use pure HTML
    //with some PHP specks
    ?>
    
    <form method="post" action="rnlogin.php">
    <?php if($error): ?>
    <code>
      <td align="left">
        <div id="errormsg_0_Passwd" class="errormsg">
          <?php echo $error ?>
        </div>
      </td>
    </code>
    <? endif ?>
    Username <input type='text' maxlength='16' name='user'
     value='$user' /><br />
    Password <input type='password' maxlength='16' name='pass'
     value='$pass' /><br />
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    <input type='submit' value='Login' />
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is the code <?php session_start(); if(!isset($_SESSION['user_name'])) { header('Location: login.php'); } $conn = mysql_connect(localhost,
here is my JS code: $.ajax({ url: 'login.php', type: 'POST', data: { loginName: $(#loginName).val(),
Here is the code that I'm working on: login.php: <?php $con = mysql_connect(localhost,root,); mysql_select_db(koro,$con);
Hi i have here a login logout function in PHP wherein a user could
I am facing troubles with sessions codes here is login code: <?php /** *
I'm a newbie to sql and am trying to follow this example here: http://net.tutsplus.com/tutorials/php/a-better-login-system/
For eg: http://example.com/login Here is my site once I logged inside and uses User
Here's the scenario. When a user's login info is submitted, activityIndicator view is shown.
I have a login form using jquery ajax and a php code. The issue
Here it is my code: <?php if ( ! defined('BASEPATH')) exit('No direct script access

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.