I'm doing an IT inventory to register and I want to connect to the database, but it's giving this error:
Fatal error: Uncaught Error: Call to undefined function mysql_connect () in C: \ xampp \ htdocs \ xampp \ cadastrando.php: 9 Stack trace: # 0 {main} thrown in C: \ xampp \ htdocs \ xampp \ cadastrando.php on line 9
How could you resolve this error?
Below is my code.
HTML:
<form method="post" action="" onSubmit="">
<fieldset>
<legend>Sistema de Inventário</legend><br />
<label class="borda">Setor: </label>
<input class="form_inp" type="text" name="" size="30" required><br />
<label class="borda">Usuário:</label>
<input class="form_inp" type="text" id="" name="" size="30" required><br />
<label class="borda">O/S :</label>
<input class="form_inp" type="email" name="" size="30" required><br /><br />
<label class="borda">Hd : </label>
<input class="form_inp"type="text" name="" size="30" required><br />
<hr />
<label class="borda">Memória:</label>
<input class="form_inp" type="text" id="" name="" size="30" required><br />
<label class="borda">Processador: </label>
<input class="form_inp" type="text" id="" name="" size="30" required><br /><br />
<hr />
<label class="borda">Cd/Dvd: </label>
<select class="form_inp" name="Dados">
<option value="Sim">Sim</option>
<option value="Não">Não</option>
</select>
<br />
<label class="borda">Placa Mãe: </label>
<input class="form_inp" type="text" id="" name="" size="30" required><br />
<label class="borda">HostName: </label>
<input class="form_inp"type="text" id="" name="" size="30" required><br /><br />
<label class="borda">Monitor/Patrimônio/Marca/Modelo: </label>
<input class="form_inp" type="text" id="" name="" size="30" required><br />
<label class="borda">Nobreak/Patrimônio/Marca/: </label>
<input class="form_inp" type="text" id="" name="" size="30" required><br />
<label class="borda">Placa de Rede : </label>
<input class="form_inp" type="text" id="" name="" size="30" required><br />
<label class="borda">Placa de Vídeo: </label>
<input class="form_inp" type="text" id="" name="" size="30" required><br />
<hr />
<input type="submit" style="float: right;" value="Cadastrar" >
<input type="reset" style="float: right;" value="Limpar">
</fieldset>
php / bancodedados:
<html>
<head><title>Cadastrando...</title></head>
<body>
<?php
$host = "localhost";
$user ="roor";
$pass = "";
$banco = "cadastro";
$link = mysqli_connect("host", "user", "pass", "database");
mysqli_select_db($banco) or die (mysqli_error());
?>
<?php
$setor=$_POST['setor'];
$usuario=$_POST['usuario'];
$hd=$_POST['hd'];
$memoria=$_POST['memoria'];
$propressador=$_POST['processador'];
$cd=$_POST['cd'];
$placam=$_POST['placam'];
$host=$_POST['host'];
$monitor=$_POST['monitor'];
$nobreak=$_POST['nobreak'];
$placar=$_POST['placar'];
$placav=$_POST['placav'];
$sql=mysql_query("INSERT INTO setor(setor,usuario,hd,memoria,processador,cd,placam,host,monitor,nobreak,placar,plavav) VALUES('$setor,$usuario,$hd,$memoria,$processador,$cd,$placam,$host,$monitor,$nobreak,$placar,$placav'))");
?>
</body>
</html>