Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
Two pieces of Code in same program HTML and PHP

I am very new to PHP and I have two different pieces of PHP code, as shown below. I do not know how to join these two together. Each time I try to join the two codes together, it only executes the top code. Any help I could get would be great!

Here are my two pieces of code I am trying to join up:

    <?php 
    if (isset($_POST["title"])) {
        require "db_conn.php";
        $title = $_POST["title"];


        if (empty($title)) {
            header("Location: index.php?mess=error#popup1");
        } else {
            $stmt = $conn->prepare("INSERT INTO todos(title) VALUE(?)");
            $res = $stmt->execute([$title]);

            if ($res) {
                header("Location: index.php?mess=success");
            } else {
                header("Location: index.php");
            }
            $conn = null;
            exit();
        }
    } else {
        header("Location: index.php?mess=error#popup1");
    }
    <?php 
    if (isset($_POST["description"])) {
        require "db_conn.php";
        $description = $_POST["description"];


        if (empty($description)) {
            header("Location: index.php?mess=error#popup1");
        } else {
            $stmt = $conn->prepare("INSERT INTO todos(description) VALUE(?)");
            $res = $stmt->execute([$description]);

            if ($res) {
                header("Location: index.php?mess=success");
            } else {
                header("Location: index.php");
            }
            $conn = null;
            exit();
        }
    } else {
        header("Location: index.php?mess=error#popup1");
    }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!