Please i need to create an advance form for my website. Is there a link ou website where i can find tutorials on it..
16 Replies - 809 Views - Last Post: 24 August 2011 - 06:06 PM
Replies To: Advanced Form.
#2
Re: Advanced Form.
Posted 24 August 2011 - 04:08 PM
Hi,
What exactly is an "advance form"? What are you looking for it to do? What have you tried thus far?
What exactly is an "advance form"? What are you looking for it to do? What have you tried thus far?
#3
Re: Advanced Form.
Posted 24 August 2011 - 04:15 PM
Ok this is what i am trying to do:
I have a form that will enable people to search for there desired property based on different criteria. The form is working.. and the search is working as well but the problem is that if a user does not fill in all the details in the form , it wont work. So i am looking for a way to modify the search so that it can retrieve information's even when a user decides to skip some of its fields or even when the fields are empty.
Here is the code:
Here is the code for the form:
And here is the property_search.php
I have a form that will enable people to search for there desired property based on different criteria. The form is working.. and the search is working as well but the problem is that if a user does not fill in all the details in the form , it wont work. So i am looking for a way to modify the search so that it can retrieve information's even when a user decides to skip some of its fields or even when the fields are empty.
Here is the code:
Here is the code for the form:
<?php
//include PHP script with MySQL parameters defined
require "database.php";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Property Search</title>
<!-- Link to our style sheets-->
<link rel="stylesheet" type="text/css" href="css/search.css">
</head>
<body>
<form name="search" method="post" action="property_search.php" onsubmit="return validate();">
<table>
<tr>
<th colspan="2" style="font-size:20px" > Quick Search </th>
</tr>
<!--location of the property-->
<tr style="height:50px">
<th>Location: </th>
<td>
<?php
$query = "SELECT DISTINCT State FROM Property_Details ORDER BY State ASC";
$result = mysql_query($query);
echo "<select name=state>";
echo "<option value=\"\">--Choose--</option>";
// printing the list box select command
while($row = mysql_fetch_assoc($result))
{//Array or records stored in $nt
echo "<option value=\"".$row['State']."\">".$row['State']."</option>";
/* Option values are added by looping through the array */
}
echo "</select>";
?>
</td>
</tr>
<!--property_type(Menu to choose weather the property is for sale or to rent-->
<tr style="height:50px">
<th>Type: </th>
<td>
<?php
$query = "SELECT DISTINCT Property_Type FROM Property_Details ORDER BY Property_Type ASC";
$result = mysql_query($query);
echo "<select name=propertyType>";
echo "<option value=\"\">--Choose--</option>";
// printing the list box select command
while($row = mysql_fetch_assoc($result))
{//Array or records stored in $nt
echo "<option value=\"".$row['Property_Type']."\">".$row['Property_Type']."</option>";
/* Option values are added by looping through the array */
}
echo "</select>";
?>
</td>
</tr>
<!--Property Category(Menu to choose weather the property is for Flat, Bungalow etc-->
<tr style="height:50px">
<th>Category: </th>
<td>
<?php
$query = "SELECT DISTINCT Property_Category FROM Property_Details ORDER BY Property_Category ASC";
$result = mysql_query($query);
echo "<select name=propertyCatagory>";
echo "<option value=\"\">--Choose--</option>";
// printing the list box select command
while($row = mysql_fetch_assoc($result))
{//Array or records stored in $nt
echo "<option value=\"".$row['Property_Category']."\">".$row['Property_Category']."</option>";
/* Option values are added by looping through the array */
}
echo "</select>";
?>
</td>
</tr>
<tr style="height:50px">
<th>Rooms: </th>
<td>
<?php
$query = "SELECT DISTINCT Number_Of_Rooms FROM Property_Details ORDER BY Number_Of_Rooms ASC";
$result = mysql_query($query);
echo "<select name=no_of_rooms>";
echo "<option value=\"\">Min No.of Rooms</option>";
// printing the list box select command
while($row = mysql_fetch_assoc($result))
{//Array or records stored in $nt
echo "<option value=\"".$row['Number_Of_Rooms']."\">".$row['Number_Of_Rooms']."</option>";
/* Option values are added by looping through the array */
}
echo "</select>";
?>
<?php
$query = "SELECT DISTINCT Number_Of_Rooms FROM Property_Details ORDER BY Number_Of_Rooms ASC";
$result = mysql_query($query);
echo "<select name=no_of_rooms_2>";
echo "<option value=\"\">Max No.of Rooms</option>";
// printing the list box select command
while($row = mysql_fetch_assoc($result))
{//Array or records stored in $nt
echo "<option value=\"".$row['Number_Of_Rooms']."\">".$row['Number_Of_Rooms']."</option>";
/* Option values are added by looping through the array */
}
echo "</select>";
?>
</td>
</tr>
<tr style="height:50px">
<th>Bathrooms: </th>
<td>
<?php
$query = "SELECT DISTINCT Number_Of_Bathrooms FROM Property_Details ORDER BY Number_Of_Bathrooms ASC";
$result = mysql_query($query);
echo "<select name=no_of_br>";
echo "<option value=\"\">Mini No.of Baths</option>";
// printing the list box select command
while($row = mysql_fetch_assoc($result))
{//Array or records stored in $nt
echo "<option value=\"".$row['Number_Of_Bathrooms']."\">".$row['Number_Of_Bathrooms']."</option>";
/* Option values are added by looping through the array */
}
echo "</select>";
?>
<?php
$query = "SELECT DISTINCT Number_Of_Bathrooms FROM Property_Details ORDER BY Number_Of_Bathrooms ASC";
$result = mysql_query($query);
echo "<select name=no_of_br_2>";
echo "<option value=\"\">Max No.of Baths</option>";
// printing the list box select command
while($row = mysql_fetch_assoc($result))
{//Array or records stored in $nt
echo "<option value=\"".$row['Number_Of_Bathrooms']."\">".$row['Number_Of_Bathrooms']."</option>";
/* Option values are added by looping through the array */
}
echo "</select>";
?>
</td>
</tr>
<tr style="height:50px">
<th>Price: </th>
<td>
<?php
$query = "SELECT DISTINCT Property_Price FROM Property_Details ORDER BY Property_Price ASC";
$result = mysql_query($query);
echo "<select name=price>";
echo "<option value=\"\">Minimum Price</option>";
// printing the list box select command
while($row = mysql_fetch_assoc($result))
{//Array or records stored in $nt
echo "<option value=\"".$row['Property_Price']."\">".$row['Property_Price']."</option>";
/* Option values are added by looping through the array */
}
echo "</select>";
?>
<?php
$query = "SELECT DISTINCT Property_Price FROM Property_Details ORDER BY Property_Price ASC";
$result = mysql_query($query);
echo "<select name=price_2>";
echo "<option value=\"\">Maximun Price</option>";
// printing the list box select command
while($row = mysql_fetch_assoc($result))
{//Array or records stored in $nt
echo "<option value=\"".$row['Property_Price']."\">".$row['Property_Price']."</option>";
/* Option values are added by looping through the array */
}
echo "</select>";
?>
</td>
</tr>
<tr>
<td colspan="2">
<button type="search" name="submit"> Search </button>
<button type="reset" value="Reset" />Clear </button>
</td>
</tr>
</table>
</form>
</body>
</html>
And here is the property_search.php
<?php
//include PHP script with MySQL parameters defined
require "database.php";
?>
<html>
<head>
<!-- title of our web page-->
<title>Search For Property</title>
<!--***The W3C validator like the encoding and content-type specified.-->
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<!-- Link to our style sheets-->
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" type="text/css" href="css/property.css">
</head>
</body>
<!-- include the file for the top Navigation-->
<?php include("topnav.html"); ?>
<div id="properties">
<?php
//include PHP script with MySQL parameters defined
require "database.php";
//This gets all the other information from the form
$state=$_POST['state'];
$propertyType=$_POST['propertyType'];
$property_catagory=$_POST['propertyCatagory'];
$no_of_rooms=$_POST['no_of_rooms'];
$no_of_rooms_2=$_POST['no_of_rooms_2'];
$no_of_br=$_POST['no_of_br'];
$no_of_br_2=$_POST['no_of_br_2'];
$price=$_POST['price'];
$price_2=$_POST['price_2'];
// compose SQL query and execute
$query=" SELECT * FROM Property_Details WHERE State='$state'
AND Property_Type='$propertyType'
AND Property_Category='$property_catagory'
AND Number_Of_Rooms BETWEEN '$no_of_rooms' AND '$no_of_rooms_2'
AND Number_Of_Bathrooms BETWEEN '$no_of_br' AND '$no_of_br_2'
AND Property_Price BETWEEN '$price' AND '$price_2' ORDER BY Date DESC";
$result=mysql_query($query,$link);
//
// process query result
//
if ($result==null)
{
echo "No property found.<br>\n";
}
else {
//generate table of properties.
print "<table class=\"thin-outline\">\n";
while ($row=mysql_fetch_array($result))
{
print "<tr>";
print "<td colspan=\"2\" style=\"font-style:italic;font-weight: bold; font-size:25px\">" .$row["State"]. "</td>";
print "<td style=\"font-style:italic;font-weight: bold; font-size:25px\">".$row["Property_Price"]."</td>";
print "</tr>";
print "<tr>";
print "<td><a href=\"propertyDetails.php?id=".$row["Property_Id"]."\"><img src='Images/properties/".$row["Img1"]."'
style=\"border-right-style: solid; border-right-width: 5px; border-right-color: #000; border-bottom-style: solid;
border-bottom-width: 5px; border-bottom-color: #000; margin-right: 1em; margin-bottom: 1em; width:300px; height:150px\"/>
</td>";
print "<td style=\"font-weight: bold\">" .$row["Property_Category"] ."\n<p>"
.$row["Property_Description"].
"</td>";
//generate a hyperlink with the correct parameter
print "<td style=\"font-style:italic;font-weight: bold; font-size:18px\">";
print "<ul>";
print "<li> <a href=\"propertyDetails.php?id=".$row["Property_Id"]."\">More Details</a> </li>";
print "<li> <a href=\"contact_us.html\">Contact Agent</a> </li>";
print "</ul>";
print "</td>";
print "</tr>\n";
}
print "</table>\n";
}
mysql_close($link);
?>
</div>
<!-- include the file for the footer-->
<?php include("footer.html"); ?>
#5
Re: Advanced Form.
Posted 24 August 2011 - 04:31 PM
Just checked that link there was nothing in it...That has to do with my question.
#6
Re: Advanced Form.
Posted 24 August 2011 - 04:37 PM
Hmmm, Pls one question...I ASKED FOR SOMEONE TO GIVE ME A LINK TO LEARN AND PEOPLE ARE JUST THERE MESSING AROUND WITH MY REPUTATION. IS THERE ANYTHING WRONG WITH LEARNING OR DID I ASK ANYONE TO CODE FOR ME?
#7
Re: Advanced Form.
Posted 24 August 2011 - 05:43 PM
You apparently don't understand why I posted that link. In the next post you write, I want you to read the text inside the text area where you write your response. The reason you're being down repped is because you're violating one of the most important rules, we don't write code for you. Rudi tried to help you, but you still were wanting code. We help you, we don't do it for you.
#8
Re: Advanced Form.
Posted 24 August 2011 - 05:46 PM
But what i asked for on this particular post is a link to learn. So is that against your rules too?
#9
Re: Advanced Form.
Posted 24 August 2011 - 05:49 PM
#10
Re: Advanced Form.
Posted 24 August 2011 - 05:50 PM
Actually what Rudi was telling me in that post was not what i wanted to do, so i needed to clarify things. And if i might ask why are you bring that issue in here? This is a different post and should be treated differently.
#11
Re: Advanced Form.
Posted 24 August 2011 - 05:53 PM
Did you not read my post? just before
#12
Re: Advanced Form.
Posted 24 August 2011 - 05:56 PM
Yeah aaron1178 I just saw it..Thx for the link...
#13
Re: Advanced Form.
Posted 24 August 2011 - 05:57 PM
Hint- take a look at the isset() function. If the user skips a field (ie., the field in the $_POST or $_GET superglobal isn't set), don't include it in the query. Also, you should take a look at PDO over the deprecated mysql_*() family of functions. PDO uses prepared statements, which are immune to SQL Injection.
#14
Re: Advanced Form.
Posted 24 August 2011 - 06:03 PM
Quote
I would also suggest using PDO like Mac said, but that would require OO PHP knowledge.
Not much, in all honesty. If you can instantiate an object and invoke a method from it, then you're good. It's maybe a couple minor syntax things. That's it.
Also, let's keep things on-topic here and leave the rule enforcing to the moderation team please.
#15
Re: Advanced Form.
Posted 24 August 2011 - 06:05 PM
lol, the post you deleted also had the answer to his question
. You could have at least kept that part. I don't mind though.
|
|

New Topic/Question
Reply



MultiQuote









|