ltoto Posted September 19, 2006 Share Posted September 19, 2006 What I am im doing is there is an initial form where they can fil in the details required, and then there will be an option to select, Villa, Hotel or Appartments ( the type of accomodation they want and after they sumbit the first form, depending on what option of them three they chose it goes through to another form.what i need to know is how to get the details of the form into the database if that makes sense, but also the person who is filling in the form will be given a reference number( kinda how a data is done ) which will follow them through both forms.any ideas or do i need to give more information? Quote Link to comment Share on other sites More sharing options...
onlyican Posted September 19, 2006 Share Posted September 19, 2006 make them MySQL safe, I have built my own function for this[code]<?phpfunction MakeSafe($str, $make_lower = false){if($make_lower){$str = strtolower($str);}$str = stripslashes($str);$str = trim($str);$str = strip_tags($str);$str = mysql_real_escape_string($str);return $str;}?>[/code]so if we have field names "name" AND "email"We create a table in the MySQL Database, with aFIELD NAME: id_numTYPE: int(50) Primary KeyAUtoIncrementand also 2 varchars, with name and emailthen[code]<?phpfunction DBConnect(){$db = mysql_connect("localhost","username","password");//Replace username and password with yours, host is normally localhostmysql_select_db("DB_Name",$db);//Replace DB_Name with the Database name}$name = MakeSafe($_POST["name"]);$email = MakeSafe($_POST["email"]);$query1 = "INSERT INTO tablename (name, email) VALUES ('".$name."', '".$email."');$result1 = mysql_query($query1);if($result1){echo "The data has been added to the Database."<br />\n";}else{echo "There has been an error<br />\n".mysql_error();}?>[/code] Quote Link to comment Share on other sites More sharing options...
ltoto Posted September 19, 2006 Author Share Posted September 19, 2006 right, i will give this a go and let you know how i get on, thanks a lot Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.