Welcome to WebmasterWorld Guest from 54.147.44.93

Forum Moderators: incrediBILL

Message Too Old, No Replies

Search form is not submitting

     

ksklos

5:28 pm on Jul 12, 2013 (gmt 0)



I have this search form with php script to retrieve the data being searched for. I am Google-learning html and php and got this code from someone else. I have adapted it to my needs and I don't think it is my adaptations. When I select the category and put in my criteria there appears to be no way to submit my inputs.


I need some help figuring out how to submit. Thanks for any help you can give.
Code:
<html>
<head>
<title>Member Lookup</title>
<style type="text/css">
table{
background-color: #FCF;
}
th{
width: 150px;
text-align: left;
}
</style>
</head>

<body>
<h1>Search Membership</h1>

<form method="post" action="Search2.php">
<input type="hidden" name="submitted" value="true" />

<label>Search Category:

<select name="category">
<option value="FName">First Name</option>
<option value="LName">Last Name</option>
<option value="City">City</option>
<option value="State">State</option>
<option value="ChapterName">Chapter Name</option>
<option value="ChapterNumber">Chapter Number</option>
</select>
</label>

<label>Search Criteria: <input type="text" name="criteria /></label>

<input type="submit" />

</form>

<?php

if (isset($_Post['submitted'])) {

//Connect to the database
$include('connect.php');

$category = $_Post['category'];
$criteria = $_Post['criteria'];
$query = "Select * FROM Member WHERE $category = '$criteria'";
$result = mysqli_query($dbcon, $query) or die('Could not connect');

echo "<table>";
echo "<tr><th>Member Number</th><th>First Name</th><th>Laast Name</th><th>Address</th><th>Address2</th><th>City</th><th>State</th><th>Zip</th><th>Phone</th><th>Chapter</th><th>Chapter Number</th></tr>";

while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){

echo "<tr><td>";
echo $row['MemberNumber'];
echo "</td><td>";
echo $row['FName'];
echo "</td><td>";
echo $row['LName'];
echo "</td><td>";
echo $row['Address'];
echo "</td><td>";
echo $row['Address2'];
echo "</td><td>";
echo $row['City'];
echo "</td><td>";
echo $row['State'];
echo "</td><td>";
echo $row['Zip'];
echo "</td><td>";
echo $row['Phone'];
echo "</td><td>";
echo $row['Chapter'];
echo "</td><td>";
echo $row['ChapterNumber'];
echo "</td></tr>";

}

echo "</table>";

}//end of main if statement

?>

</body>
</html>

DrDoc

7:18 pm on Jul 12, 2013 (gmt 0)

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Welcome to WebmasterWorld!

CaSe MaTtErS ... It's
$_POST
, not
$_Post

lucy24

8:40 pm on Jul 12, 2013 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



... and that's all assuming "Search2.php" (again, case sensitive) is the name of the file containing the form.

ksklos

10:09 pm on Jul 12, 2013 (gmt 0)



Search2.php is the correct page. I realize that case matters I just don't know what needs to be capitalized and what doesn't. I am still very new at this programming platform. Anyway, I found a missing " and once I corrected it and changed the Post to POST. I now have a submit button but am not getting any data back from the Mysql database. Again no error message, just nothing after the submit.

ksklos

1:35 am on Jul 13, 2013 (gmt 0)



I got it worked out. Thanks for your help.

incrediBILL

3:26 am on Jul 13, 2013 (gmt 0)

WebmasterWorld Administrator incredibill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Please share the solution to your problem for others to learn.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month