-
Notifications
You must be signed in to change notification settings - Fork 0
/
reg_chegada.php
91 lines (73 loc) · 3.28 KB
/
reg_chegada.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
require_once "config.php";
require_once "menu.php";
$id = null;
if ( !empty($_GET['id'])) {
$id = $_REQUEST['id'];
}
if ( null==$id ) {
header("Location: index.php");
}
if ( !empty($_POST)) {
// keep track validation errors
$codError = null;
$tempoError = null;
// keep track post values
$cod = $_POST['cod'];
$tempo = $_POST['tempo'];
// validate input
$valid = true;
$result = mysqli_query($con, "select * from inscricao where etapa_idetapa=$id and numero=$cod");
if ( (empty($cod) ) or (mysqli_num_rows($result)==0) ){
$codError = 'Inscrição inválida';
$valid = false;
}
if (empty($tempo)) {
$tempoError = 'Tempo não informado';
$valid = false;
}
// insert data
if ($valid) {
mysqli_query($con, "UPDATE inscricao SET tempo='$tempo' where numero='$cod' and etapa_idetapa='$id'");
echo "<script>alert('Cadastro efetuado com sucesso.');</script>";
echo "<meta http-equiv='refresh' content='0, url=./reg_chegada.php?id=$id'>";
}
}
?>
<html lang="en">
<body>
<div class="container">
<div class="span10 offset1">
<div class="row">
<h3 align="center">Registro de Chegada - PROVA LONGA</h3>
<br>
<br>
</div>
<form class="form-horizontal" action="reg_chegada.php?id=<?php echo $id?>" method="post">
<div class="control-group <?php echo !empty($codError)?'error':'';?>">
<label class="control-label">Inscrição</label>
<div class="controls">
<input style="min-height:35px;" name="cod" type="text" autofocus placeholder="Número de Inscrição"value="<?php echo !empty($cod)?$cod:'';?>">
<?php if (!empty($codError)): ?>
<span class="help-inline"><?php echo $codError;?></span>
<?php endif; ?>
</div>
</div>
<div class="control-group <?php echo !empty($tempoError)?'error':'';?>">
<label class="control-label">Tempo</label>
<div class="controls">
<input style="min-height:35px;" name="tempo" type="text" class="time" placeholder="tempo" value="<?php echo !empty($tempo)?$tempo:'';?>">
<?php if (!empty($tempoError)): ?>
<span class="help-inline"><?php echo $tempoError;?></span>
<?php endif; ?>
</div>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-success">Registrar</button>
<a class="btn" href="index.php">Back</a>
</div>
</form>
</div>
</div> <!-- /container -->
</body>
</html>