SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot crunch42's Avatar
    Join Date
    Jun 2003
    Location
    San Francisco
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to insert record in Dreamweaver then show it on next page.

    Dreamweaver's insert record behavior allows you to take form contents and insert them into a record, then it redirects to another page. I can't figure out how to show the contents of what was just inserted on the redirect page. Anyone out there done this? I'm sure it's a simple thing, but I'm under a very stressful deadline and can't think straight.

    The code on both pages is huge:

    On the insert page:
    PHP Code:
    <?php
    function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
    {
      
    $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

      switch (
    $theType) {
        case 
    "text":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;    
        case 
    "long":
        case 
    "int":
          
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case 
    "double":
          
    $theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
          break;
        case 
    "date":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;
        case 
    "defined":
          
    $theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
          break;
      }
      return 
    $theValue;
    }

    $editFormAction $_SERVER['PHP_SELF'];
    if (isset(
    $_SERVER['QUERY_STRING'])) {
      
    $editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
    }

    if ((isset(
    $_POST["MM_insert"])) && ($_POST["MM_insert"] == "RegForm")) {
      
    $insertSQL sprintf("INSERT INTO Registrations (UserID, day_pre, conf, Workshops, Track, CEU, Meals_1, Meals_2, Meals_3, Meals_4, Meals_5, meal_vegan, meal_vegetarian, meal_wheat, meal_dairy, meal_other, HUB, payment_method, CCNum, CCexp, CCV, CheckNum, CheckDate, WireNum, FirstName, LastName, Organization, Address, Address2, `State`, StateProv, City, PostalCode, Phone, Country, payment_other, payment_other_name, notes) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                           
    GetSQLValueString($_POST['UserID'], "text"),
                           
    GetSQLValueString(isset($_POST['day_pre']) ? "true" """defined","'Y'","'N'"),
                           
    GetSQLValueString(isset($_POST['conf']) ? "true" """defined","'Y'","'N'"),
                           
    GetSQLValueString($_POST['Workshops'], "text"),
                           
    GetSQLValueString($_POST['Track'], "text"),
                           
    GetSQLValueString($_POST['CEU'], "text"),
                           
    GetSQLValueString(isset($_POST['Meals_1']) ? "true" """defined","'Y'","'N'"),
                           
    GetSQLValueString(isset($_POST['Meals_2']) ? "true" """defined","'Y'","'N'"),
                           
    GetSQLValueString(isset($_POST['Meals_3']) ? "true" """defined","'Y'","'N'"),
                           
    GetSQLValueString(isset($_POST['Meals_4']) ? "true" """defined","'Y'","'N'"),
                           
    GetSQLValueString(isset($_POST['Meals_5']) ? "true" """defined","'Y'","'N'"),
                           
    GetSQLValueString(isset($_POST['meal_vegan']) ? "true" """defined","'Y'","'N'"),
                           
    GetSQLValueString(isset($_POST['meal_vegetarian']) ? "true" """defined","'Y'","'N'"),
                           
    GetSQLValueString(isset($_POST['meal_wheat']) ? "true" """defined","'Y'","'N'"),
                           
    GetSQLValueString(isset($_POST['meal_dairy']) ? "true" """defined","'Y'","'N'"),
                           
    GetSQLValueString($_POST['meal_other'], "text"),
                           
    GetSQLValueString(isset($_POST['HUB']) ? "true" """defined","'Y'","'N'"),
                           
    GetSQLValueString($_POST['payment_method'], "text"),
                           
    GetSQLValueString($_POST['CCNum'], "text"),
                           
    GetSQLValueString($_POST['CCexp'], "text"),
                           
    GetSQLValueString($_POST['CCV'], "text"),
                           
    GetSQLValueString($_POST['CheckNum'], "text"),
                           
    GetSQLValueString($_POST['CheckDate'], "text"),
                           
    GetSQLValueString($_POST['WireNum'], "text"),
                           
    GetSQLValueString($_POST['FirstName'], "text"),
                           
    GetSQLValueString($_POST['LastName'], "text"),
                           
    GetSQLValueString($_POST['Organization'], "text"),
                           
    GetSQLValueString($_POST['Address'], "text"),
                           
    GetSQLValueString($_POST['Address2'], "text"),
                           
    GetSQLValueString($_POST['State'], "text"),
                           
    GetSQLValueString($_POST['StateProv'], "text"),
                           
    GetSQLValueString($_POST['City'], "text"),
                           
    GetSQLValueString($_POST['PostalCode'], "text"),
                           
    GetSQLValueString($_POST['Phone'], "text"),
                           
    GetSQLValueString($_POST['Country'], "text"),
                           
    GetSQLValueString(isset($_POST['payment_other']) ? "true" """defined","'Y'","'N'"),
                           
    GetSQLValueString($_POST['payment_other_name'], "text"),
                           
    GetSQLValueString($_POST['notes'], "text"));

      
    mysql_select_db($database_conference$conference);
      
    $Result1 mysql_query($insertSQL$conference) or die(mysql_error());

      
    $insertGoTo "register3a.php";
      if (isset(
    $_SERVER['QUERY_STRING'])) {
        
    $insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
        
    $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      
    header(sprintf("Location: %s"$insertGoTo));
    }

    mysql_select_db($database_conference$conference);
    $query_rs_ceus "SELECT * FROM CEUs ORDER BY code ASC";
    $rs_ceus mysql_query($query_rs_ceus$conference) or die(mysql_error());
    $row_rs_ceus mysql_fetch_assoc($rs_ceus);
    $totalRows_rs_ceus mysql_num_rows($rs_ceus);

    mysql_select_db($database_conference$conference);
    $query_rs_states "SELECT * FROM States ORDER BY stprv_ID ASC";
    $rs_states mysql_query($query_rs_states$conference) or die(mysql_error());
    $row_rs_states mysql_fetch_assoc($rs_states);
    $totalRows_rs_states mysql_num_rows($rs_states);

    $colname_rs_user "1";
    if (isset(
    $_GET['Email1'])) {
      
    $colname_rs_user = (get_magic_quotes_gpc()) ? $_GET['Email1'] : addslashes($_GET['Email1']);
    }
    mysql_select_db($database_conference$conference);
    $query_rs_user sprintf("SELECT * FROM Attendee WHERE Email1 = '%s'"$colname_rs_user);
    $rs_user mysql_query($query_rs_user$conference) or die(mysql_error());
    $row_rs_user mysql_fetch_assoc($rs_user);
    $totalRows_rs_user mysql_num_rows($rs_user);
    ?>
    And on the redirect page:

    PHP Code:
    <?php
    session_start
    ();
    header("Cache-control: private"); // IE 6 Fix.
    $colname_rs_name "1";
    if (isset(
    $_SESSION['MM_Username'])) {
      
    $colname_rs_name = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
    }
    mysql_select_db($database_conference$conference);
    $query_rs_name sprintf("SELECT * FROM Attendee WHERE Email1 = '%s'"$colname_rs_name);
    $rs_name mysql_query($query_rs_name$conference) or die(mysql_error());
    $row_rs_name mysql_fetch_assoc($rs_name);
    $totalRows_rs_name mysql_num_rows($rs_name);

    $colname_rs_reg_receipt "1";
    if (isset(
    $_GET['RegID'])) {
      
    $colname_rs_reg_receipt = (get_magic_quotes_gpc()) ? $_GET['RegID'] : addslashes($_GET['RegID']);
    }
    mysql_select_db($database_conference$conference);
    $query_rs_reg_receipt sprintf("SELECT * FROM Registrations WHERE RegID = '%s'"$colname_rs_reg_receipt);
    $rs_reg_receipt mysql_query($query_rs_reg_receipt$conference) or die(mysql_error());
    $row_rs_reg_receipt mysql_fetch_assoc($rs_reg_receipt);
    $totalRows_rs_reg_receipt mysql_num_rows($rs_reg_receipt);
    ?>
    Thanks in advance!
    Julian

  2. #2
    SitePoint Zealot crunch42's Avatar
    Join Date
    Jun 2003
    Location
    San Francisco
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    The solution...

    The solution was to go into code view and manually replace (on the page with the form and the insert record behavior):

    PHP Code:
      $insertGoTo "receipt.php";
      if (isset(
    $_SERVER['QUERY_STRING'])) {
        
    $insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
        
    $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      
    header(sprintf("Location: %s"$insertGoTo)); 
    with:

    PHP Code:
      $insertGoTo "receipt.php";
      if (isset(
    $_SERVER['QUERY_STRING'])) {
        
    $insertGoTo .= "?UserID=" mysql_insert_id();
      }
      
    header(sprintf("Location: %s"$insertGoTo)); 
    This will pass along the newly created record's "auto increment" registry key as a URL variable called UserID.

    Dreamweaver won't be happy with this manual replacing of part of the Insert Record behavior code, and it will say something like "the Insert Record behavior was only partially deleted blah blah blah". This doesn't mean that it won't work, it just means that you can no longer edit the Insert Record behavior in DW's Behavior's Panel without first manually deleting the code and then reapplying the Insert Record behavior (and then re-patching it in code view).

    - Julian

  3. #3
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    151 Post(s)
    Tagged
    3 Thread(s)
    One thing with Dreamweaver is the way that it seriously bloats the code added, what I would suggest you do is learn from dreamweaver and then stat coding by hand.

    In the short term this might seem pointless as Dreamweaver does alot for you but trust me, in the long run you will be far better off!

    SpikeZ
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •