I have started work on a new project and it is basically a database site for the new MMO if you have heard of it SWTOR and basically I need a solution on making it go to the page linking to the text entered into the search bar. So what I mean is I really need it so if you search up something like Lightsaber it will take the user to the page about the Lightsaber.

Here is the code for my index page:

<html>

<head>

<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die                      ('Error connecting to 

mysql');

$dbname = 'archives';
mysql_select_db($dbname);
?> 



<font color="White" size="1">

<LINK href="style.css" rel="stylesheet" type="text/css">


<META name="description" content="SWTOR archives is a database packed full of information regarding 

weapons, equipment and many more items in Bioware's MMO Star Wars: The Old Republic.">

<META name="keywords" content="swtor, star wars, archives, jedi archives, star wars archives, jedi, 

mmo, mmorpg">

<br><br>
<center><img src="TOR_Logo.png" width="350" height="150"></center>

</head>

<body bgcolor="#000000">

<br><br><br><br>

<center>
<form action="http://localhost/search.php">

<INPUT type="text" size="50"> 
<br><br>
<INPUT type="submit" alt="Search the SWTOR database!" value="Search">

<div id="footer">

<p>



This site is in not endorsed by or affiliated with LucasArts, BioWare, or Electronic Arts.
Trademarks are the property of their respective owners. LucasArts, the LucasArts logo, STAR WARS and 

related properties are trademarks in the United States and/or in other countries of Lucasfilm Ltd. 

and/or its affiliates. © 2008-2010 Lucasfilm Entertainment Company Ltd. or Lucasfilm Ltd. All Rights 

Reserved. BioWare and the BioWare logo are trademarks or registered trademarks of EA International 

(Studio and Publishing) Ltd. You may not copy any images, videos or sound clips found on this site or 

deep link‟ to any image, video or sound clip directly.
Game content and materials copyright LICENSOR. All Rights Reserved.

</p>


</div>

</center>

</form>

</body>


</html>

Dani AI

Generated

A short, practical plan to make a search jump straight to the item page (for example: searching "Lightsaber" -> the Lightsaber page).

The flow: the search form should submit a named query parameter (GET is better for searches because results are bookmarkable/shareable). search.php reads and normalizes the query, tries an exact match against a precomputed slug (or a unique name) and, if found, issues a redirect to the canonical item URL. If no exact match, fall back to a results list (partial matches, ranked results, fuzzy suggestions). Use PDO or mysqli with prepared statements (do not use mysql_*), and always escape HTML on output.

A minimal server-side example (search.php) showing the exact-match -> redirect, then partial-match fallback:

<?php
// search.php (example)
$q = trim($_GET['q'] ?? '');
if ($q === '') { header('Location: /'); exit; }

$pdo = new PDO('mysql:host=localhost;dbname=archives;charset=utf8mb4', 'dbuser', 'dbpass', [
    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
]);

// try exact slug match first
$slug = preg_replace('/[^a-z0-9\-]+/i', '-', strtolower($q));
$stmt = $pdo->prepare('SELECT id, slug FROM items WHERE slug = :slug LIMIT 1');
$stmt->execute([':slug' => $slug]);
if ($item = $stmt->fetch(PDO::FETCH_ASSOC)) {
    header('Location: /item/' . $item['slug'], true, 302);
    exit;
}

// fallback: partial matches
$stmt = $pdo->prepare('SELECT id,name,slug FROM items WHERE name LIKE :like LIMIT 20');
$stmt->execute([':like' => '%' . $q . '%']);
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
// render results (simple example)
foreach ($results as $r) {
    echo '<a href="/item/' . htmlspecialchars($r['slug']) . '">' . htmlspecialchars($r['name']) . "</a><br>\n";
}

Practical tips and pitfalls:

  • Add a slug column (unique) to your items table and generate it on insert. Use slug for clean URLs and reliable exact matches.
  • For large catalogs use MySQL FULLTEXT or a search engine (Sphinx/Elasticsearch) for relevance and speed.
  • Security: prepared statements, charset=utf8mb4, htmlspecialchars() on output.
  • Common gotchas: input name must match what search.php reads; header('Location:') must run before any output; avoid hard-coded localhost in production; choose 301 vs 302 depending on permanence.

— your index and intent are clear. 's change toward a named input was the right move; prefer GET for shareable searches. — the above is the minimal, safe flow to implement.

Recommended Answers

All 2 Replies

Hi Friend

Please try the below thing, i don't know how helpful for you...

<html>

<head>
<LINK href="style.css" rel="stylesheet" type="text/css">
<META name="description" content="SWTOR archives is a database packed full of information regarding 

weapons, equipment and many more items in Bioware's MMO Star Wars: The Old Republic.">

<META name="keywords" content="swtor, star wars, archives, jedi archives, star wars archives, jedi, 

mmo, mmorpg">

<br><br>
<center><img src="TOR_Logo.png" width="350" height="150"></center>
<style>
.search form{display:block;position:relative;width:425px;margin:0 auto;}

.search input{width:100%;font-size:20px;color:black;padding:3px;margin:0;outline:0;border:1px solid #adadad;background:white url(/images/ui/form/input-textbox-bg.gif) repeat-x;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;}

.search input{-moz-box-shadow:0 1px 5px black;-webkit-box-shadow:0 1px 5px black;-o-box-shadow:0 1px 5px black;}

.search a{display:block;position:absolute;right:-3px;top:4px;width:24px;height:24px;background:url(/images/search.gif) 4px 4px no-repeat;}

.logo {display:block;cursor:default;width:261px;height:119px;margin:0 auto 10px auto;background:url(/images/TOR_Logo.png) no-repeat;}

.p {
	font-family:Verdana, Geneva, sans-serif; font-size:12px; color:#FFF; text-align:justify; margin:10px auto 10px auto; width:600px; }
	
</style>
</head>

<body bgcolor="#000000">

<div class="logo"></div>

<div class="search">
<form method="post" action="http://localhost/search.php">
<input autocomplete="off" name="q" type="text">
</form>

</div>
<div id="footer">

<div class="p">
This site is in not endorsed by or affiliated with LucasArts, BioWare, or Electronic Arts.
Trademarks are the property of their respective owners. LucasArts, the LucasArts logo, STAR WARS and 

related properties are trademarks in the United States and/or in other countries of Lucasfilm Ltd. 

and/or its affiliates. © 2008-2010 Lucasfilm Entertainment Company Ltd. or Lucasfilm Ltd. All Rights 

Reserved. BioWare and the BioWare logo are trademarks or registered trademarks of EA International 

(Studio and Publishing) Ltd. You may not copy any images, videos or sound clips found on this site or 

deep link‟ to any image, video or sound clip directly.
Game content and materials copyright LICENSOR. All Rights Reserved.

</div>


</div>

</body>


</html>

so what is your question?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.