Jump to content

php maker code?


jimmi8

Recommended Posts

Hi there,

 

Is anyone familiar with phpmaker. IM looking at modifying some functionality in a site and i noticed that it used php maker and im slightly thrown by it.

 

The snippet of code below is just in the process of inserting some form data into a database record

<?php
// Load key from QueryString
$bCopy = true;
$x_brand_id = @$_GET["brand_id"];
if (($x_brand_id == "") || (is_null($x_brand_id))) $bCopy = false;

// Get action
$sAction = @$_POST["a_add"];
if (($sAction == "") || ((is_null($sAction)))) {
    if ($bCopy) {
        $sAction = "C"; // Copy record
    } else {
        $sAction = "I"; // Display blank record
    }
} else {

    // Get fields from form
    $x_brand_id = @$_POST["x_brand_id"];
    $x_brand = @$_POST["x_brand"];
    $x_description = @$_POST["x_description"];
    $x_more_links = @$_POST["x_more_links"];
    $x_header_image = @$_POST["x_header_image"];
    $x_logo_image = @$_POST["x_logo_image"];
    $x_updated = @$_POST["x_updated"];

}
$conn = phpmkr_db_connect(HOST, USER, PASS, DB, PORT);
switch ($sAction) {
    case "C": // Copy record
        if (!LoadData($conn)) { // Load record
            $_SESSION[ewSessionMessage] = "No records found";
            phpmkr_db_close($conn);
            ob_end_clean();
            header("Location: tbl_brandslist.php");
            exit();
        }
        break;
    case "A": // Add
        if (AddData($conn)) { // Add new record
            $_SESSION[ewSessionMessage] = "Add New Record Successful";
            phpmkr_db_close($conn);
            ob_end_clean();
            header("Location: tbl_brandslist.php");
            exit();
        }
    break;

Now i wanted to use mysql_insert_id to get the id of the last insert and use this to insert another piece of info in to another table. So i did it here ( also adding relevant fields with the correct name attribute etc lower down in the script), Ive put ** where ive added my bit in:

 

<?php

// Load key from QueryString
$bCopy = true;
$x_brand_id = @$_GET["brand_id"];
if (($x_brand_id == "") || (is_null($x_brand_id))) $bCopy = false;

// Get action
$sAction = @$_POST["a_add"];
if (($sAction == "") || ((is_null($sAction)))) {
    if ($bCopy) {
        $sAction = "C"; // Copy record
    } else {
        $sAction = "I"; // Display blank record
    }
} else {

    // Get fields from form
    $x_brand_id = @$_POST["x_brand_id"];
    $x_brand = @$_POST["x_brand"];
    $x_description = @$_POST["x_description"];
    $x_more_links = @$_POST["x_more_links"];
    $x_header_image = @$_POST["x_header_image"];
    $x_logo_image = @$_POST["x_logo_image"];
    $x_updated = @$_POST["x_updated"];

}
$conn = phpmkr_db_connect(HOST, USER, PASS, DB, PORT);
switch ($sAction) {
    case "C": // Copy record
        if (!LoadData($conn)) { // Load record
            $_SESSION[ewSessionMessage] = "No records found";
            phpmkr_db_close($conn);
            ob_end_clean();
            header("Location: tbl_brandslist.php");
            exit();
        }
        break;
    case "A": // Add
        if (AddData($conn)) { // Add new record
        **$conn = phpmkr_db_connect(HOST, USER, PASS, DB, PORT);
                ** $id = mysql_insert_id();
                **$x_page_title = $_POST['x_page_title'];
                **$sql = "INSERT INTO page_title (title_id, title,brand_id) VALUES (NULL,     '$x_page_title', 'brand_id')";
        $query = mysql_query($sql);
        
            $_SESSION[ewSessionMessage] = "Add New Record Successful";
            phpmkr_db_close($conn);
            ob_end_clean();
            header("Location: tbl_brandslist.php");
            exit();
        }
        
    
        
}

the table doesnt seem to get input in to when i submit the form. Is anyone at all familiar with this? Could anyone comment whether that bit of code i added is in the correct place?

Link to comment
https://forums.phpfreaks.com/topic/38044-php-maker-code/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.