fixing the search, now does it for full name or username, not complete just yet

This commit is contained in:
Bryan
2019-11-25 03:17:21 -05:00
parent 7728958a94
commit 235c55285d
3 changed files with 44 additions and 18 deletions

8
var/www/nameSearch.php Normal file
View File

@@ -0,0 +1,8 @@
<html>
<body>
First Name is <?php echo $_POST["fname"]; ?><br>
Last Name is <?php echo $_POST["lname"]; ?>
</body>
</html>

View File

@@ -10,21 +10,24 @@ body {
<h2><font color="white">Who would you like to search for</h2> <h2><font color="white">Who would you like to search for</h2>
<?php <?php
$name = $message = ""; $name = $fname = $lname = "";
$nameErr = $fnameErr = $lnameErr = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"])) { if (empty($_POST["name"])) {
$name = ""; $nameErr = "Name is required";
} else { }
$comment = test_input($_POST["name"]); else {
$name = test_input($_POST["name"]);
if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
$nameErr = "Only letters and white space allowed";
}
} }
if (empty($_POST["Message"])) {
$message = "";
} else {
$message = test_input($_POST["message"]);
}
} }
function test_input($data) { function test_input($data) {
@@ -35,16 +38,24 @@ function test_input($data) {
} }
?> ?>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <form method="post" action="usernameSearch.php">
Which Search: Username: <br><input type="text" name="username"><br>
<input type="radio" name="type" <?php if (isset($type) && $gender=="name") echo "checked";?> value="type">Name <input type="submit">
<input type="radio" name="type" <?php if (isset($type) && $gender=="username") echo "checked";?> value="type">Username
<br><br>
Search Key: <br><input type="text" name="name" value="<?php echo $name;?>">
<br><br>
<input type="submit" name="submit" value="Submit">
</form> </form>
<br>
<form action="nameSearch.php" method="post">
First Name: <input type="text" name="fname"><br>
Last Name: <input type="text" name="lname"><br>
<input type="submit">
</form>
<?php
echo $name;
echo "<br>"
?>
</body> </body>
</html> </html>

View File

@@ -0,0 +1,7 @@
<html>
<body>
Username is <?php echo $_POST["username"]; ?>
</body>
</html>