Jump to content
  • 0

[request]Script for insert item


Question

6 answers to this question

Recommended Posts

  • 0
Posted

<?php 
include "valida_session.php";
include "../useron.php";
?>
<title>add item </title>
<script language="javascript">
function checa_formulario(donate)
{
if (donate.idchar.value == "")
{ 
alert("Por Favor não deixe o campo ID char em branco!!!");
donate.idchar.focus();
return (false); 
}
if (donate.nqtd.value == "")
{ 
alert("Por Favor não deixe campo QTD em branco!!!");
donate.nqtd.focus();
return (false); 
}
}

</script>
<style type="text/css">
<!--
.style7 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; }
.style9 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; font-weight: bold; }
.style10 {
color: #FF6600;
font-weight: bold;
}
body {
background-image: url(imgs/box_bg.jpg);
}
-->
</style>
<body>
<form action="donate.php"  method="post" name="donate" onSubmit="return checa_formulario(this)">
  <p align="center"><img src="imgs/topo.jpg" width="703" height="98"></p>
  <table width="30%" border="0" align="center" cellpadding="0" cellspacing="3">
    <tr>
      <td colspan="2"><div align="center"><span class="style9">Inserir Item</span></div></td>
    </tr>
    <tr>
      <td colspan="2"><hr /></td>
    </tr>
    <tr>
      <td width="24%"><span class="style7">Id Char </span></td>
      <td width="76%"><input name="idchar" type="text" id="idchar" /></td>
    </tr>
    <tr>
      <td><span class="style7">Qtd </span></td>
      <td><input name="nqtd" type="text" id="nqtd" /></td>
    </tr>
    <tr>
      <td colspan="2"><hr /></td>
    </tr>
    <tr>
      <td><span class="style7">Local: </span></td>
      <td class="style7"><span class="style10">WareHouse</span></td>
    </tr>
    <tr>
      <td colspan="2"><hr /></td>
    </tr>
    <tr>
      <td colspan="2"><div align="center" class="style7">
        <input type="submit" name="Submit" value="Inserir Tickets" />
        <input name="item_id" type="hidden" id="item_id" value="9325" />
        <a href="logout.php">Logout</a></div></td>
    </tr>
  </table>
  
</form>
<br>
<br>
<center><b><font face=verdana color=red size=3>

</body>

</html>

 

Note

1° replace the item id of line 68 you want to insert the item

<input name="item_id" type="hidden" id="item_id" value="9325" />

 

.php

<meta http-equiv="refresh" content="3;URL=index.php">
<body background=imgs/box_bg.jpg></body><center>
<img src=imgs/topo.jpg width=703 height=98><br><br></center><br><br>
<? 
include "valida_session.php";
$ip="ip"; 
$user="sa";
$pass="pass";
$db="lin2world";

$conn=mssql_connect($ip,$user,$pass); 
mssql_select_db($db, $conn); 

$idchar = $_POST["idchar"];
$nqtd = $_POST["nqtd"];
$item_id = $_POST['item_id'];

$result = mssql_query("SELECT a-beep-t,item_id FROM user_item WHERE char_id = $idchar AND item_type = $item_id AND warehouse = 1");

$rows = mssql_num_rows($result);
$dba-beep-t = mssql_result($result, 0, 0);
$dbitemid = mssql_result($result, 0, 1);

$nqtd = $nqtd $dba-beep-t;

if ($dba-beep-t > 0) {
  mssql_query("UPDATE user_item SET a-beep-t = $nqtd WHERE item_id = $dbitemid");
  echo "<center><font face=verdana size=2 color=green>Tickets Entregues com sucesso!</font></center>";
}
else {
  mssql_query("INSERT INTO user_item (char_id, item_type, a-beep-t, enchant, eroded, bless, ident, wished, warehouse) values ($idchar,$item_id,$nqtd,0,0,0,0,0,1)"); 
  echo "<center><font face=verdana size=2 color=green>Tickets Entregues com sucesso!</font></center>";
}

$conn=mssql_close(); 

?> 

 

 

config.php

Ps. if only to protect the page you log

otherwise disregard the codes below

<?php
$conexao=mysql_connect("localhost","root","pass");
mysql_select_db("yourdb"); 

?>

 

valida session

<?php
include "config.php";
/*session_start();

if (empty($_SESSION["login"]) || empty($_SESSION["senha"])) {
header("Location:form_login.php");
}*/
session_start();
if (isset ($_SESSION["login_usuario"]) AND isset($_SESSION["senha_usuario"])) {
$login_usuario = $_SESSION["login_usuario"];
$senha_usuario = $_SESSION["senha_usuario"];
}
else{
echo '<center><font face=verdana size=2 color=#999999><BR><BR><BR><BR>Voce nao efetuou o login.<BR>';
echo '<font face=verdana size=2 color=#999999>Caso você ja seja cadastrado <a href=form_login.php>clique aqui</a> para entrar. <br><br><br><img src="images/bgadminsite.gif" />';
exit(); 
} 

if(!(empty($login_usuario) OR empty($senha_usuario))){
$resultado = mysql_query("select * from tbluser where login = '$_SESSION[login_usuario]'");
if (mysql_num_rows ($resultado) == 1) {
	if ($senha_usuario !=mysql_result($resultado, 0, "senha")){
		unset ($_SESSION["nome_usuario"]);
		unset ($_SESSION["senha_usuario"]);
		echo '<font face=verdana size=2 color=#999999>você não efetuou o login.<br><br><br><img src="images/bgadminsite.gif" />';
		exit();
	}
}
else{
	echo '<font face=verdana size=2 color=#999999>voce nao efetuou o login.<br><br><br><img src="images/bgadminsite.gif" />';
	exit();
}
}
mysql_close($conexao);
?>

 

login.php

<body background=imgs/box_bg.jpg></body><center>
<img src=imgs/topo.jpg width=703 height=98><br><br></center><br><br>
<?php 
include "config.php";
$login = $_POST["login"];
$senha = $_POST["senha"];
$senha=md5($senha);
$resultado = mysql_query("select * from tbluser where login = '$login'");
$linhas = mysql_num_rows($resultado);
if ($linhas ==0)
{
echo "Usuário não encontrado ";
echo "<a href=form_login.php>Logar</a>";
} else {
if ($senha != mysql_result ($resultado, 0, "senha")) 
{
	echo "Usuário não encontrado ";
	echo "<a href=form_login.php>Logar</a>";
}else{ 
session_start(); 
$_SESSION["login_usuario"] = $login;
$_SESSION["senha_usuario"] = $senha;


header("Location: index.php");
}
}
mysql_close($conexao);
?>

 

item added after restart

  • 0
Posted

Do you know what l2off in name category mean ? :P

If you asked me, yes I know, if you're so smart should have seen the script before you speak.

 

ps. mysql  only to validate session

  • 0
Posted

...

:P

you know that script will only work if the character is offline and hasn't logged in since the last server restart right?

Note!

Thank u for remember

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..