PHP code to INSERT values into MULTIPLE tables

They have: 5 posts

Joined: Jan 2012

can anyone help me !!!!!!!!!!!!!!!!

im trying to get the values from the select box in HTML form , and if the value is "Male" the user info will be inserted into the "male" table. and if the value is "female" then the info will be inserted into the "female" table........

i dont know where i made the mistake................

They have: 5 posts

Joined: Jan 2012

/// this is the Form.php

<?php


$mysql_host
= 'localhost';
$mysql_user = 'root';
$mysql_pass = 'password';
$mysql_db   = 'select';

@
mysql_connect($mysql_host,$mysql_user,$mysql_pass) or die(mysql_error());
echo
'Connected to MySQL';
@
mysql_select_db($mysql_db) or die(mysql_error());
echo
'Connected to DB';
?>

Untitled Document

name :
Gender :
-SELECT
Male
Female

They have: 5 posts

Joined: Jan 2012

/// this is the store.php file

<?php
$mysql_host
= 'localhost';
$mysql_user = 'root';
$mysql_pass = 'password';
$mysql_db   = 'select';

@
mysql_connect($mysql_host,$mysql_user,$mysql_pass) or die(mysql_error());
echo
'Connected to MySQL';
@
mysql_select_db($mysql_db) or die(mysql_error());
echo
'Connected to DB';

$name   = $_POST['name'];
$gender = $_POST['gender'];

if(isset(
$gender)='m')
{
$query1 = "INSERT INTO `male` (name,gender) VALUES('$name','$gender')";
$run = mysql_query($query1);
}
else {
$query2 = "INSERT INTO `female` (name,gender) VALUES('$name','$gender')";
$run = mysql_query($query2);
}
?>

They have: 6 posts

Joined: Jan 2012

kpkguru003 your code is not working properly.

They have: 5 posts

Joined: Jan 2012

Untitled Document

name :
Gender :
-SELECT
Male
Female

this is the form i missed in form.php

They have: 5 posts

Joined: Jan 2012

the HTML tags are not working here , what can i do ?

They have: 10 posts

Joined: Mar 2012

<?php
if (isset($_POST) && isset($_POST["form_register"]))
{
   
$insert_query = "INSERT INTO users SET
                        users.first_name='"
. mysql_real_escape_string($_POST['fname']) . "',
                        users.last_name='"
. mysql_real_escape_string($_POST['lname']) . "',
                        users.email='"
. mysql_real_escape_string($_POST['email']) . "',
                        users.password='"
. mysql_real_escape_string($_POST['password']) . "';";

    if (
mysql_query($insert_query))
    {
       
$_SESSION['messageType'] = "success_msg";
    }
    else
    {
       
$_SESSION['message'] = "-Registration not Successful.";
       
$_SESSION['messageType'] = "error_msg";
    }
}
?>

He has: 13 posts

Joined: May 2010

Can i use in css . If any more or other information for me...

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.