close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Quick question about order of PHP code at start of page

Thread began 8/01/2012 1:53 pm by iainmacdonald331081 | Last modified 8/02/2012 12:05 pm by iainmacdonald331081 | 826 views | 2 replies

iainmacdonald331081

Quick question about order of PHP code at start of page

I have DB Update page that is just being used to add images and a PDF to a record just created on a previous page. The set up is a bit convoluted, but this page is the third of a sequence.

In addition to the DB code to update the record and upload the files, there is some code which inserts some keywords into a related table, using the code below:

<?php

/********************
*
*insert Lodge Activities into the LodgeActivities table
*
********************/

//sql insert string

$sql = "INSERT INTO ItineraryActivities (ItineraryID, ActivityID) VALUES ";

$ck = $_GET['ckbox'];

//loops though the profiles adding the insert string each profile row

foreach ($ck As $GetIndex => $GetValue){
if ($GetValue=='on'){
$sql .= "('{$_GET['ItineraryID']}', '$GetIndex'), ";
}
}

//trims the end ,

$sql = rtrim($sql," ,") ;

//inserts data

mysql_select_db($database_connSafari, $connSafari); mysql_query($sql); echo mysql_error();
?>



This code appears after the DB Update / Upload code, ie immediately before the <DOCTYPE> declaration.

So when the page first loads, it ignores the DB Update / Upload code, and executes the code above, correctly inserting the keywords.

However, when the form is submitted, and executes the DB Update / Upload code, its also executing the code above a again, and creating duplicate records.

Should that happen, or should that part not be executed on form submission, because it would only get as far as the redirect in the DB Update / Upload code before it?

Hope that makes sense - I've attached the page for reference.

Attached Files
index2.zip

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