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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:35:04+00:00 2026-06-06T15:35:04+00:00

I have a ecrtst.php which has 3 fields for input, on submit – submit-ecr.php.

  • 0

I have a ecrtst.php which has 3 fields for input, on submit – submit-ecr.php. I need to write the data into a mysql table, validating if there is no blank field.
When I submit with all values it is working fine, it comes back to ecrtst.php after successful submission, but when I leave a blank field, it is unable to show the errors.

Let me know if we can show errors in javascript or php and then go back to previous page.

ecrtst.php file:

<?php
$dbservertype='mysql';
$servername='localhost';
$dbusername='hitec';
$dbpassword='!@#';
$dbname='hitec';

connecttodb($servername,$dbname,$dbusername,$dbpassword);
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
global $link;
$link=mysql_connect ("$servername","$dbuser","$dbpassword");
if(!$link){die("Could not connect to MySQL");}
mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
}
//////// End of connecting to database ////////
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head id="Head1" runat="server">
<title>ECR</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
    $(function () {
    $("form:not(.filter) :input:visible:enabled:first").focus();
    });
</script>

</head>

<body document.f1.ecrno.focus();">
<table width="100%"  border="0" cellpadding="0" cellspacing="0" bgcolor="#026465">
  <tr>
<td><div align="center"><center class="style6">ECR</center>
<center>

<?php
$rowec=mysql_query("SELECT Ecrno FROM ECRHDR_draft WHERE usr='$user'");
$rowec2=mysql_fetch_assoc($rowec);
$rowec3=$rowec2['Ecrno'];
?>
<form name='f1' id='f1'>
<table width="600" border="0" cellspacing="1" cellpadding="0">
  <tr>
    <td width="60"><span class='style5'>ECR No.</span></td>
    <td width="99"><input name="ecrno" type="text" size="10" maxlength="10" value="<?=$rowec3;?>" onchange="showecr(this.value);"></td>
<?php
$rowarea=mysql_query("SELECT Area FROM ACMAST");
$rowarea2=mysql_fetch_assoc($rowarea);
$rowarea3=$rowarea2['Area'];
?>
    <td width="180"><select name='area' onchange="showarea(this.value);">
    <option value='<?=$rowarea3;?>'> <?=$rowarea3;?> <option>
    <option value='Rajajinagar'>Rajajinagar</option>
    <option value='Jayanagar'>Jayanagar</option>
    <option value='Chennai'>Chennai</option>
    </select></td>
<?php $script_dt = date('d/m/Y'); ?>
<td width="72"><span class='style5'>ECR Date:</span></td>
<td width="189"><input name="ecrdate" type="text" size="10" maxlength="10" value="<?=$script_dt;?>" onchange="showecrdate(this.value);"> <span class='style5'>(d/m/yyyy)</span>        </td>
  </tr>
</table>
<a href="submit-ecr.php" target="_parent" accesskey="s" ><input name="SAVE" type="button" value="SAVE ECR !">
</form>
</center>
</body>
</html>

submit-ecr.php file:

<?php
ob_start();

$con = mysql_connect("localhost","hitec","@#");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("hitec", $con);

 //-----Checking for blank fields in ECRHDR-draft file. ------------------------//

 $rowexist=mysql_query("select Ecrno from ECRHDR_draft WHERE usr='$user'");
 $data=mysql_fetch_array($rowexist);

  if ($data[Ecrno] <= 0 || $data[Ecrno]='')
  {
  echo "<span class='sty1'><center>DONOT LEAVE EMPTY FIELDS for ECR No.</CENTER><br>    <br></span>";
  echo " <span class='sty1'><center><a href=\"javascript:PreviousPage();\">CLICK HERE TO GO BACK !!!!</a></CENTER></span>";
  }

$URL="http://www.samplesite.info/svga//ecrtst.php";

header('WWW-Authenticate: Negotiate');
header('WWW-Authenticate: NTLM', false);
header ('Location:'.$URL);

mysql_close($con);
ob_flush();?>
  • 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-06T15:35:05+00:00Added an answer on June 6, 2026 at 3:35 pm

    What you’re doing is a little wacky. Instead of echoing the errors, start a PHP session at the top of the file with session_start(), and then store the error messages in the session like $_SESSION['dberror'] = 'You didn\'t fill out all the fields.';.

    After you redirect, check on the other page for the error session_start(); if (isset($_SESSION['dberror'])) { echo $_SESSION['dberror']; unset($_SESSION['dberror']); }.

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

Sidebar

Related Questions

Have data that has this kind of structure: $input = [ { animal: 'cat',
Have data that has this kind of structure. Will be in ascending order by
Have a simple one-off tasks which needs a progress bar. OpenSSL has a useful
Have anyone used Redmine Documentor which lets you convert PHP to HTML to Redmine
Have a bunch of classes which I need to do serialize and deserialize from/to
Have deployed numerous report parts which reference the same view however one of them
Have the following select giving me the data I want, but I want to
Have searched the database but need to specifically sum(of hours flown or days off)in
Have a look at this url: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:jquery_ui_methods#column_chooser I have got the Column Chooser dialog
Have a really weird one here. The app has two targets, just to be

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.