Jump to content

searching by users' personal information


silverglade

Recommended Posts

Hi, I want to have a page search by user entered personal information by a form. Right now I just have a huge form, where the user puts into the database all of his personal information, and then I want to be able to use the form or another form to echo out all users with the entered criteria. So if the searcher puts in for the Hobbies field "hunting" and the Likes field "John Lennon", the script will return all of the people who like both hunting for Hobbies OR john lennon for Likes. Please if anyone knows any google search terms for tutorials on this I would greatly appreciate it. Or advice on what I am doing wrong, because all the page does now is output this '

 

"000-000", which is a bogus date I think in the date field in database.

 

here is the sql dump.

 

- phpMyAdmin SQL Dump
-- version 2.8.0.1
-- http://www.phpmyadmin.net
-- 
-- Host: custsql-sl07.eigbox.net
-- Generation Time: Aug 28, 2011 at 01:44 PM
-- Server version: 5.0.91
-- PHP Version: 4.4.9
-- 
-- Database: `photo_artists`
-- 

-- --------------------------------------------------------

-- 
-- Table structure for table `images`
-- 

CREATE TABLE `images` (
  `image_id` bigint(20) unsigned NOT NULL auto_increment,
  `gallery_user` int(11) NOT NULL,
  `filename` varchar(255) NOT NULL,
  `mime_type` varchar(255) NOT NULL,
  `file_size` int(11) NOT NULL,
  `file_data` longblob NOT NULL,
  PRIMARY KEY  (`image_id`),
  UNIQUE KEY `image_id` (`image_id`),
  KEY `filename` (`filename`),
  KEY `gallery_user` (`gallery_user`)
) ENGINE=MyISAM AUTO_INCREMENT=38 DEFAULT CHARSET=latin1 AUTO_INCREMENT=38 ;


- Table structure for table `users`
-- 

CREATE TABLE `users` (
  `id` int(11) NOT NULL auto_increment,
  `status` varchar(20) NOT NULL,
  `lastname` varchar(50) NOT NULL,
  `dob` varchar(20) NOT NULL,
  `gender` varchar(10) NOT NULL,
  `username` varchar(20) NOT NULL,
  `password` varchar(60) NOT NULL,
  `email` varchar(20) NOT NULL,
  `activationkey` varchar(100) NOT NULL,
  `race` varchar(40) NOT NULL,
  `job` varchar(40) NOT NULL,
  `country` varchar(30) NOT NULL,
  `state` varchar(30) NOT NULL,
  `town` varchar(30) NOT NULL,
  `hobbies` mediumtext NOT NULL,
  `business` varchar(50) NOT NULL,
  `religion` varchar(40) NOT NULL,
  `social_groups` mediumtext NOT NULL,
  `political_groups` varchar(200) NOT NULL,
  `other_affiliations` varchar(200) NOT NULL,
  `buying` longtext NOT NULL,
  `selling` longtext NOT NULL,
  `links` varchar(100) NOT NULL,
  `likes` mediumtext NOT NULL,
  `dislikes` longtext NOT NULL,
  `firstName` varchar(30) NOT NULL,
  `zip` varchar(15) NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `username` (`username`),
  UNIQUE KEY `email` (`email`),
  UNIQUE KEY `activationkey` (`activationkey`)
) ENGINE=MyISAM AUTO_INCREMENT=56 DEFAULT CHARSET=latin1 AUTO_INCREMENT=56 ;

-- 
-- Dumping data for table `users`
-- 

INSERT INTO `users` VALUES (49, 'verify', '', '0000-00-00', '', 'joe', '32b3491336522e073489725b5daf298cd749007a', 'rlx1@aol.com', '34705256317118179901016541118525481318594628324', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '');
INSERT INTO `users` VALUES (55, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '');
INSERT INTO `users` VALUES (54, 'activated', '', '', '', 'derekv', 'e8ee80e34d93d48813b08949c07fc826a1c82b63', 'derek@hotmai', '206536188212612954985362234801657390262812961008', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '');

 

and here is my majorly large search criteria form LOL.

 

<?php 
$host		=  ";
$database 	= " ";
$username 	= " ;
$password 	= " ";
$tbl_name   = "users";
$conn = mysql_connect($host, $username, $password) or die("Could not connect: " . mysql_error());
mysql_select_db($database);
include('bouncer.php');


$first = $_POST['first'];
$last = $_POST['last'];
$dob = $_POST['dob'];
$gender = $_POST['gender'];
$ethnic = $_POST['ethnic'];
$country = $_POST['country'];
$state = $_POST['state'];
$town = $_POST['town'];
$zip = $_POST['zip'];
$email = $_POST['email'];
$job = $_POST['job'];
$business = $_POST['business'];
$religion = $_POST['religion'];
$social = $_POST['social'];
$political = $_POST['political'];
$affiliations = $_POST['affiliations'];
$buying = $_POST['buying'];
$selling = $_POST['selling'];
$likes = $_POST['likes'];
$dislikes = $_POST['dislikes'];
$links = $_POST['links'];


$currentUser = $_SESSION['myusername'];


/*UPDATE orders
SET quantity = '11',
Product = 'Hanging Files'
WHERE id = '1'
*/


/*USE photo_artists;*/


mysql_query ( "UPDATE users SET dob = '$dob', gender='$gender',  race='$ethnic', job='$job', country='$country', state='$state', town='$town', zip='$zip', hobbies='$hobbies', business='$business', religion='$religion', social_groups='$social', political_groups='$political', other_affiliations='$affiliations', buying='$buying', selling='$selling', links='$links', likes='$likes', dislikes='$dislikes' WHERE username='$currentUser'");

//THE SEARCH FUNCTION
$sql = "SELECT * FROM users WHERE dob  LIKE '%$dob%' OR gender LIKE '%$gender%' OR race  LIKE '%$ethnic%' OR job  LIKE '%$job%' OR country  LIKE '%$country%' OR state  LIKE '%$state%' OR town  LIKE '%$town%' OR zip  LIKE'%$zip%' OR hobbies  LIKE'%hobbies%' OR business  LIKE'%$business%' OR religion  LIKE'%$religion%' OR social_groups  LIKE '%$social%' OR political_groups  LIKE'%$political%' OR other_affiliations LIKE '%$affiliations%' OR  buying  LIKE '%$buying%' OR selling  LIKE '%$selling%' OR links  LIKE '%$links%' OR likes  LIKE '%$likes%' OR dislikes  LIKE'%$dislikes%'";


//run the quiery
$data = mysql_query($sql, $conn) or die(mysql_error());

if($_POST['dob']);
{
while ($result = mysql_fetch_array($data)) {


//giving names to the fields
$dob = $result['dob'];
$gender = $result['gender'];
$race = $result['race'];
$job = $result['job'];
$country = $result['country'];
$state = $result['state'];
$town = $result['town'];
$zip = $result['zip'];
$hobbies = $result['hobbies'];
$business = $result['business'];
$religion = $result['religion'];
$social = $result['social'];
$political = $result['political'];
$affiliations = $result['affiliations'];
$buying = $result['buying'];
$selling = $result['sellling'];
$links = $result['links'];
$likes = $result['likes'];
$dislikes = $result['dislikes'];

//put the results on the screen
echo "<br>$dob <br/> ";
echo ">$gender <br>";
echo "$job <br/>";
echo "$ocuntry <br/>";
echo "$state <br/>";
echo "$town <br/>";
echo "$zip <br/>";
echo "$hobbies <br/>";
echo "$business <br/>";
echo "$religion <br/>";
echo "$social <br/>";
echo "$political <br/>";
echo "$affiliations <br/>";
echo "$buying <br/>";
echo "$selling <br/>";
echo "$links <br/>";
echo "$likes <br/>";
echo "$dislikes <br/>";

}
}//end if


//This counts the number or results – and if there wasn’t any it gives a little message explaining that
$anymatches=mysql_num_rows($data);
if ($anymatches == 0)
{
echo "<h3>Results</h3>";
echo "<p>Sorry, your search: "" . $input . "" returned zero results</p>";
}
?>



<html>
<body>
<p>Login Successful</p>
<p> </p>
<p>

<form action="login_success2.php" method="post">
  <p>
    <input type="text" name="first" size="20" /> 
  First name<br />
    <input type="text" name="last" size="20" />
    Last name<br />
    <input name="dob" type="text" size="20" id="dob" />
    Date of Birth<br />
    <input type="text" name="gender" size="20" id="gender" />
  Gender <br />
  <input type="text" name="ethnic" size="20" id="ethnic" />
  Ethnicity
  <br />
  <input type="text" name="country" size="20" id="country" />
  Country<br />
  <input type="text" name="state" size="20" id="state" />
  State<br />
    <input type="text" name="town" size="20" id="town" />
    Town<br />
<input type="text" name="zip" size="20" id="zip" />
  Zip Code<br />
  <br />
    <input type="text" name="email" size="40" id="email" />
    Email<br />
<textarea name="job" cols="40" id="job"></textarea>
  Job<br />
    <textarea name="business" cols="40" id="business"></textarea>
    Business<br />
    <input type="text" name="religion" size="60" id="religion" />
  Religion</p>
  <p><br />
    <textarea name="social" cols="100" id="social"></textarea>
    Social Groups<br />
    <textarea name="political" cols="100" id="political"></textarea>
    Political groups<br />
    <textarea name="affiliations" cols="100" id="affiliations"></textarea>
    Other Affiliations<br />
    <textarea name="buying" cols="100" id="buying"></textarea>
    Items I am buying<br />
    <textarea name="selling" cols="100" id="selling"></textarea>
    Items I am selling<br />
    <textarea name="likes" cols="100" id="likes"></textarea>
    My likes <br />
    <textarea name="dislikes" cols="100" id="dislikes"></textarea>
    My dislikes <br />
    <textarea name="links" cols="100" id="links"></textarea>
    My links <br />
    <input type="submit" value="Store in database and search" />
    <input type="reset" value="Reset fields" />
  </p>
  </p>
</form> 








<p><a href="index.php">HOME</a></p>
<p> </p>
</body>
</html>

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.