close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

redirect not working

Thread began 5/25/2011 12:29 pm by mr hankey | Last modified 7/31/2013 9:33 am by dDog | 2189 views | 8 replies |

mr hankey

redirect not working

hi,

my data assist page is not redirecting:

code is:

<?php
// WA Application Builder Insert
if (isset($_POST["OK"])) // Trigger
{
$WA_connection = $cbank;
$WA_table = "parts";
$WA_sessionName = "parts_PartID";
$WA_redirectURL = "parts_Results.php";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_indexField = "PartID";
$WA_fieldNamesStr = "PartName|SupplierID|PartSerialNumber";
$WA_fieldValuesStr = "".((isset($_POST["PartName"]))?$_POST["PartName"]:"") ."" . "|" . "".((isset($_POST["Supplier"]))?$_POST["Supplier"]:"") ."" . "|" . "".((isset($_POST["PartSerialNumber"]))?$_POST["PartSerialNumber"]:"") ."";
$WA_columnTypesStr = "',none,''|none,none,NULL|',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_cbank;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = mysql_insert_id();
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>

this happens on a blank white page or any page for that fact.

is there something wrong with the code it is producing?

the form action is set to POST.

many thanks

Sign in to reply to this post

Jason ByrnesWebAssist

is it inserting the data to the database?

add the following code at line 1 to see if a php error is occurring to prevent the redirect:

php:
<?php 
error_reporting
(E_ALL);
ini_set('display_errors','on');
?>
Sign in to reply to this post

mr hankey

no errors show up and i just tested and it insets into the database fine.

so the isnert is working perfectly it is just the redirect that does not.

it just adds a "?" to the page name after insert.

many thanks

Sign in to reply to this post

Jason ByrnesWebAssist

I have created a support ticket so we can look into this issue further.

To view and edit your support ticket, please log into your support history:
supporthistory.php

If anyone else is experiencing this same issue, please append to this thread.

Sign in to reply to this post

dDog

Exact same issue

Our product insert page uses both "insert record" and "insert multiple records" (for multiple categories). The products insert correctly, but does not redirect to products_Results.php.

We get error message:

Warning: Cannot modify header information - headers already sent by (output started at /home2/ahsafety/public_html/admin/products_Insert.php:47) in /home2/ahsafety/public_html/admin/products_Insert.php on line 426

Line 426 is multiple insert:

header("Location: ".$WA_redirectURL);

Sign in to reply to this post

Jason ByrnesWebAssist

This error is caused by output to the page before the header or session_start() functions are used.

if you read the errror carefully, it states that the out put is at line 47
(output started at /home2/ahsafety/public_html/admin/products_Insert.php:47)


line 426 is just where the header function occurs.

in this case, the probelm is a blank line betweren php code blocks.

lines 45 - 47 are:

php:
?>


<?php




there should not be a blank line after the closing php tag at line 45 and the opening php tag at line 47.

change that to:

php:
?>

<?php
Sign in to reply to this post

dDog

Doh!

Amazing how a few poorly placed blank lines can cause so much havoc. :-)

I made the correction on lines 45 - 47, and I found another blank line 391-393. After correcting both and searching for other blank lines, I uploaded and tried to insert a product again.

This time we get the error:

Warning: Cannot modify header information - headers already sent by (output started at /home2/ahsafety/public_html/admin/products_Insert.php:162) in /home2/ahsafety/public_html/admin/products_Insert.php on line 424

Looking carefully at lines 161-165:

php:
<h1 class="text">

<?php if(WA_Auth_RulePasses("Administrator")){ // Begin Show Region ?>
Administrator
<?php // End Show Region ?>
</h1>



This code are part of the template, and are grayed out. Is there a change I need to make the template?

Sign in to reply to this post

Jason ByrnesWebAssist

you have the insert code in the page body at lines 360 - 429.

that code should be above the doctype tag.

Sign in to reply to this post

dDog

Wah hoo!!!

It works now! Thank you for taking time to help squash these bugs. I know better now what to look for in the future.

I had moved the insert functions at the end the code thinking that would help, but I it makes sense that the insert code would have to be at the top where databridge initially placed it.

Many thanks!

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...