close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

URL redirect

Thread began 4/19/2010 3:57 am by gwh362692 | Last modified 9/09/2011 11:57 am by Ray Borduin | 2492 views | 7 replies |

gwh362692

URL redirect

Hi everyone,

I have a page on my site with a series of links that, when clicked, submit to a page (index.php) located in the same directory as itself, eg.

<li id="formal"><?php echo "<a href=\"$url_consumer/index.php?subcatID=6&itemTypeID=1\">Link 1</a>"?></li>

index.php contains only php and basically just queries a database and then loads the information into the current page with the links in it.

This page with all the links in it, also contains a form which when submitted, inserts the information into a database table and is then redirected to the current page:

$WA_redirectURL = "?sent=true";

On this current page, the first 'confirm' paragraph below is supposed to be shown:

<?php if(isset($_GET['sent']) && $_GET['sent'] == "true") { ?> <p id="confirm" style="background-color: #ded5b3; color: #00274c; padding: 5px; margin-bottom: 8px;"> <strong>Thank you – your details have been processed. </strong></p><?php } else { ?>
<p>Subscribe to our newsletter.</p>
<?php } ?>

It doesn't seem to work though because even though it's submitting to itself, it's not loading the current page because it needs certain information in the url string to do this (see the abovementioned link). When the submit button is pressed the following is at the end of the url:

index.php?sent=true

Since index.php is the php page that only queries the database the page shown is blank and not the page that was previously seen, before submitting the form.

I just wondered if anyone knows of a workaround for this problem?

Appreciate any advice.

Sign in to reply to this post

Jason ByrnesWebAssist

so basically your page is relying on the subcatID=6&itemTypeID=1 query string variables?



you can add those into the redirect so they are passed when the page is redirected:

php:
$WA_redirectURL = "?sent=true".((isset($_GET['subcatID']))?"&subcatID=".$_GET['subcatID']:"")."".((isset($_GET['itemTypeID']))?"&itemTypeID=".$_GET['itemTypeID']:"")."";
Sign in to reply to this post

gwh362692

That's great - thanks very much.

Just a related question if that's ok: as mentioned I have this form on each of the pages of the site that allows users to sign up for a newsletter. The following shows one of the input fields in the form:

<div> 
<input id="firstname" name="firstname" type="text" value="First name" onfocus="if (this.value == 'First name') this.value=''" onblur="if (this.value == '') this.value='First name'" />
<?php
if (ValidatedField('index_965','index_965')) {
if ((strpos((",".ValidatedField("index_965","index_965").","), "," . "1" . ",") !== false || "1" == "")) {
if (!(false)) {
?>
<span style="color: red; margin: 0; padding: 0;"> First name is required </span>
<?php //WAFV_Conditional index.php index_965(1:)
}
}
}?>
</div>




I used a Data Assist insert server behaviour to insert the contents of the form into a DB table. The following is the code produced by the server behaviour:

<?php require_once("/home/site/private/newsletter.php"); ?>
<?php require_once("../WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php require_once("../WA_ValidationToolkit/WAVT_Scripts_PHP.php"); ?>
<?php require_once("../WA_ValidationToolkit/WAVT_ValidatedForm_PHP.php"); ?>
<?php
if (isset($_POST["submit"])) {
$WAFV_Redirect = "";
$_SESSION['WAVT_index_965_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}

$WAFV_Errors = "";
$WAFV_Errors .= WAValidateRQ(((isset($_POST['firstname']) && $_POST['firstname'] != "First Name")?$_POST['firstname']:"") . "",false,1);
$WAFV_Errors .= WAValidateRQ(((isset($_POST['lastname']) && $_POST['lastname'] != "Last Name")?$_POST['lastname']:"") . "",false,2);
$WAFV_Errors .= WAValidateEM(((isset($_POST["email"]))?$_POST["email"]:"") . "",true,3);

if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"index_965");
}
}
?>
<?php
// WA Application Builder Insert
if (isset($_POST["submit"])) // Trigger
{
$WA_connection = $newsletter;
$WA_table = "subscriptions";
$WA_sessionName = "subscriptions_subID";
$WA_redirectURL = "";
$WA_keepQueryString = false;
$WA_indexField = "subID";
$WA_fieldNamesStr = "firstname|lastname|email";
$WA_fieldValuesStr = "".((isset($_POST["firstname"]))?$_POST["firstname"]:"") ."" . "|" . "".((isset($_POST["lastname"]))?$_POST["lastname"]:"") ."" . "|" . "".((isset($_POST["email"]))?$_POST["email"]:"") ."";
$WA_columnTypesStr = "',none,''|',none,''|',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_newsletter;
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);
}
}
?>



Since the newsletter form is potentially open to a sql injection, I wondered if the code produced by the server behaviour contained any protection against this security risk. As I don't understand a lot of the code produced, could you tell me if it has taken care of it or whether this is something extra I need to add to the input fields?

Sign in to reply to this post

Jason ByrnesWebAssist

DataAssist does include code to help prevent SQL Injection attacks. using form validation is also a good idea.

In your form validation, you should be validating the data types for the different fields. For example, I see you have applied Email Validation to the email address form field, but only Required Validation to the First name and last name fields.

It would be a good idea to use alpha numeric validation on those fields instead to restrict special characters from being entered.

validating on the data type can help further prevent against SQL Injections.

Sign in to reply to this post

gwh362692

Ok thanks for the information.

Sign in to reply to this post

Web Designer Troy

Data Injection Hack

I was hacked (sql injection) through address bar using the dataassist app. Is there any protection on a level where I can't validate. Please help.

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

Ray BorduinWebAssist

We looked into this problem over the phone. It is not an issue with our software.

The injection hole was due to having built the recordsets with DW8. We solved it by opening up the recordset SB and reapplying.

Sign in to reply to this post
Did this help? Tips are appreciated...

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...