Hi
i have a page that passes an url string of
http://www.torbaypoetryfestival.co.uk/a ... 0_home.jpg
when my image is uploaded.
But i also have another form on this page that does not require the string, but when i submit this form the url string remains.
Is there a way of clearing the string and just having http://www.torbaypoetryfestival.co.uk/a ... _links.php when the form is submitted?
Cheers
Kev
clearing a url string
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: clearing a url string
Show the code.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
kevrelland
- Forum Commoner
- Posts: 73
- Joined: Mon Jan 08, 2007 7:41 am
Re: clearing a url string
this is part of the image upload form
and this is part of the update form
i want the second part to delete
and just have update_archive.php?
Cheers
Kev
Code: Select all
header('Location: update_archive.php?upload_message=image uploaded&upload_message_type=success&archive_id='.$_REQUEST["archive_id"].'&show_image='.$_FILES["image_upload_box"]["name"]);
exit;Code: Select all
$updateGoTo = "update_archive.php?";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}Code: Select all
?upload_message=image uploaded&upload_message_type=success&archive_id='.$_REQUEST["archive_id"].'&show_image='.$_FILES["image_upload_box"]["name"]);Cheers
Kev
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: clearing a url string
If I follow correctly just change:
To:
$_SERVER['QUERY_STRING'] is always SET but it may be EMPTY if there is no query string.
Code: Select all
if (isset($_SERVER['QUERY_STRING'])) {Code: Select all
if (!empty($_SERVER['QUERY_STRING'])) {mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
kevrelland
- Forum Commoner
- Posts: 73
- Joined: Mon Jan 08, 2007 7:41 am
Re: clearing a url string
I have tried that and i still get this
http://www.torbaypoetryfestival.co.uk/a ... 355_fr.jpg
but all i want to appear is http://www.torbaypoetryfestival.co.uk/a ... chives.php
here is the original code in full
http://www.torbaypoetryfestival.co.uk/a ... 355_fr.jpg
but all i want to appear is http://www.torbaypoetryfestival.co.uk/a ... chives.php
here is the original code in full
Code: Select all
<?php ini_set("memory_limit", "200000000"); // for large images so that we do not get "Allowed memory exhausted"?>
<?php
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;
}
}
$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 archive SET archive_heading=%s, archive_content=%s, archive_image=%s, archive_online=%s WHERE archive_id=%s",
GetSQLValueString($_POST['archive_heading'], "text"),
GetSQLValueString($_POST['archive_content'], "text"),
GetSQLValueString($_POST['archive_image'], "text"),
GetSQLValueString(isset($_POST['archive_online']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString($_POST['archive_id'], "int"));
mysql_select_db($database_poetry, $poetry);
$Result1 = mysql_query($updateSQL, $poetry) or die(mysql_error());
$updateGoTo = "list_archives.php?";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_archive_ammend = "-1";
if (isset($_GET['archive_id'])) {
$colname_archive_ammend = $_GET['archive_id'];
}
mysql_select_db($database_poetry, $poetry);
$query_archive_ammend = sprintf("SELECT * FROM archive WHERE archive_id = %s", GetSQLValueString($colname_archive_ammend, "int"));
$archive_ammend = mysql_query($query_archive_ammend, $poetry) or die(mysql_error());
$row_archive_ammend = mysql_fetch_assoc($archive_ammend);
$totalRows_archive_ammend = mysql_num_rows($archive_ammend);
// upload the file
if ((isset($_POST["submitted_form"])) && ($_POST["submitted_form"] == "image_upload_form")) {
// file needs to be jpg,gif,bmp,x-png and 4 MB max
if (($_FILES["image_upload_box"]["type"] == "image/jpeg" || $_FILES["image_upload_box"]["type"] == "image/pjpeg" || $_FILES["image_upload_box"]["type"] == "image/gif" || $_FILES["image_upload_box"]["type"] == "image/x-png") && ($_FILES["image_upload_box"]["size"] < 4000000))
{
// some settings
$max_upload_width = 2592;
$max_upload_height = 1944;
// if user chosed properly then scale down the image according to user preferances
if(isset($_REQUEST['max_width_box']) and $_REQUEST['max_width_box']!='' and $_REQUEST['max_width_box']<=$max_upload_width){
$max_upload_width = $_REQUEST['max_width_box'];
}
if(isset($_REQUEST['max_height_box']) and $_REQUEST['max_height_box']!='' and $_REQUEST['max_height_box']<=$max_upload_height){
$max_upload_height = $_REQUEST['max_height_box'];
}
// if uploaded image was JPG/JPEG
if($_FILES["image_upload_box"]["type"] == "image/jpeg" || $_FILES["image_upload_box"]["type"] == "image/pjpeg"){
$image_source = imagecreatefromjpeg($_FILES["image_upload_box"]["tmp_name"]);
}
// if uploaded image was GIF
if($_FILES["image_upload_box"]["type"] == "image/gif"){
$image_source = imagecreatefromgif($_FILES["image_upload_box"]["tmp_name"]);
}
// BMP doesn't seem to be supported so remove it form above image type test (reject bmps)
// if uploaded image was BMP
if($_FILES["image_upload_box"]["type"] == "image/bmp"){
$image_source = imagecreatefromwbmp($_FILES["image_upload_box"]["tmp_name"]);
}
// if uploaded image was PNG
if($_FILES["image_upload_box"]["type"] == "image/x-png"){
$image_source = imagecreatefrompng($_FILES["image_upload_box"]["tmp_name"]);
}
$remote_file = "../img/archives/".$_FILES["image_upload_box"]["name"];
imagejpeg($image_source,$remote_file,100);
chmod($remote_file,0644);
// get width and height of original image
list($image_width, $image_height) = getimagesize($remote_file);
if($image_width>$max_upload_width || $image_height >$max_upload_height){
$proportions = $image_width/$image_height;
if($image_width>$image_height){
$new_width = $max_upload_width;
$new_height = round($max_upload_width/$proportions);
}
else{
$new_height = $max_upload_height;
$new_width = round($max_upload_height*$proportions);
}
$new_image = imagecreatetruecolor($new_width , $new_height);
$image_source = imagecreatefromjpeg($remote_file);
imagecopyresampled($new_image, $image_source, 0, 0, 0, 0, $new_width, $new_height, $image_width, $image_height);
imagejpeg($new_image,$remote_file,100);
imagedestroy($new_image);
}
imagedestroy($image_source);
header('Location: update_archive.php?upload_message=image uploaded&upload_message_type=success&archive_id='.$_REQUEST["archive_id"].'&show_image='.$_FILES["image_upload_box"]["name"]);
exit;
}
else{
header("Location: update_archive.php?upload_message=make sure the file is jpg, gif or png and that is smaller than 4MB&upload_message_type=error");
exit;
}
}
?>-
kevrelland
- Forum Commoner
- Posts: 73
- Joined: Mon Jan 08, 2007 7:41 am
Re: clearing a url string
Bump
Any ideas, anybody?
Any ideas, anybody?