Jump to content

Need Help.


Selfish

Recommended Posts

Well, I'm a beginner at coding, and I wan't a seach thing. When I say that, I wan't something that when you type in their username, it goes to their profile.I was wondering if anybody could code me one, thanks.Also, if you do, it'll be going to my RPG which can be found here.Thanks, Selfish.

Link to comment
Share on other sites

Something like:

<form action="search.php" method="get"><input type="text" name="username" /></form>

$username = mysql_real_escape_string($_GET['username']);$id = implode(mysql_fetch_assoc(mysql_query("SELECT id FROM users WHERE username='$username'")));header("location:/forums/PokemonAtticRPG/profile.php?id=$id");

You just need to get the ID from the username entered and redirect - no "searching" necessary.

Link to comment
Share on other sites

Something like:
<form action="search.php" method="get"><input type="text" name="username" /></form>

$username = mysql_real_escape_string($_GET['username']);$id = implode(mysql_fetch_assoc(mysql_query("SELECT id FROM users WHERE username='$username'")));header("location:/forums/PokemonAtticRPG/profile.php?id=$id");

You just need to get the ID from the username entered and redirect - no "searching" necessary.

Thanks you so much, but this happened: http://www.punbb-hosting.com/forums/Pokemo.../page.php?id=12
Link to comment
Share on other sites

Guest FirefoxRocks

Assuming that each user has a unique username, you can do this:

<form action="search.php" method="get"><div> <input type="text" name="username"> <button type="submit">Search</button> </div></form>

<?php(string)$username = mysql_real_escape_string($_GET['username']);$con = mysql_connect("localhost", "database_user", "database_password");if(!mysql_select_db("database_name", $con)) { die("Error."); }$q = mysql_query("SELECT * FROM `users` WHERE `username`='$username'");if(is_resource($q)) {	(array)$user = mysql_fetch_assoc($q));	echo "<h1>{$user["username"]}</h1>";	// print out more details about the user here}else {	die("Error: ".mysql_error());}?>

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...