Jump to content

Where should I should put my INSERT SQL?


jsk1gcc

Recommended Posts

Just a quick question I have a form, couple of drop down boxes, input fields etc.. at the end is the submit button. now my question is should my insert into database sqls go before the submit button inside the form?

out side the form? after the button inside the form?

 

If by any chance you could give me some advice on the best way to layout my sql that would be great. They are big and go into three tables, at the moment I have them as three seperate queries but I think they must be able to go into one. can someone please help me with the layout and syntax.

 

here is what the queries look like at the moment:

 

if ($IBselect=$_POST ['IBselect']);
{
//CUSTOMER
$enterCust="INSERT INTO customer(username, password, title, firstName, lastName, address, town, country, postCode, phone, email, dateCust) 
                        VALUES ('$_POST[username]', '$_POST[password]', '$_POST[title]', '$_POST[firstName]', '$_POST[lastName]', '$_POST[address]', '$_POST[town]', '$_POST[country]', '$_POST[postCode]', '$_POST[phone]', '$_POST[email]', 'DATE: Auto CURDATE()', CURDATE()";
$enterCust_query=mysql_query($enterCust)or die(mysql_error());

//CARD 
$enterCard="INSERT INTO card(cardNumber,  name, expDate, cardID) 
                        VALUES ('$_POST[cardNumber]','$_POST[name]', ' $_POST[expDate]', '$_POST[cardID]')";
$enterCard_query=mysql_query($enterCard);

//BOOKING
$RCenterBook=mysql_query("INSERT INTO booking (custNumber, cardID, rideName, seatNo1, seatNo2, price, price2, dateBook, ID_time_tbl) 
                VALUES ('$custNumber', '$_POST[cardID]', '$rideName', '$_SESSION[iBextract]', '$_SESSION[iBextract2]', '$IBendPrice1', '$IBendPrice2', 'DATE: Auto CURDATE()', CURDATE()',  '$_SESSION[iB_slot_Time]'");
$IBenterBooking_query=mysql_query($IBenterBook); 
        if (!mysql_query($enterCard, $enterCust, $IBenterBook))
        {
        die("Error:" .mysql_error());
        }
        echo "1 record added IB";
}

 

Thanks =)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.