hi my name is shaz and m a student.....i am design a website where i can search for house.... example house type,no of bedrooms, price and are... my databse is in sql and i am using php language.....i need little healp with the search form validation in javascript.... can anybody help in this...... what i am looking for is how can i do form validation in javascript when i click submit php should retive data from mysql..... thanks
I didn't understand the exact nature of validation you require. Kindly explain a bit more. Do you want to check/match the data with the server before submitting the form?
hi basically i have a form which is in php and i want to do a form validation in javascript and when we click on submit i want php to show the result which is in mysql...i mean my database is in mysql...... i hope that helps
Thats very easy dude! I hope you know how to connect to a database with PHP, and brief me about the type of fields you want to validate, and the structure of the form. Validation using JavaScript and returning results from the MySQL databse, both are fairly simple to implement. Checkout the PHP and JavaScript forums, you'll find a lot of threads on form validation and database connectivity,retrieval.In case that doesn't help you, let me know, and also post your code snippet.
hi pradeep.i havent done the coding as i am new in javascript and php...m still working on it..... my forum is sumthing like this its a search form (they all are drop down menu) Maximum price, minimum price, number of bedrooms, type of property or land, post code this is whre u type post code) city this is where u type city) region this is where u type region) when i click on search it should validate the form and then retrives data frpm mysql through php i have read a book on how to retrive mysql through php will work on it soon. thanks alot for u help
hi pardeep how are u sorry for botherin u again.. i tried alot but i failed..... first of all i have got an idea how to validate a form with javascript but the probelm is how can i retrieve data from mysql using php..and what method i am suppose to use.... second thing if i want to install php pr mysql how can i do that .... thanks alot shaz
Hi, Nice to hear from you. You can install both PHP and MySQL on your PC, to run PHP you'll need a webserver like IIS or Apache. You can get Apache from http://httpd.apache.org/ , IIS comes with Windows and MySQL from http://dev.mysql.com/downloads/. Detailed installation instructions will be provided at the sites.
what is ISS and second thing when i am tryin to safe my php file.it is cumin as text file...whats the reason is it because i havent got ISS or there is sumthing which i am not doing
Its not ISS, its IIS (Internet Information Server) which is a web server and comes with Windows.To run php scrips u need to have PHP installed and configured for the web server.
hay pardeep how u doing what u up 2.....i ahve written the codes but there seems to be sum problem. can u check please... thanks alot shaz HTML: <html> <head> <title>Search Form</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> body { font-family: Arial, Helvetica, sans-serif; font-size: 12px; } .box { font-family: Arial, Helvetica, sans-serif; font-size: 12px; border: 1px solid #000000; } .bluebox { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bolder; color: #FFFFFF; background-color: #006699; border: 1px solid #000000; } .maincell { font-family: Arial, Helvetica, sans-serif; font-size: 12px; padding: 5px; border: 1px solid #006699; } .errmsg { font-family: "Courier New", Courier, mono; font-size: 12px; font-weight: bolder; color: #CC0000; } </meta> </style> <script language="JavaScript"> function checkForm() { var ccity, carea, cpostcode, cminprice, cmaxprice; with(window.document.searchform) { ccity = city; carea = area; cpostcode = postcode; cminprice = minprice; cmaxprice = maxprice; } if(trim(ccity.value) == '') { alert('Please enter city'); ccity.focus(); return false; } else if(trim(carea.value) == '') { alert('Please enter area'); carea.focus(); return false; } else if(trim(cpostcode.value) == '') { alert('Please enter postcode'); cpostcode.focus(); return false; } else if(trim(cminprice.value) == '') { alert('Please enter minimum price'); cminprice.focus(); return false; } else if(trim(cmaxprice.value) == '') { alert('Please enter maximum price'); cmaxprice.focus(); return false; } else { ccity.value = trim(ccity.value); carea.value = trim(carea.value); cpostcode.value = trim(cpostcode.value); cminprice.value = trim(cminprice.value); cmaxprice.value = trim(cmaxprice.value); return true; } } /* Strip whitespace from the beginning and end of a string Input : a string */ function trim(str) { return str.replace(/^\s+|\s+$/g,''); } </script> </head> <body> <?php $errmsg = ''; // error message $city = ''; // city $area = ''; // area $postcode = ''; // postcode $minprice = ''; // minprice $maxprice = ''; // maxpricewebsite development if(isset($_POST['send'])) { $city = $_POST['city']; $area = $_POST['area']; $postcode = $_POST['postcode']; $minprice = $_POST['minprice']; $maxprice = $_POST['maxprice']; if(trim($city) == '') { $errmsg = 'Please enter city'; } else if(trim($area) == '') { $errmsg = 'Please enter area'; } else if(trim($postcode) == '') { $errmsg = 'Please enter postcode'; } else if(trim($minprice) == '') { $errmsg = 'Please enter minimum price'; } else if(trim($maxprice) == '') { $errmsg = 'Please enter maximum price'; } if($errmsg == '') { if(get_magic_quotes_gpc()) { $minprice = stripslashes($minprice); $maxprice = stripslashes($maxprice); } ?> <?php } } if(!isset($_POST['send']) || $errmsg != '') { ?> <div align="center" class="errmsg"><?=$errmsg;?></div> <form action= "http://mudfoot.doc.stu.mmu.ac.uk/students/shaikhs/searchform2.php" method="post" name="searchform" id="searchform"> <table width="500" border="0" align="center" cellpadding="2" cellspacing="1" class="maincell"> <tr> <td width="106">Select Region</td> <td width="381"><input name="region" type="radio" id="region" value="London" checked> London <td><input name="region" type="radio" id="region" value="England"> England <td><input name="region" type="radio" id="region" value="<Scotland>"> Scotland <td><input name="region" type="radio" id="region" value="Wales"> Wales website development<td><input name="region" type="radio" id="region" value="Northern Ireland" checked> Northern Ireland </td> </tr> <tr> <td>City</td> <td><input name="city" type="text" class="box" id="city" size="30" value="<?=$city;?>"></td> </tr> <tr> <td>Area</td> <td><input name="area" type="text" class="box" id="area" size="30" value="<?=$area;?>"></td> </tr> <tr> <td>Min No.Of Bedrooms</td> <td><input name="bedrooms" type="radio" id="bedrooms" value="7" checked> 7 </td> <td><input name="bedrooms" type="radio" id="bedrooms" value="6"> 6 </td> <td><input name="bedrooms" type="radio" id="bedrooms" value="5"> 5 </td> <td><input name="bedrooms" type="radio" id="bedrooms" value="4"> 4 </td> <td><input name="bedrooms" type="radio" id="bedrooms" value="3"> 3 </td> <td><input name="bedrooms" type="radio" id="bedrooms" value="2"> 2 </td> <td><input name="bedrooms" type="radio" id="bedrooms" value="1"> 1 </td> </tr> <tr> <td>Postcode</td> <td><input name="postcode" type="text" class="box" id="postcode" size="10" value="<?=$postcode?>"></td> </tr> <tr> <td>Property Type</td> <td><input name="type" type="radio" id="type" value="Flat" checked> Flat </td> <td><input name="type" type="radio" id="type" value="terrace"> Terrace </td> <td> <input name="type" type="radio" id="type" value="house" > house </td> </tr> <tr> <td>Minimum Selling price</td> <td><input name="minprice" type="text" class="box" id="minprice" size="30" value="<?=$minprice;?>"></td> </tr> <tr> <td>Maximum Selling price</td> <td><input name="maxprice" type="text" class="box" id="maxprice" size="30" value="<?=$maxprice;?>"></td> </tr> <tr align="center"> <td colspan="2"><input name="search" type="submit" class="bluebox" id="search" value="Search Property" onclick="return checkForm();"></td> </tr> </table> </form> </body> </html>