Reputation: 1926
Data inside my form will not send to search.php
.
<form class="form-search" action="search.php" method="get">
<input type="text">
<button type="submit">Search</button>
</form>
// search.php
<h2>Searched <?php print $_GET['username']; ?>; Returned 5 Results from Query.</h2>
Notice: Undefined index: username in C:\xampp\htdocs\Web\Statistics\search.php on line 40
Therefore, the data was not set in $_GET
.
Upvotes: 0
Views: 142
Reputation: 3160
your form should look like
<form class="form-search" action="search.php" method="get">
<fieldset>
<input type="text" name="username" placeholder="Username" id="username" class="input-medium search-query">
<button type="submit" id="srchUser" class="btn">Search</button>
</fieldset>
</form>
I've added to your input name="username"
so it can send get variables to php by using the name attribute in input items
Upvotes: 0
Reputation: 773
You need to add a name to the input
<input type="text" name='username' placeholder="Username" id="username" class="input-medium search-query">
$_GET works based on the Input name not the ID. Name is passed when you press submit, ID just identifies the input on the page.
Upvotes: 1
Reputation: 590
You need name="username" in addition to all of the other attributes you've specified.
Upvotes: 0