-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreg.php
More file actions
51 lines (44 loc) · 1.25 KB
/
reg.php
File metadata and controls
51 lines (44 loc) · 1.25 KB
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
<?php
/*
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database_name";
*/
if (isset($_POST['submit_btn'])) {
$username = $_POST['name'];
$password = $_POST['pwd'];
$text = $username . " " . $password . "\n";
$fp = fopen('/home/magic/Documenti/LabUni/SAW/', 'a+');
if (!preg_match('/^[a-zA-Z_]+$/', $username)) {
echo "Only letters and _ are allowed for username";
fclose($fp);
return;
}
else if (!preg_match('/^[a-zA-Z0-9&$@]+$/', $password)) {
echo "Puntuation characters are not allowed";
fclose($fp);
return;
}
else
{
if (fwrite($fp, $text)) {
echo 'saved';
}
fclose($fp);
/*
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: ". $conn->connect_error);
}
$sqlquery = "INSERT INTO table VALUES ($username, $password)";
if ($conn->query($sql) === TRUE) {
echo "dato inserito";
}
else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
*/
}
}
?>