0

hi m facing same problem from 2,3 days i m too confused now. i m making an application. when i take data from from dont know why it doesnot reach the other page as
print_r($_POST) is empty
my code of both files are"

<?php
$con=mysql_connect("localhost","root","");
 
	mysql_select_db("pras2");
	?>
	
<!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">
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<title>Home Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="mm_travel2.css" type="text/css" />
<script language="JavaScript" type="text/javascript">
//--------------- LOCALIZEABLE GLOBALS ---------------
var d=new Date();
var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
//Ensure correct for language. English is "January 1, 2004"
var TODAY = monthname[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear();
//---------------   END LOCALIZEABLE   ---------------
</script>
</head>
<body bgcolor="#C0DFFD">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr bgcolor="#3366CC">
    <td colspan="3" rowspan="2"><img src="mm_travel_photo.jpg" alt="Header image" width="382" height="127" border="0" /></td>
    <td height="63" colspan="3" id="logo" valign="bottom" align="center" nowrap="nowrap">insert website name</td>
    <td width="4">&nbsp;</td>
  </tr>

  <tr bgcolor="#3366CC">
    <td height="64" colspan="3" id="tagline" valign="top" align="center">OPTIONAL TAGLINE HERE</td>
	<td width="4">&nbsp;</td>
  </tr>

  <tr>
    <td colspan="7" bgcolor="#003366"><img src="mm_spacer.gif" alt="" width="1" height="1" border="0" /></td>
  </tr>

  <tr bgcolor="#CCFF99">
  	<td colspan="7" id="dateformat" height="25">&nbsp;&nbsp;<script language="JavaScript" type="text/javascript">
      document.write(TODAY);	</script>	</td>
  </tr>
 <tr>
    <td colspan="7" bgcolor="#003366"><img src="mm_spacer.gif" alt="" width="1" height="1" border="0" /></td>
  </tr>

 <tr>
    <td width="165" valign="top" bgcolor="#E6F3FF">
	<table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
        <tr>
          <td width="165">&nbsp;<br />
		 &nbsp;<br /></td>
        </tr>
        <tr>
          <td width="165"><a href="javascript:;" class="navText">destinations</a></td>
        </tr>
        <tr>
          <td width="165"><a href="javascript:;" class="navText">airfare</a></td>
        </tr>
        <tr>
          <td width="165"><a href="javascript:;" class="navText">cruises</a></td>
        </tr>
        <tr>
          <td width="165"><a href="javascript:;" class="navText">specials</a></td>
        </tr>
        <tr>
          <td width="165"><a href="javascript:;" class="navText">contact</a></td>
        </tr>
      </table>
 	 <br />
  	&nbsp;<br />
  	&nbsp;<br />
  	&nbsp;<br /> 	</td>
    <td width="50"><img src="mm_spacer.gif" alt="" width="50" height="1" border="0" /></td>
    <td colspan="2" valign="top"><img src="mm_spacer.gif" alt="" width="305" height="1" border="0" /><br />
	&nbsp;<br />
	&nbsp;<br />
	<table border="0" cellspacing="0" cellpadding="0" width="650">
        <tr>
          <td width="650" class="pageName">welcome store officer </td>
		</tr>

		<tr>
          <td class="bodyText"><p>&nbsp;</p>
            <form id="form1" name="form1" method="post" action="savingISdata2.php">
              <label>
                Enter the date:
                <input type="text" name="date" />
              </label>
              <p>Enter the shift num:
                <label>
                <input type="text" name="num" />
                </label>
</p>
              <p> Enter the name of the product:
			  
			  
			    <select name="P_list">'
		     <?php 
				$query="SELECT product_id,product_name FROM product";
				$result = mysql_query ($query);  

               

						while($menu=mysql_fetch_assoc($result))
						{
						echo '<option value="'.$menu['product_name'].'">'.$menu['product_name'].'</option>';						
						}
?>      
</select></p>
              <p>Enter the amount received:
                <label>
                <input type="text" name="amount_rec" />
                </label>
              </p>
              <p>Enter the sorted amount:
                <label>
                <input type="text" name="amount_sort" />
                </label>
              </p>
              <p>Emter the rejected amount:
                <label>
                <input type="text" name="amount_rej" />
                </label>
              </p>
              <p>Enter the reason for rejection: 
                <label>
                <input type="text" name="reason" />
                </label>
              </p>
              <p align="center">
                <label>
                <input type="submit" name="Submit" value="Submit" />
                </label>
              </p>
            </form>
            <p>&nbsp;</p>          </td>
        </tr>
      </table>
	   <br />	  </td>
    <td width="50"><img src="mm_spacer.gif" alt="" width="50" height="1" border="0" /></td>
        <td width="190" valign="top"><br />
		&nbsp;<br />
		<table border="0" cellspacing="0" cellpadding="0" width="190">
			<tr>
			<td colspan="3" class="subHeader" align="center">NEW DESTINATIONS</td>
			</tr>

			<tr>
			<td width="40"><img src="mm_spacer.gif" alt="" width="40" height="1" border="0" /></td>
			<td width="110" id="sidebar" class="smallText"><br />
			<p><img src="mm_travel_photo1.jpg" alt="Image 1" width="110" height="110" vspace="6" border="0" /><br />
			Include a short description here.<br />
			<a href="javascript:;">Read more &gt;</a></p>

			<p><img src="mm_travel_photo2.jpg" alt="Image 2" width="110" height="110" vspace="6" border="0" /><br />
			Include a short description here.<br />
			<a href="javascript:;">Read more &gt;</a></p>
			 <br />
			&nbsp;<br />
			&nbsp;<br />			</td>
			<td width="40">&nbsp;</td>
			</tr>
		</table>	</td>
	<td width="4">&nbsp;</td>
  </tr>
  <tr>
    <td width="165">&nbsp;</td>
    <td width="50">&nbsp;</td>
    <td width="167">&nbsp;</td>
    <td width="486">&nbsp;</td>
    <td width="50">&nbsp;</td>
    <td width="190">&nbsp;</td>
	<td width="4">&nbsp;</td>
  </tr>
</table>
</body>
</html>
<?php

?>

the file to which data goes is:

<?php
session_start();


$con=mysql_connect("localhost","root","");
 
	mysql_select_db("pras2");

$date= $_POST['date'];

  $shift_num=$_POST['num'];
  
  $name=$_POST['P_list'];
  
  $amount_rec=$_POST['amount_rec'];
  $amount_sort=$_POST['amount_sort'];
  $amount_rej =$_POST['amount_rej'];
  $reason=$_POST['reason'];
  
  
  $query= "SELECT * FROM  `shift` WHERE date='$date' AND shift_no='$num')";
  $result=mysql_query($query) or die(mysql_error());
  if ($result)
  {
  $row=mysql_fetch_assoc($result);
  
  $shift_id = $row(shift_id);
   echo $shift_id;

}

else 
{
echo "failed";
}

$query1="INSERT INTO intemediate_store (shift_id, product, quantity_sorted,quantity_rejected,quantity_received, reason_of_rejection) VALUES ('$shift_id', '$name', '$amount_sort', '$amount_rej', '$amount_rec', '$reason')";

$result1= mysql_query($query1);
if ($result1)
{
echo "data added succssfully";
}
else
{
echo "updation failed";
}
  


?>

the error which it gives is of undefined index of all variables

3
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by sidra 100
0

on line 7 you have

mysql_select_db("pras2");

you need to include the connection in it

mysql_select_db("pras2", $con);
0

using this command i dont get any error but the problem remains there.

i have two other pages same problem lies with them as well

molding schedule which is name of dile which contains form and
machine_schedule take the values and process them


molding_schedule.php

<?php
// ru
$con=mysql_connect("localhost","root","");
 
	mysql_select_db("pras2");
	
	?>
	<?php error_reporting(E_ALL ^ E_NOTICE) ?>
	<!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">
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<title>Home Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="../../../Users/dfff/Documents/Unnamed Site 3/mm_travel2.css" type="text/css" />
<script language="JavaScript" type="text/javascript">
<!--
//--------------- LOCALIZEABLE GLOBALS ---------------
var d=new Date();
var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
//Ensure correct for language. English is "January 1, 2004"
var TODAY = monthname[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear();
//---------------   END LOCALIZEABLE   ---------------

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<style type="text/css">
<!--
.style1 {
	font-size: 36px;
	color: #000000;
}
.style2 {
	font-size: 24px;
	color: #000000;
}
-->
</style>
</head>
<body bgcolor="#C0DFFD">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr bgcolor="#3366CC">
    <td colspan="3" rowspan="2"><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_travel_photo.jpg" alt="Header image" width="242" height="127" border="0" /></td>
    <td height="104" colspan="3" align="center" valign="bottom" nowrap="nowrap" id="logo"><span class="style1">Production Rejection Assessment System </span></td>
    <td width="12">&nbsp;</td>
  </tr>

  <tr bgcolor="#3366CC">
    <td height="60" colspan="3" align="center" valign="top" id="tagline">&nbsp;</td>
    <td width="12">&nbsp;</td>
  </tr>

  <tr>
    <td colspan="7" bgcolor="#003366"><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_spacer.gif" alt="" width="1" height="1" border="0" /></td>
  </tr>

  <tr bgcolor="#CCFF99">
  	<td colspan="7" id="dateformat" height="25">&nbsp;&nbsp;<script language="JavaScript" type="text/javascript">
      document.write(TODAY);	</script>	</td>
  </tr>
 <tr>
    <td colspan="7" bgcolor="#003366"><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_spacer.gif" alt="" width="1" height="1" border="0" /></td>
  </tr>

 <tr>
    <td width="165" valign="top" bgcolor="#E6F3FF">
	<table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
        <tr>
          <td width="165">&nbsp;<br />
		 &nbsp;<br /></td>
        </tr>
        <tr>
          <td><a href="javascript:;" class="navText">Home Page </a></td>
        </tr>
        <tr>
          <td><a href="../../../Users/dfff/Documents/Unnamed Site 3/products.html" class="navText">Products</a></td>
        </tr>
        <tr>
          <td><a href="../../../Users/dfff/Documents/Unnamed Site 3/Log In.html" class="navText">Sign In </a></td>
        </tr>
        <tr>
          <td><a href="javascript:;" class="navText">About us </a></td>
        </tr>
        <tr>
          <td><a href="javascript:;" class="navText">FAQ</a></td>
        </tr>
      </table>
 	 <br />
  	&nbsp;<br />
  	&nbsp;<br />
  	&nbsp;<br /> 	</td>
    <td width="50"><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_spacer.gif" alt="" width="50" height="1" border="0" /></td>
    <td colspan="2" valign="top"><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_spacer.gif" alt="" width="305" height="1" border="0" /><br />
	&nbsp;<br />
	&nbsp;<br />
	<table border="0" cellspacing="0" cellpadding="0" width="786">
        <tr>
          <td width="786" class="pageName style2"><div align="center">SCHEDULE MOLDING SECTION </div></td>
		</tr>

		<tr>
          <td class="bodyText"><form id="form1" name="form1" method="post" action="machine_schedule.php">
		  <p>Enter the machine name:
		     <?php 
				$query1="SELECT machine_id,machine_name FROM machines";
				$result1 = mysql_query ($query1);  
//print_r($result1);
               
               echo  '<select name="M_list">';
						while($menu1=mysql_fetch_assoc($result1))
						{
						echo'<option value="'.$menu1['machine_name'].'">'.$menu1['machine_name'].'</option>';						
						}
					  echo '</select>';
?>      
</p>
		  <p>Enter the name of product:
		  <select name="P_list">'
		     <?php 
				$query="SELECT product_id,product_name FROM product";
				$result = mysql_query ($query);  

               

						while($menu=mysql_fetch_assoc($result))
						{
						echo '<option value="'.$menu['product_name'].'">'.$menu['product_name'].'</option>';						
						}
?>      
</select>
</p>
		  
		  <p>target acheived in this month:
		    <label>
		    <input type="text" name="num" />
		    </label>
</p>
		  <p>Enter the start date:
		    <label>
		    <input type="text" name="date" />
		    </label>
</p>
		  <p>&nbsp;</p>
		  <p>&nbsp;</p>
		  
		  <p align="center">
		    <input type="submit" name="Submit" value="Next machine" />
            <input type="submit" name="Submit2" value="Send to Section incharge" />
		    <a href="../../../Users/dfff/Documents/Unnamed Site 3/Administrator.html"><input type="submit" name="Submit3" value="Back" /></a>		  </p>
		  <p>&nbsp;		     </p>
		</form>
		<p>&nbsp; </p></td>
        </tr>
      </table>
	   <br />	  </td>
    <td width="73"><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_spacer.gif" alt="" width="50" height="1" border="0" /></td>
        <td width="190" valign="top"><br />
		&nbsp;<br />
		<table border="0" cellspacing="0" cellpadding="0" width="190">
			<tr>
			<td colspan="3" class="subHeader" align="center">NEW DESTINATIONS</td>
			</tr>

			<tr>
			<td width="40"><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_spacer.gif" alt="" width="40" height="1" border="0" /></td>
			<td width="110" id="sidebar" class="smallText"><br />
			<p><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_travel_photo1.jpg" alt="Image 1" width="110" height="110" vspace="6" border="0" /><br />
			Include a short description here.<br />
			<a href="javascript:;">Read more &gt;</a></p>

			<p><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_travel_photo2.jpg" alt="Image 2" width="110" height="110" vspace="6" border="0" /><br />
			Include a short description here.<br />
			<a href="javascript:;">Read more &gt;</a></p>
			 <br />
			&nbsp;<br />
			&nbsp;<br />			</td>
			<td width="40">&nbsp;</td>
			</tr>
		</table>	</td>
	<td width="12">&nbsp;</td>
  </tr>
  <tr>
    <td width="165">&nbsp;</td>
    <td width="50">&nbsp;</td>
    <td width="33">&nbsp;</td>
    <td width="795">&nbsp;</td>
    <td width="73">&nbsp;</td>
    <td width="190">&nbsp;</td>
	<td width="12">&nbsp;</td>
  </tr>

machine_schedule.php

<?php error_reporting(E_ALL ^ E_NOTICE) ?>

<?php
session_start();

//print_r($_POST); //to check k forms se value arai ha k ne
// to abi next sy aisy mat karna ok

$con=mysql_connect("localhost","root","");
 
mysql_select_db("pras2", $con);
	
	$product=$_REQUEST["P_list"];
	echo  $product;
	$machine=$_POST['M_list'];
	$quantity=$_POST['num'];
	$st_date=$_POST['date'];
	
	$query="INSERT INTO molding_schedule(machine_name, product_name, quantity_required, date_start, pending) VALUES ('$machine', '$product', '$quantity', '$st_date', '$quantity')";
	
	$result=mysql_query($query) or die(mysql_error());
	
	if ($result)
	{
	echo " machine schedule fixed";
	echo "<a href=\"molding_schedule.php\">CLICK HERE TO ENTER NEXT  MACHINE SCHEDULE<\a>";
	}
	else 
	{
	echo "updation failed";
	}
	?>

it also has same problem of undefined index of all variables

0

Hai Sidra 100!
I have found some errors,
Am telling these for all for first page you have posted,
In first file you have not used any form !!First use form .
Then check weather that files are in same folder or not means change the path on the form .
There is no '$num' variable in the second page . Check it out

Thats it , it will fix.. If not tell me
$query= "SELECT * FROM `shift` WHERE date='$date' AND shift_no='$num')"; --$num not specified

The Second post
In machine_schedule.php check that code <?php error_reporting(E_ALL ^ E_NOTICE); ?>
You havn't inserted ';' for them . Sorry that's my mistake
Use any one $_REQUEST[], or $_POST[].
I recommend you to use $_POST["something"]; instead of $_POST; "SEE QUOTATIONS"


Try it..

Edited by mohamedasif18: Spelling

0

in the first page form is there on line 107 it is declared. from where i have to get the values. and it do access the second page. but out on second page shows that undefined index of all variables. means it do proceed to next page but it values are not transfered. rest of my mistakes as you have told me. i have corrected them.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.