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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:23:38+00:00 2026-06-11T00:23:38+00:00

Hi can some one please point out my mistake here. I’ve got two PHP

  • 0

Hi can some one please point out my mistake here. I’ve got two PHP files. First view.php goes as follows; and the second as processor.php
I see the if(constant(‘SELECTitem’) == $i) line doesnt capture the desired input to be compared with $i hence straight goes to ‘else’ validation. Please correct me. Thanks.

view.php

<?php
$con=mysql_connect('localhost','root') or die ("Server connection failure!");
$db=mysql_select_db('regional_data',$con) or die ("Couldn't connect the database");
$SQL="SELECT sbstart, sbend FROM newchk";
$run=mysql_query($SQL,$con) or die ("SQL Error");
$nor=mysql_num_rows($run);

define("SELECTitem", form.options.value);
?>
<html>
<head><title></title>
<script type="text/javascript">
function ValidateData(form) 
{
var TextIn = document.getElementById('txtN');
if(form.txtN.value == "")
{
alert("Text field is empty"); 
return false;
}else{
alert ((form.options[form.options.selectedIndex].value) + (form.txtN.value));
}
}
</script>
</head>
<body>
<form onsubmit="return ValidateData(this)" method="POST" action="processor.php">
<select STYLE='width:90px' name="options"><?php
while ($rec = mysql_fetch_array($run))
{
    for($i=$rec['sbstart']; $i<=$rec['sbend']; $i++)
    {
    echo "<option id='options' value='$i'>$i<br></option>";
    }
}
?>
</select>
<input type="text" id="txtN">
<input type="submit" name="subN" value="Save">
</form>

</body>
</html> 

processor.php

<?php
$con=mysql_connect('localhost','root') or die ("Server connection failure!");
$db=mysql_select_db('regional_data',$con) or die ("Couldn't connect the database");
$SQL="SELECT * FROM newchk";
$run=mysql_query($SQL,$con) or die ("SQL Error");
$nor=mysql_num_rows($run);

while ($rec = mysql_fetch_array($run))
{
for($i=$rec['sbstart']; $i<=$rec['sbend']; $i++)
    {
    if(constant('SELECTitem') == $i)
     {
        if($rec['totsb'] <= "0")
        {
        echo "You have already entred this cheque number."; 
        return false;
        } else {
        echo "You can proceed withi this entry"; 
        return false;
        }
     }
     else 
     { echo "Error: Cant find choosen in the databse"; 
      return false;
     }
    }
}
?>
  • 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-11T00:23:40+00:00Added an answer on June 11, 2026 at 12:23 am

    When you submit to processor.php, the constant you created in the previous page will not be carried over. Also, when you are defining the constant, you cannot access JavaScript in PHP. So the constant you created…

    define("SELECTitem", form.options.value);
    echo SELECTitem; // returns "formoptionsvalue" (form concatenated with options and value)
    

    What you should do is submit form.options.value and access it via $_POST.

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

Sidebar

Related Questions

Possible Duplicate: JavaScript: formatting number with exactly two decimals Can some one please help
it's assembler right? can someone please point out the progression that we've had in
Can someone please point me out a hash function (preferably an implementation) which would
Could someone please point out a site where I can find an algorithm to
Can some one please explain why this loop never 'breaks' and goes on forever
Can some one please tell me why exactly classes were introduced in C++. Are
Can some one please guide me to understand which jar file i need to
Please can some one explain the javacv method for the pyrDown() method. I'm trying
Please can some one give an example describing cascading as meant in CSS and
Can someone please point me to instructions for installing the latest Indy10 in Delphi

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.