<?php
include 'connection.php';
session_start();
$noteinfo = array();
$noteinfo['note'] = $_POST['note'];
$_SESSION['noteinfo'] = $noteinfo;
if (isset($_POST['submit'])) {
if (empty($_POST['note'])) {
echo "Dobavete Komentar";
}
if (!empty($_SESSION['noteinfo'])) {
$check = mysqli_escape_string($conn,$_SESSION['userinfo']['fname']);
print_r($_SESSION['userinfo']);
$sql = "INSERT INTO users (user_fname,user_mname,user_lname,user_login,user_email,user_phone)
VALUES ('{$_SESSION['userinfo']['fname']}', '{$_SESSION['userinfo']['mname']}', '{$_SESSION['userinfo']['lname']}', '{$_SESSION['userinfo']['login']}', '{$_SESSION['userinfo']['email']}', '{$_SESSION['userinfo']['phone']}')";
$sql1 = "INSERT INTO addresses (address_line_1,address_line_2,address_zip,address_city,address_province,address_country)
VALUES ('{$_SESSION['addressinfo']['adr1']}', '{$_SESSION['addressinfo']['adr2']}', '{$_SESSION['addressinfo']['zip']}', '{$_SESSION['addressinfo']['city']}', '{$_SESSION['addressinfo']['provinciq']}', '{$_SESSION['addressinfo']['durjava']}')";
$sql2 = "INSERT INTO notes (note_text)
VALUES ('{$_SESSION['noteinfo']['note']}')";
$sql3 = "INSERT INTO users_addresses (ua_user_id,ua_address_id)
SELECT users.user_id,addresses.address_id
FROM ( VALUES () )";
if (mysqli_query($conn,$sql)) {
echo "Added";
if (mysqli_query($conn,$sql1)) {
echo "Added";
if (mysqli_query($conn,$sql2)) {
echo "Added";
if (mysqli_query($conn,$sql3)) {
echo "Mai stana toq put";
header("refresh:3 ; url=profile.php");
}
}
}
}
else{
echo "Error";
}
}
else{
header("refresh:1 ; url=zapiski.php");
}
}
?>
My question is for $sql3: I want when the forms are completed to fill the users_addresses with the id of the user and the id from the address tables.But for now the SQL doesn't fill nothing in the table users_addresses. These are my tables:
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…