Code:
<?php
/* This sets the form's action, where it is directing the form data too
* in this case - its back to itself $_SERVER['PHP_SELF']
**/
$editFormAction = $_SERVER['PHP_SELF'];
/* Checks the incoming url to see if any query string has been passed to it.
* eg: www.mysite.com/action.php?name=Spike
* anything after the ? is the query string
* this is taken and added to the form action IN CASE IT IS NEEDED LATER
**/
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
/* if the form has been sent, check for the MM_insert field
* (Should be in the <form> and a <hidden> field
*/
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
/* run the query using a FORMATTED string
* GetSQLValueString is a DW created function that checks the value being sent to it
* and gets rid of any nasties
**/
$insertSQL = sprintf("INSERT INTO groomers (shopName, groomPropName, groomStreet, groomCity, groomProvince, groomCountry, groomPhone, groomEmail, groomWebsite, groomListing, groomPic, groomShow_Hide) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['shopName'], "text"),
GetSQLValueString($_POST['groomPropName'], "text"),
GetSQLValueString($_POST['groomStreet'], "text"),
GetSQLValueString($_POST['groomCity'], "text"),
GetSQLValueString($_POST['groomProvince'], "text"),
GetSQLValueString($_POST['groomCountry'], "text"),
GetSQLValueString($_POST['groomPhone'], "text"),
GetSQLValueString($_POST['groomEmail'], "text"),
GetSQLValueString($_POST['groomWebsite'], "text"),
GetSQLValueString($_POST['groomListing'], "text"),
GetSQLValueString($_POST['groomPic'], "text"),
GetSQLValueString($_POST['groomShow_Hide'], "text"));
/* select the datatbase */
mysql_select_db($database_db9568, $db9568);
/* run the query */
$Result1 = mysql_query($insertSQL, $db9568) or die(mysql_error());
/* where to go to AFTER the query has been run */
$insertGoTo = "CRcart/directory_list_logo.php";
/* as before with the query string. If it exists, append it to the $insertToGo variable
* So if your page was
* www.mysite.com/action.php?name=Spike
* and the next page the script is going to is
* CRcart/directory_list_logo.php
* it would become
* CRcart/directory_list_logo.php?name=Spike
* If you are not worried about appending query strings - you can safely delete the following threee lines.
**/
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
/* redirect the user based on the variable created above.
**/
header(sprintf("Location: %s", $insertGoTo));
/* this could also be acheived by simply using:
header("Location: CRcart/directory_list_logo.php");
exit();
*/
?>
Bookmarks