playersearch.php script

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
Lady Kverem
Forum Newbie
Posts: 1
Joined: Wed Apr 16, 2003 8:52 am
Location: Saint John, New Brunswick Canada
Contact:

playersearch.php script

Post by Lady Kverem »

Quick question for anyone out there...

I presently run a php-nuke based website,

http://www.impossible-realities.net

I am looking to have a search area where people can submit their names and gaming information on what types of games they play.. (such as specific RPG games, Tabletop war games...etc) I was curious to know if there was anyone who had a script of the sort??

There is one on rpgregistry.com that's pretty sweet.

I'm not very good at programming or I'd do it myself :/

Thanks

Melissa
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Have you looked at hotscripts.com?

Mac
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

That's a pretty basic script, it shouldn't be too difficult to program:

Code: Select all

<form action="page2.php" method="post">
     <input type=text name="Arrayїname]" value="">
     <input type=text name="Arrayїage]" value="">
     <input type=text name="Arrayїlocation]" value="">
     <input type=text name="Arrayїgames]" value="">
     <input type=text name="Arrayїbio]" value="">
    <br>
     <input type="submit" name="submit" value="Submit">
    <br>
    <br>
</form>

Code: Select all

<?php
/*
This page will handle the form 
*/

if ($submit){
//trim the incoming data
$Array[name] = trim($Array["name"]); // name of user
$Array[age] = trim($Array["age"]); // user age
$Array[location] = trim($Array["location"]); // user location
$Array[games] = trim($Array["games"]); // list of games
$Array[bio] = trim($Array["bio"]); // short bio
$Array[ip] = $REMOTE_ADDR; // user ip for logging

// setting variables for DB access
$host = ""; // host, usualy localhost
$user = ""; // username of host
$pass = ""; // password of host
$db = ""; // database name
$table = ""; // table name inside the db

// connecting to the database
$link = mysql_connect ($host, $user, $pass);

// the database query
$query = "INSERT into $table values ('0', '$Array[name]', '$Array[age]', '$Array[location]', '$Array[games]', '$Array[bio]', '$Array[ip]')";

// checking if the database insertion was successful
if (mysql_db_query ($db, $query, $link)) {

	echo "<center><u>Successful!</u>";

	} else {
	
                echo "<center>This query was <u>NOT</u> entered into the database!";
	
} // ending db query if statement

// closing the database connection
mysql_close ($link)

} // ending $submit if statement
?>

Code: Select all

# This is what the SQL part of this should look like
#
# Table structure for table `members`
#

CREATE TABLE members (
  id int(8) NOT NULL auto_increment,
  name tinytext NOT NULL,
  age tinytext NOT NULL,
  location tinytext NOT NULL,
  games tinytext NOT NULL,
  bio tinytext NOT NULL,
  ip tinytext NOT NULL,
  PRIMARY KEY  (id)
) TYPE=MyISAM;
It's totally untested so if i screwed up, post it. :wink:

Enjoy. 8)
Post Reply