Jump to content

Insert Record/Update Record Member Profile


Recommended Posts

Hi all,

Im a newcomer to this website and so if this is in the wrong category I apologise.

 

Now, by by trade im a Graphic Designer and im currently trying to self teach (Autodidact?) myself php & mySQL.

I have a web idea im currently trying to pursue which was going fine as in my studio the web programmer was currently teaching me on the side, however with his heavy work loads he no longer can;

 

I have a website where users can log in, then upon first visit submit a profile, and then there after they can modiify/update it (Dont worry its not another social networking website  :P) the problem im having is everytime I create the record insert form Im having trouble "echo'ing" certain elements of that form, as well as getting it to work correctly.

 

Im eager to get this website online and have been thinking of outsourcing the project, however id like to build my knowledge of the subject whilst producing this site; Id also like to ask would you take the risk of working with people you may never meet on such an idea you ideally want to keep under wraps?

 

Thanks  :)

Welcome to PHPFreaks, by the way. =P

And back to your topic...Show us some code so we can help you and see what exactly it is that you're doing.  And I'd completely trust the people here because we're here to help.  Many of us have had years of experience and can really solve most problems and get people on the way to successful coding.  Be aware that we won't code it FOR you (for free at least), but we'll help as best we can.  =)  So yeah, show us some code that you have and we'll help.

tags.

 

Thanks :), im not sure if this is correct, there seems to be a lot of coding but here it goes...

 

first of all this is my form coding:

 

 
<form method="post" id="form1" action="<?php echo KT_escapeAttribute(KT_getFullUri()); ?>">
        <table cellpadding="2" cellspacing="0" class="KT_tngtable">
          <tr>
            <td class="KT_th"><label for="profile_name">First Name:</label></td>
            <td><input type="text" name="profile_name" id="profile_name" value="<?php echo KT_escapeAttribute($row_rsmember_profile['profile_name']); ?>" size="32" />
                <?php echo $tNGs->displayFieldHint("profile_name");?> <?php echo $tNGs->displayFieldError("member_profile", "profile_name"); ?> </td>
          </tr>
          <tr>
            <td class="KT_th"><label for="profile_member_secondname">Profile_member_secondname:</label></td>
            <td><input type="text" name="profile_member_secondname" id="profile_member_secondname" value="<?php echo KT_escapeAttribute($row_rsmember_profile['profile_member_secondname']); ?>" size="32" />
                <?php echo $tNGs->displayFieldHint("profile_member_secondname");?> <?php echo $tNGs->displayFieldError("member_profile", "profile_member_secondname"); ?> </td>
          </tr>
          <tr>
            <td class="KT_th"><label for="profile_email">eMail:</label></td>
            <td><input type="text" name="profile_email" id="profile_email" value="<?php echo KT_escapeAttribute($row_rsmember_profile['profile_email']); ?>" size="32" />
                <?php echo $tNGs->displayFieldHint("profile_email");?> <?php echo $tNGs->displayFieldError("member_profile", "profile_email"); ?> </td>
          </tr>
          <tr>
            <td class="KT_th"><label for="profile_landline">Landline:</label></td>
            <td><input type="text" name="profile_landline" id="profile_landline" value="" size="32" />
                <?php echo $tNGs->displayFieldHint("profile_landline");?> <?php echo $tNGs->displayFieldError("member_profile", "profile_landline"); ?> </td>
          </tr>
          <tr>
            <td class="KT_th"><label for="profile_mob">Mobile:</label></td>
            <td><input type="text" name="profile_mob" id="profile_mob" value="<?php echo KT_escapeAttribute($row_rsmember_profile['profile_mob']); ?>" size="32" />
                <?php echo $tNGs->displayFieldHint("profile_mob");?> <?php echo $tNGs->displayFieldError("member_profile", "profile_mob"); ?> </td>
          </tr>
          <tr>
            <td class="KT_th"><label for="profile_summary">Profile_summary:</label></td>
            <td><input type="text" name="profile_summary" id="profile_summary" value="<?php echo KT_escapeAttribute($row_rsmember_profile['profile_summary']); ?>" size="32" />
                <?php echo $tNGs->displayFieldHint("profile_summary");?> <?php echo $tNGs->displayFieldError("member_profile", "profile_summary"); ?> </td>
          </tr>
          <tr>
            <td class="KT_th"><label for="profile_qualifications">Profile_qualifications:</label></td>
            <td><input type="text" name="profile_qualifications" id="profile_qualifications" value="<?php echo KT_escapeAttribute($row_rsmember_profile['profile_qualifications']); ?>" size="32" />
                <?php echo $tNGs->displayFieldHint("profile_qualifications");?> <?php echo $tNGs->displayFieldError("member_profile", "profile_qualifications"); ?> </td>
          </tr>
          <tr>
            <td class="KT_th"><label for="profile_paypref">Profile_paypref:</label></td>
            <td><input type="text" name="profile_paypref" id="profile_paypref" value="<?php echo KT_escapeAttribute($row_rsmember_profile['profile_paypref']); ?>" size="32" />
                <?php echo $tNGs->displayFieldHint("profile_paypref");?> <?php echo $tNGs->displayFieldError("member_profile", "profile_paypref"); ?> </td>
          </tr>
          <tr>
            <td class="KT_th"><label for="profile_minimumrate">Profile_minimumrate:</label></td>
            <td><input type="text" name="profile_minimumrate" id="profile_minimumrate" value="<?php echo KT_escapeAttribute($row_rsmember_profile['profile_minimumrate']); ?>" size="32" />
                <?php echo $tNGs->displayFieldHint("profile_minimumrate");?> <?php echo $tNGs->displayFieldError("member_profile", "profile_minimumrate"); ?> </td>
          </tr>
          <tr>
            <td class="KT_th"><label for="profile_days">Profile_days:</label></td>
            <td><input type="text" name="profile_days" id="profile_days" value="<?php echo KT_escapeAttribute($row_rsmember_profile['profile_days']); ?>" size="32" />
                <?php echo $tNGs->displayFieldHint("profile_days");?> <?php echo $tNGs->displayFieldError("member_profile", "profile_days"); ?> </td>
          </tr>
          <tr>
            <td class="KT_th"><label for="profile_misc">Profile_misc:</label></td>
            <td><input type="text" name="profile_misc" id="profile_misc" value="<?php echo KT_escapeAttribute($row_rsmember_profile['profile_misc']); ?>" size="32" />
                <?php echo $tNGs->displayFieldHint("profile_misc");?> <?php echo $tNGs->displayFieldError("member_profile", "profile_misc"); ?> </td>
          </tr>
          <tr class="KT_buttons">
            <td colspan="2"><input type="submit" name="KT_Insert1" id="KT_Insert1" value="Insert record" />
            </td>
          </tr>
        </table>
        <input type="hidden" name="profile_member_id" id="profile_member_id" value="<?php echo KT_escapeAttribute($row_rsmember_profile['profile_member_id']); ?>" />
      </form>

Then this is my php for the entire page im working on

 

<?php require_once('Connections/db99.php'); ?>
<?php
// Load the common classes
require_once('includes/common/KT_common.php');

// Load the tNG classes
require_once('includes/tng/tNG.inc.php');

// Make a transaction dispatcher instance
$tNGs = new tNG_dispatcher("");

// Make unified connection variable
$conn_db99 = new KT_connection($db99, $database_db99);

// Start trigger
$formValidation = new tNG_FormValidation();
$formValidation->addField("profile_name", true, "text", "", "3", "50", "You forgot to enter your name!");
$formValidation->addField("profile_email", true, "text", "email", "5", "100", "You forgot to enter your email!");
$formValidation->addField("profile_landline", true, "text", "phone", "11", "20", "You forgot to enter your landline telephone number!");
$formValidation->addField("profile_mob", true, "text", "phone", "11", "11", "You forgot to enter your mobile telephone number!");
$formValidation->addField("profile_summary", true, "text", "", "1", "500", "You forgot to enter your name!");
$formValidation->addField("profile_qualifications", true, "text", "", "1", "200", "You forgot to enter your name!");
$formValidation->addField("profile_paypref", true, "text", "", "1", "100", "You forgot to enter your name!");
$formValidation->addField("profile_minimumrate", true, "text", "", "3", "10", "You forgot to enter your name!");
$formValidation->addField("profile_days", true, "text", "", "0", "200", "You forgot to enter your name!");
$formValidation->addField("profile_misc", false, "text", "", "0", "500", "");
$tNGs->prepareValidation($formValidation);
// End trigger

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}

mysql_select_db($database_db99, $db99);
$query_get_details = "SELECT member_id, member_email, member_firstname, member_lastname, member_landline FROM members";
$get_details = mysql_query($query_get_details, $db99) or die(mysql_error());
$row_get_details = mysql_fetch_assoc($get_details);
$totalRows_get_details = mysql_num_rows($get_details);

// Make a logout transaction instance
$logoutTransaction = new tNG_logoutTransaction($conn_db99);
$tNGs->addTransaction($logoutTransaction);
// Register triggers
$logoutTransaction->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "GET", "KT_logout_now");
$logoutTransaction->registerTrigger("END", "Trigger_Default_Redirect", 99, "index.php");
// Add columns
// End of logout transaction instance

// Make an insert transaction instance
$ins_member_profile = new tNG_insert($conn_db99);
$tNGs->addTransaction($ins_member_profile);
// Register triggers
$ins_member_profile->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");
$ins_member_profile->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);
$ins_member_profile->registerTrigger("END", "Trigger_Default_Redirect", 99, "member_area.php?message=Your profile has been successfully updated!");
// Add columns
$ins_member_profile->setTable("member_profile");
$ins_member_profile->addColumn("profile_member_id", "STRING_TYPE", "POST", "profile_member_id", "{SESSION.kt_login_id}");
$ins_member_profile->addColumn("profile_name", "STRING_TYPE", "POST", "profile_name", "{get_details.member_firstname}");
$ins_member_profile->addColumn("profile_member_secondname", "STRING_TYPE", "POST", "profile_member_secondname", "{get_details.member_lastname}");
$ins_member_profile->addColumn("profile_email", "STRING_TYPE", "SESSION", "profile_email", "{SESSION.kt_login_user}");
$ins_member_profile->addColumn("profile_landline", "STRING_TYPE", "SESSION", "profile_landline", "{member_get_details.member_landline}");
$ins_member_profile->addColumn("profile_mob", "STRING_TYPE", "POST", "profile_mob", "");
$ins_member_profile->addColumn("profile_summary", "STRING_TYPE", "POST", "profile_summary");
$ins_member_profile->addColumn("profile_qualifications", "STRING_TYPE", "POST", "profile_qualifications");
$ins_member_profile->addColumn("profile_paypref", "STRING_TYPE", "POST", "profile_paypref");
$ins_member_profile->addColumn("profile_minimumrate", "STRING_TYPE", "POST", "profile_minimumrate");
$ins_member_profile->addColumn("profile_days", "STRING_TYPE", "POST", "profile_days");
$ins_member_profile->addColumn("profile_misc", "STRING_TYPE", "POST", "profile_misc");
$ins_member_profile->setPrimaryKey("profile_id", "NUMERIC_TYPE");

// Execute all the registered transactions
$tNGs->executeTransactions();

// Get the transaction recordset
$rscustom = $tNGs->getRecordset("custom");
$row_rscustom = mysql_fetch_assoc($rscustom);
$totalRows_rscustom = mysql_num_rows($rscustom);

// Get the transaction recordset
$rsmember_profile = $tNGs->getRecordset("member_profile");
$row_rsmember_profile = mysql_fetch_assoc($rsmember_profile);
$totalRows_rsmember_profile = mysql_num_rows($rsmember_profile);
?>

 

Please note however I am a complete beginner to this subject so constructive criticism is welcome, thanks :)

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.