-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test PHP.php
41 lines (35 loc) · 1.17 KB
/
Test PHP.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
<?php
$servername = "your_server";
$username = "your_username";
$password = "your_password";
$dbname = "your_database";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$username = $_POST['username'];
$sql = "SELECT * FROM users WHERE username = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("s", $username);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
// Fetch options (for example purposes, we'll just list some static options)
echo '<div class="form-group">
<label for="option">Options:</label>
<select class="form-control" id="option" name="option">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
</div>';
} else {
echo '<p>No user found with that username.</p>';
}
$stmt->close();
}
$conn->close();
?>