Jump to content

trouble connecting search textbox to database


iggy407

Recommended Posts

I have a textbox which i want users to be able to search the database for zipcodes, I can't seem to make it work my IDE doesn't show any errors but when I test the code everything goes blank, the mysql credentials are all correct the code is, any suggestions would help

 

<form action="index.php" method="post">

  <label for="search2" style="color:#FFF;background-color:#0A016D"><b>Search Homes by Zipcode</b></label><br>

zipcode:  <input type="text" name="zipcode"><br>

  <button type="submit" name="submit" value="submit"/>

  </form>

<?php

    $zipcode= @$_post['zipcode'];

    require("myconn.php");

    mysql_select_db("phplogin")or die(mysql_error());

  $sql= mysql_query("SELECT * FROM users WHERE zipcode='$zipcode' ");

  $numrow= mysql_num_rows($sql);

  while($row= mysql_fetch_assoc($sql))

  {

echo "zipcode: ".$row['zipcode']." city :".$row['city']."<br/>";

 

  }

  ?>

1) Remove the @ error suppression character from your code. That character, with limited exception has no place in code except when it's part of an email address.

 

2) There is no such variable as $_post, unless you've defined it yourself, but the error suppression is hiding the warning that would be generated. $_POST != $_post

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.