I need to save content into two tables. I have this code, but it save just into table games. I need save into the games all content and into archive just id, title and date of article.
Any help?
Thanks very much
<?php include("../includes/connect.php"); if(isset($_POST['submit'])) { $games_date = date('y-m-d-h'); $games_title = $_POST['title']; $games_author = $_POST['author']; $games_keywords = $_POST['keywords']; $games_link = $_POST['download_link']; $games_image = $_FILES['image']['name']; $games_tmp = $_FILES['image']['tmp_name']; $games_content = $_POST['content']; if($games_title=="" or $games_author=="" or $games_keywords=="" or $games_content=="" or $games_download_link="") { echo"<script>alert('any field is empty')</script>"; exit(); } else { move_uploaded_file($games_tmp,"../uploaded_images/$games_image"); $games_query = "insert into games (games_title,games_date,games_author,games_image,games_keywords,games_link,games_content) values ('$games_title','$games_date','$games_author','$games_image','$games_keywords','$games_link','$games_content')"; $last_id = mysqli_insert_id($connect); $archive_query = "insert into archive (title, pub_date) values ('$games_title','$games_date',)"; } if(mysqli_query($connect,$games_query)) { echo "<center><h1>Post published seccesfuly!</h1></center>"; } } ?>
$games_queryand not the$archive_query. Are you missing some of the code?$archive_query. It's not going to jump up and magically execute itself. Your code is also vulnerable to SQL injection, making it potentially possible for someone to corrupt your database, steal information from it, or take control of the site.