fixing the search, now does it for full name or username, not complete just yet
This commit is contained in:
8
var/www/nameSearch.php
Normal file
8
var/www/nameSearch.php
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
First Name is <?php echo $_POST["fname"]; ?><br>
|
||||||
|
Last Name is <?php echo $_POST["lname"]; ?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -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>
|
||||||
|
|
||||||
|
|||||||
7
var/www/usernameSearch.php
Normal file
7
var/www/usernameSearch.php
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
Username is <?php echo $_POST["username"]; ?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user