Link to home
Start Free TrialLog in
Avatar of MrTV
MrTVFlag for Thailand

asked on

Deprecated: Function session_register() php

Deprecated: Function session_register() is deprecated in C:\wamp\www\asian\stockadjust\adjust.php on line 68

please suggest how to fix
<?php
header('Content-Type: text/html; charset=utf-8');
error_reporting(E_ALL);
include "./common_db.inc";
// $register_script = "./register.php";

function auth_user($userid, $userpassword) {
   global $default_dbname1, $user_tablename;
  
   $link_id = db_connect1($default_dbname1);
   $query = "SELECT nickname FROM $user_tablename 
                             WHERE nickname = '$userid' 
                             AND password = '$userpassword' AND stockad = 'y' ";
   $result = mysql_query($query);
   if(!mysql_num_rows($result)) return 0;
   else {
      $query_data = mysql_fetch_row($result);
      return $query_data[0];
   }
}

function login_form() {
   global $PHP_SELF;
?>
<HTML>
<HEAD>
<TITLE>Login</TITLE>
</HEAD>
<BODY>
<FORM METHOD="POST" ACTION="<?php echo $PHP_SELF ?>">
   <DIV ALIGN="CENTER"><CENTER>
      <H3>Please log in to access the page you requested.</H3>
   <TABLE BORDER="1" WIDTH="200" CELLPADDING="2">
      <TR>
         <TH WIDTH="18%" ALIGN="RIGHT" NOWRAP>ID</TH>
         <TD WIDTH="82%" NOWRAP>
            <INPUT TYPE="TEXT" NAME="userid" SIZE="8">
         </TD>
      </TR>
      <TR>
         <TH WIDTH="18%" ALIGN="RIGHT" NOWRAP>Password</TH>
         <TD WIDTH="82%" NOWRAP>
            <INPUT TYPE="PASSWORD" NAME="userpassword" SIZE="8">
         </TD>
      </TR>
      <TR>
         <TD WIDTH="100%" COLSPAN="2" ALIGN="CENTER" NOWRAP>
            <INPUT TYPE="SUBMIT" VALUE="LOGIN" NAME="Submit">
         </TD>
      </TR>
   </TABLE>
   </CENTER></DIV>
</FORM>
</BODY>
</HTML>
<?php
}



session_start();
if(!isset($userid)) {
   login_form();
   exit;
}
// main else when have log in then process
else {
   session_register("userid", "userpassword");
   $username = auth_user($userid, $userpassword);
   if(!$username) {
      session_unregister("userid");
      session_unregister("userpassword");
      echo "Authorization failed. " .
           "You must enter a valid userid and password combo. " .
           "Click on the following link to try again.<BR>\n";
      echo "<A HREF=\"$PHP_SELF\">Login</A><BR>";
      echo "If you're not a member yet, click " .
           "on the following link to register.<BR>\n";
      echo "<A HREF=\"$register_script\">Membership</A>";
      exit;
   }
// incase get correct user Id  
    else
    {$_SESSION['username'] = $userid;
	
	echo "Welcome, $username!";
     
	 
	 
	if ( isset($_POST['update']) )

// I plane to check it have 4 parameter  if it have then process to in sert in database	

	
	
	{
	include "user4.inc";
	
	$db = db_connect($default_dbname);
	$sql = "UPDATE  `prdmas` SET OnHand='$OnHand',SellPrice1='$SellPrice1',Shelf1='$Shelf1',Stare1='$Stare1',Sel2='$Sel2',str02='$str02' WHERE  Code='".($Code)."'";

	$result = mysql_query($sql);
   

    ?>
	<html>
	<head>
	<title>Adjust Stock </title>
	
	<body>
 
	<h1>Enter Product No</h1>

	  <form  method="post" action="<?php echo $PHP_SELF?>"> 
	   <table border="0">
     
		 <tr>
       
	       <td><input name="id" type="text" size="70" maxlength="70"><br /></td>
	    </tr>
	 
	      <tr>
        <td colspan="2"><input type="submit" value="Register"></td>
      </tr>
	   </table>
	 </form>
	</body>
	</html>
	<?php




	echo "<br><br>Product Code $Code updated .\n";
//i fstate ment show the detail of each record that they list
		if ( $onbook != $OnHand || $onprice != $SellPrice1 )
		{
		$sql2 = "INSERT INTO StockRec ( user, procode, laststock, stock, lastprice, price) VALUES ('$username','$Code','$onbook','$OnHand','$onprice','$SellPrice1')";
		$result = mysql_query($sql2);
		
		
		echo "<br><br>Last 15 record that up date";
		
         $list015 = mysql_query("SELECT * FROM `StockRec` ORDER BY `datetime` DESC  LIMIT 0 , 30");
echo "<table cellpadding=2 cellspacing=1 border=0>"; 
$alternate = "2"; 
while ($row = mysql_fetch_array($list015)) { 

$UsrCh = $row["user"];
$CodeCh = $row["procode"];
$laststockCh = $row["laststock"];
$stockUp = $row["stock"];
$LastpriceChk = $row["lastprice"]; 
$priceChke = $row["price"];
$datetimeChke = $row["datetime"];

if ($alternate == "1") { 
$color = "#ffffff"; 
$alternate = "2"; 
} 
else { 
$color = "#efefef"; 
$alternate = "1"; 
} 
echo"<trbgcolor=$color><td>$UsrCh</td><td>$CodeCh</td><td>$laststockCh</td><td>$stockUp</td><td>$LastpriceChk  </td><td>$priceChke</td><td>$datetimeChke</td></tr>"; 
} 
echo "</table>";

		



	
		}

	}
// end of show record	

		else if (isset($id))
		{
		$id2 =$id ;
		include "user4.inc";
		$db = db_connect($default_dbname);
		$result = mysql_query("SELECT  Code,Name,OnHand,SellPrice1,Shelf1,Stare1,Sel2,str02 FROM prdmas  WHERE Code =  '$id2' ",$db);
		$myrow = mysql_fetch_array($result);
		$onbook = $myrow["OnHand"] ;
		$onprice = $myrow["SellPrice1"] ;
		$Shelf1 = $myrow["Shelf1"] ;
		$Stare1 = $myrow["Stare1"] ;
		$Sel2 = $myrow["Sel2"] ;
		$str02 = $myrow["str02"] ;


		echo "the stock on book : $onbook ";
		?>
		 <form method="post" action="<?php echo $PHP_SELF?>">
    
		 <table width="380" border="0" cellspacing="1" cellpadding="1">
	    <tr> 
		 <td>Product Code</td><td><?php echo $myrow["Code"]?></td>
		  <td> 
        <input type="hidden" name="Code" size="35" value="<?php echo $myrow["Code"]?>">
		  </td>
	      <td>         
		    <input type="hidden" name="onbook" size="35" value="<?php echo "$onbook"?>">
		  </td>
		  <td>         
		    <input type="hidden" name="onprice" size="35" value="<?php echo "$onprice"?>">
		  </td>
			</tr>
		  <td>  Product Name: </td>
		<td>
        <?php echo $myrow["Name"]?>
		  </td>
			</tr>
		   <tr> 
		  <td>On stock</td>
		  <td> 
			<input type="Text" name="OnHand" size="35" value="<?php echo $myrow["OnHand"]?>">
		 </td>
		  </tr>    
			<tr> 
		<td>Price ¿¿¿¿:</td>
      <td> 
        <input type="Text" name="SellPrice1" size="35" value="<?php echo $myrow["SellPrice1"]?>">
      </td>
     <tr> 
	   <td>Self1-Stare1</td>
	  <td> 
        <input type="Text" name="Shelf1" size="2" maxlength="2" value="<?php echo $myrow["Shelf1"]?>">
      
        <input type="Text" name="Stare1" size="2" maxlength="2" value="<?php echo $myrow["Stare1"]?>">
      </td>

		</tr> 
		<tr> 
	   <td>Self2-Stare2</td>
	  <td> 
        <input type="Text" name="Sel2" size="2" maxlength="2" value="<?php echo $myrow["Sel2"]?>">
      
        <input type="Text" name="str02" size="2" maxlength="2" value="<?php echo $myrow["str02"]?>">
      </td>
		</tr> 

		</table>
		<input type="Submit" name="update" value="Update information">
	    </form>  
			<?php
		}
	else 
	{
	?>
	<html>
	<head>
	<title>Adjust Stock </title>
	
	<body>
 
	<h1>Enter Product No</h1>

	  <form  method="post" action="<?php echo $PHP_SELF?>"> 
	   <table border="0">
     
		 <tr>
       
	       <td><input name="id" type="text" size="70" maxlength="70"><br /></td>
	    </tr>
	 
	      <tr>
        <td colspan="2"><input type="submit" value="Register"></td>
      </tr>
	   </table>
	 </form>
	</body>
	</html>
	<?php
	} 
	 
		 }
	}
?>
<html>
	<head>
	<title>Stock Check mini</title>
	</head>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Cornelia Yoder
Cornelia Yoder
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
When you get to the point that you have trouble with sessions across subdomains, please post a new question and we can show you how to handle that issue, too.

Best regards, ~Ray