Jump to content

php coding for search form


h4r00n

Recommended Posts

Hi,

 

I have created a form in Dreamweaver and connected mySQL database to it. I am having great trouble in creating a script for it. I have found many on the internet but just cannot get my head around it. The php code I have so far is:

 

<?php

$username = "root";

$password = "";

$hostname = "localhost";

$dbh = mysql_connect($hostname, $username, $password)

or die("Unable to connect to MySQL");

print "Connected to MySQL<br>";

$selected = mysql_select_db("jobjar",$dbh)

or die("Could not select jobjar");

?>

 

and I have attached a print screen of my form and what it looks like when previewed in firefox... can anyone help?

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/171521-php-coding-for-search-form/
Share on other sites

Hi, I have the following code:

<?php

 

//get data

$button = $_GET['submit'];

$search = $_GET['search'];

 

if (!$button)

echo "You didn't submit a keyword.";

else

{

if (strlen($search)<=2)

echo "Search term too short.";

else

{

echo "You searched for <b>$search</b><hr size='1'>";

}

}

 

?>

 

but keep getting an error where I have bolded the above text... any help/

Archived

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

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