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/>";

 

  }

  ?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.