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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:50:43+00:00 2026-05-28T03:50:43+00:00

I have an issue in a PHP script which checks if the tax number

  • 0

I have an issue in a PHP script which checks if the tax number has right company name on input some other form fields and insert into MySQL. What I want is to put some control code – maybe “select distinct formCompany from company where formCompany = “.$formCompany.” ” or some code which checks if taxid is given correctly for the name of company from input form. Does someone have idea of how to do that? Any example is welcome.

I have script which simply input data from form fields into MySQL db:

$db=mysql_connect($hostname, $db_user, $db_password);
    mysql_select_db($database,$db);
$taxid=mysql_real_escape_string($_POST['taxid']);
$formCompany=mysql_real_escape_string($_POST['formCompany']);
$formOffice=mysql_real_escape_string($_POST['formOffice']);
$formBr=mysql_real_escape_string($_POST['formBr']);
$formContact=mysql_real_escape_string($_POST['formContact']);
//trim
$id=trim($id);
$taxid=trim($taxid);
$formCompany=trim($formCompany);
$formOffice=trim($formOffice);
$formBr=trim($formBr);
$formContact=trim($formContact);
if($_POST['taxid']==''||$_POST['formCompany']=='') {
       echo '<p style="color: red">Input relevant data!<p>';
   } else { 
      $sql = "INSERT INTO company (taxid, formCompany,formOffice,formBr,formContact) VALUES ('$taxid','$formCompany','$formOffice','$formBr', '$formContact')";
   if(!$result = mysql_query($sql, $db)) {
      echo "ERROR: ".mysql_error();
   } else {
      header("Refresh: 0; url=main.php");
   }
}
  • 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-28T03:50:44+00:00Added an answer on May 28, 2026 at 3:50 am

    First, add this code before the if statement

    $taxcheck = mysql_query("SELECT * FROM company WHERE taxid = '" . $taxid . "' ");
    if (mysql_num_rows($taxcheck)) { $exists = true; }
    else { $exists = false; }
    

    Then change this line

    if($_POST['taxid']==''||$_POST['formCompany']=='')
    

    to

    if($_POST['taxid'] == "" || $_POST['formCompany'] == "" || $exists == true)
    

    This code will prevent you from ending up with more than one company using one tax ID number.

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

Sidebar

Related Questions

I have a PHP script which has the source of an email. I aim
I have a long running php script which is basically an infinite loop listening
Quick question : I have a PHP script which query Pinnacle Cart API through
I have a php script, which downloads, rescales and stores an image using the
I'm trying to run a PHP script which has pg_connect($connection_string) and it just crashes
I have a php script that triggers some magento actions, and I set it
I have created a custom PHP script which uploads information submitted by a form
I have a PHP script which is used to resize images in a user's
I have a script in kohana which runs fine on php 5.2.11. I took
I have a php script which generates an image, and is used (mainly) like

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.