Jump to content

Adding confirmation message?


andrew_ww

Recommended Posts

How easy is it to add a message informing that update had been successful ?

[code]<?php
// Get MySQL connection
require_once('../required/conn.php');
// Begin session
if (!isset($_SESSION)) {
  session_start();
}
// If user session is not set redirect to login page
if(!isset($_SESSION['authenticated'])) {
          header("location: ../?notification=pleaselogin");
}
// Logout link
$logout = $_SERVER['PHP_SELF']."?begone=true";
// If user chooses to logout unset session and redirect
if(isset($_REQUEST['begone']) && $_REQUEST['begone'] == true) {
    $_SESSION['authenticated'] = NULL;
    unset($_SESSION['authenticated']);
    header("location: ../index.php?notification=loggedout");
}
// Get user's ID from session
$userID = $_SESSION['authenticated'];
?>
<?php require_once('../Connections/db.php'); ?>
<?php
$IP_LOG = $_SERVER["REMOTE_ADDR"];
$HOSTNAME_LOG = gethostbyaddr($_SERVER['REMOTE_ADDR']);
?>



<?php
$colname_rs_table1 = "1";
if (isset($_GET['recordID'])) {
  $colname_rs_table1 = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']);
}
mysql_select_db($database_db, $db);
//$query_rs_table1 = sprintf("SELECT * FROM tbl_table1 INNER JOIN table2 ON (tbl_table1.id = table2.id) WHERE table2.id = %s", $colname_rs_table1);
$query_rs_table1 = sprintf("SELECT * FROM table2 WHERE table2.id = %s", $colname_rs_table1);
$rs_table1 = mysql_query($query_rs_table1, $DII) or die(mysql_error());
$row_rs_table1 = mysql_fetch_assoc($rs_table1);
$totalRows_rs_table1 = mysql_num_rows($rs_table1);
?>

<?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_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE table2 SET sub=%s WHERE id=%s",
                      GetSQLValueString($_POST['sub'], "text"),
                      GetSQLValueString($_POST['id'], "int"));

  mysql_select_db($database_db, $db);
  $Result1 = mysql_query($updateSQL, $db) or die(mysql_error());

  $updateGoTo = "index.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
?> [/code]
Link to comment
https://forums.phpfreaks.com/topic/33404-adding-confirmation-message/
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.