Jump to content


Forms into SQL database

  • Please log in to reply
2 replies to this topic

#1 ltoto

  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 19 September 2006 - 08:31 AM

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?

#2 onlyican

  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 19 September 2006 - 10:39 AM

make them MySQL safe, I have built my own function for this
function MakeSafe($str, $make_lower = false){
$str = strtolower($str);
$str = stripslashes($str);
$str = trim($str);
$str = strip_tags($str);
$str = mysql_real_escape_string($str);
return $str;

so if we have field names "name" AND "email"
We create a table in the MySQL Database, with a
FIELD NAME: id_num
TYPE: int(50)
Primary Key

and also 2 varchars, with name and email


function DBConnect(){
$db = mysql_connect("localhost","username","password");
//Replace username and password with yours, host is normally localhost
//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);


echo "The data has been added to the Database."<br />\n";
echo "There has been an error<br />\n"

Tell me the problem, I will try tell you the solution

#3 ltoto

  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 19 September 2006 - 10:58 AM

right, i will give this a go and let you know how i get on, thanks a lot

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users