473,386 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

PHP page get executed twice

I have a problem with a PHP page that seems to get executed twice.

I am running PHP5 ISAPI on 2003 server.

The script is a PHP page with a form. When the form is submitted one record
have to be inserted in the database but when i look at the database after
submitting the form there are two(!) records inserted so it looks like the
script is executed twice.

Can this be a proxy-setting or an ISA`server related subject???

Anyone ever experienced similair problems?

Marcel
Jun 1 '06 #1
8 4004
Marcel wrote:
I have a problem with a PHP page that seems to get executed twice.

I am running PHP5 ISAPI on 2003 server.

The script is a PHP page with a form. When the form is submitted one
record have to be inserted in the database but when i look at the database
after submitting the form there are two(!) records inserted so it looks
like the script is executed twice.
Hi Marcel,

Sorry to say, but this is most likely a problem in your code, not in the
server/webserver/PHP.

Are you maybe sending the form to the same page that produces the form?
If so, are you sure your checks for a posting and the following DB-inserts
are working as expected?

Maybe add a few echo's before inserting and check if they show up
unexpectedly?

And you can always show us some code (preferable stripped down to the core).

Can this be a proxy-setting or an ISA`server related subject???
I don't think so, but then again, I don't know what an ISAserver is.

Anyone ever experienced similair problems?
Only under Tomcat with Java (which creates a complete copy of the webapp for
purposes still mysterious to me), never with PHP under *nix or ISS.

Marcel


Regards,
Erwin Moller
Jun 1 '06 #2
Marcel wrote:
I have a problem with a PHP page that seems to get executed twice.


Have you check your own code? Maybe you execute twice.

regards,
Lorento
--
http://www.mastervb.net
http://www.padbuilder.com , http://www.immersivelounge.com

Jun 1 '06 #3

"Erwin Moller"
<si******************************************@spam yourself.com> schreef in
bericht news:44***********************@news.xs4all.nl...
Marcel wrote:
I have a problem with a PHP page that seems to get executed twice.

I am running PHP5 ISAPI on 2003 server.

The script is a PHP page with a form. When the form is submitted one
record have to be inserted in the database but when i look at the
database
after submitting the form there are two(!) records inserted so it looks
like the script is executed twice.
Hi Marcel,

Sorry to say, but this is most likely a problem in your code, not in the
server/webserver/PHP.


Yeah, maybe you are right but i am an experienced coder and i have been
searching for 2 days now where this is coming from.

I will post my code but it's kind of advanced PHP5 OOP stuff.

Are you maybe sending the form to the same page that produces the form?
Yes i am posting to the same page. So the page takes care of the database
activity too
If so, are you sure your checks for a posting and the following DB-inserts
are working as expected?
I have made a SQL class that takes care of the inserts and updates in the MS
SQL Server database

Maybe add a few echo's before inserting and check if they show up
unexpectedly?
I have put a mail() in my page to check and i receive a testmail twice... so
that makes me again think the page is executed twice.......

And you can always show us some code (preferable stripped down to the
core).

Can this be a proxy-setting or an ISA`server related subject???


I don't think so, but then again, I don't know what an ISAserver is.

Anyone ever experienced similair problems?


Only under Tomcat with Java (which creates a complete copy of the webapp
for
purposes still mysterious to me), never with PHP under *nix or ISS.

Marcel


Regards,
Erwin Moller

Jun 1 '06 #4
### mainpage

<?php
#error_reporting(E_ALL); // alle fouten weergeven
#error_reporting(0); // geen fouten weergeven
error_reporting(E_ALL ^ E_NOTICE); // alle fouten behalve notices weergeven

header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past

# database connection
require_once("../Connections/connect_communication.php");

# mssql_escape function
require_once("../php_functions/mssql_escape.php");

#
require_once("../php_functions/validator.php");

#
require_once("../php_functions/sql.php");

$uploaddir = 'C:/Inetpub/domain.com/newsletters/uploaded_images/';
mail("in**@mediaquest.nl","Test Newsletters",$_SERVER['HTTP_REFERER'].' -
'.$_SERVER['REMOTE_HOST'].' - '.$_SERVER['REQUEST_URI']);
function img_exists($filename_to_check) {

$SQLcheck = "SELECT id FROM com_images WHERE img_original_name =
'".trim($filename_to_check)."'";

#echo '<hr />'.$SQLcheck.'<hr />';

$RESULTcheck = mssql_query($SQLcheck);

if(mssql_num_rows($RESULTcheck) > 0) {
return true;
} else {
return false;
}

}

if($_POST['Submit']) {

rule(!$_POST['nwi_name'],
"You did not fill in a name for this newsitem");

/*
rule(isset($_FILES['nwi_image1']['name']) &&
img_exists($_FILES['nwi_image1']['name']),
"The filename of Image 1 that you are trying to upload allready exists");

rule(isset($_FILES['nwi_image2']['name']) &&
img_exists($_FILES['nwi_image2']['name']),
"The filename of Image 2 that you are trying to upload allready exists");

rule(isset($_FILES['nwi_image3']['name']) &&
img_exists($_FILES['nwi_image3']['name']),
"The filename of Image 3 that you are trying to upload allready exists");

rule(isset($_FILES['nwi_image4']['name']) &&
img_exists($_FILES['nwi_image4']['name']),
"The filename of Image 4 that you are trying to upload allready exists");
*/

# validation of userinput
if(getError()) {

# zo ja error message toekennen aan $err_msg
$err_msg = getError();

# leeg maken array validations
clearValidations();

$tmp_nwi_name = $_POST['nwi_name'];
$tmp_nwi_description = $_POST['nwi_description'];

$tmp_nwi_heading = $_POST['nwi_heading'];

$tmp_nwi_subheading1 = $_POST['nwi_subheading1'];
$tmp_nwi_image1 = $_POST['nwi_image1'];
$tmp_nwi_alignment1 = $_POST['nwi_alignment1'];
$tmp_nwi_text1 = $_POST['nwi_text1'];

$tmp_nwi_subheading2 = $_POST['nwi_subheading2'];
$tmp_nwi_image2 = $_POST['nwi_image2'];
$tmp_nwi_alignment2 = $_POST['nwi_alignment2'];
$tmp_nwi_text2 = $_POST['nwi_text2'];

$tmp_nwi_subheading3 = $_POST['nwi_subheading3'];
$tmp_nwi_image3 = $_POST['nwi_image3'];
$tmp_nwi_alignment3 = $_POST['nwi_alignment3'];
$tmp_nwi_text3 = $_POST['nwi_text3'];

$tmp_nwi_subheading4 = $_POST['nwi_subheading4'];
$tmp_nwi_image4 = $_POST['nwi_image4'];
$tmp_nwi_alignment4 = $_POST['nwi_alignment4'];
$tmp_nwi_text4 = $_POST['nwi_text4'];
} else {
# all userinput proofed ok, let's write data to database

#echo '<hr />userinput ok!!!<hr />';

clearValidations();

# indien er images geupload worden
# img 1
if($_FILES['nwi_image1']['name']) {

$tsql_img1 = new sql('com_images');

$tsql_img1->add("img_original_name",$_FILES['nwi_image1']['name']);
$tsql_img1->add("img_tmp_name",$_FILES['nwi_image1']['tmp_name']);
$tsql_img1->add("img_type",$_FILES['nwi_image1']['type']);
if(GetImageSize($_FILES['nwi_image1']['tmp_name'])) {

$img_dimensions = GetImageSize($_FILES['nwi_image1']['tmp_name']);

$tsql_img1->add("img_width",$img_dimensions[0]);
$tsql_img1->add("img_height",$img_dimensions[1]);

}
$tsql_img1->add("img_bytes",$_FILES['nwi_image1']['size']);

# C:\Inetpub\domain.com\newsletters\uploaded_images

if(move_uploaded_file($_FILES['nwi_image1']['tmp_name'],
$uploaddir.$_FILES["nwi_image1"]["name"])) {

$tsql_img1->add("img_system_name","http://www.domain.com/newsletters/uploaded_images/".$_FILES["nwi_image1"]["name"]);

}

$tsql_img1->insert();

$nwi_image1_id = $tsql_img1->getLastID();

unset($tsql_img1);

}

# indien er images geupload worden
# img 2
if($_FILES['nwi_image2']['name']) {

$tsql_img2 = new sql('com_images');

$tsql_img2->add("img_original_name",$_FILES['nwi_image2']['name']);
$tsql_img2->add("img_tmp_name",$_FILES['nwi_image2']['tmp_name']);
$tsql_img2->add("img_type",$_FILES['nwi_image2']['type']);
if(GetImageSize($_FILES['nwi_image2']['tmp_name'])) {

$img_dimensions = GetImageSize($_FILES['nwi_image2']['tmp_name']);

$tsql_img2->add("img_width",$img_dimensions[0]);
$tsql_img2->add("img_height",$img_dimensions[1]);

}
$tsql_img2->add("img_bytes",$_FILES['nwi_image2']['size']);

# C:\Inetpub\domain.com\newsletters\uploaded_images

if(move_uploaded_file($_FILES['nwi_image2']['tmp_name'],
$uploaddir.$_FILES["nwi_image2"]["name"])) {

$tsql_img2->add("img_system_name","http://www.domain.com/newsletters/uploaded_images/".$_FILES["nwi_image2"]["name"]);

}

$tsql_img2->insert();

$nwi_image2_id = $tsql_img2->getLastID();

unset($tsql_img2);

}

# indien er images geupload worden
# img 3
if($_FILES['nwi_image3']['name']) {

$tsql_img3 = new sql('com_images');

$tsql_img3->add("img_original_name",$_FILES['nwi_image3']['name']);
$tsql_img3->add("img_tmp_name",$_FILES['nwi_image3']['tmp_name']);
$tsql_img3->add("img_type",$_FILES['nwi_image3']['type']);
if(GetImageSize($_FILES['nwi_image3']['tmp_name'])) {

$img_dimensions = GetImageSize($_FILES['nwi_image3']['tmp_name']);

$tsql_img3->add("img_width",$img_dimensions[0]);
$tsql_img3->add("img_height",$img_dimensions[1]);

}
$tsql_img3->add("img_bytes",$_FILES['nwi_image3']['size']);

# C:\Inetpub\domain.com\newsletters\uploaded_images

if(move_uploaded_file($_FILES['nwi_image3']['tmp_name'],
$uploaddir.$_FILES["nwi_image3"]["name"])) {

$tsql_img3->add("img_system_name","http://www.domain.com/newsletters/uploaded_images/".$_FILES["nwi_image3"]["name"]);

}

$tsql_img3->insert();

$nwi_image3_id = $tsql_img3->getLastID();

unset($tsql_img3);

}

# indien er images geupload worden
# img 4
if($_FILES['nwi_image4']['name']) {

$tsql_img4 = new sql('com_images');

$tsql_img4->add("img_original_name",$_FILES['nwi_image4']['name']);
$tsql_img4->add("img_tmp_name",$_FILES['nwi_image4']['tmp_name']);
$tsql_img4->add("img_type",$_FILES['nwi_image4']['type']);
if(GetImageSize($_FILES['nwi_image4']['tmp_name'])) {

$img_dimensions = GetImageSize($_FILES['nwi_image4']['tmp_name']);

$tsql_img4->add("img_width",$img_dimensions[0]);
$tsql_img4->add("img_height",$img_dimensions[1]);

}
$tsql_img4->add("img_bytes",$_FILES['nwi_image4']['size']);

# C:\Inetpub\domain.com\newsletters\uploaded_images

if(move_uploaded_file($_FILES['nwi_image4']['tmp_name'],
$uploaddir.$_FILES["nwi_image4"]["name"])) {

$tsql_img4->add("img_system_name","http://www.domain.com/newsletters/uploaded_images/".$_FILES["nwi_image4"]["name"]);

}

$tsql_img4->insert();

$nwi_image4_id = $tsql_img4->getLastID();

unset($tsql_img4);

}


$tsql = new sql('com_newsitems');
$tsql->add("nwi_name",$_POST['nwi_name']);
$tsql->add("nwi_description",$_POST['nwi_description']);

$tsql->add("nwi_heading",$_POST['nwi_heading']);

$tsql->add("nwi_subheading1",$_POST['nwi_subheading1']);
if($_FILES['nwi_image1']['name']) {
$tsql->add("nwi_image1",$nwi_image1_id);
$tsql->add("nwi_alignment1",$_POST['nwi_alignment1']);
} else {

if(!$_POST['nwi_image1_del']) {
$tsql->exclude("nwi_image1");
}

}
$tsql->add("nwi_text1",$_POST['nwi_text1']);

$tsql->add("nwi_subheading2",$_POST['nwi_subheading2']);
if($_FILES['nwi_image2']['name']) {
$tsql->add("nwi_image2",$nwi_image2_id);
$tsql->add("nwi_alignment2",$_POST['nwi_alignment2']);
} else {

if(!$_POST['nwi_image2_del']) {
$tsql->exclude("nwi_image2");
}

}
$tsql->add("nwi_text2",$_POST['nwi_text2']);

$tsql->add("nwi_subheading3",$_POST['nwi_subheading3']);
if($_FILES['nwi_image3']['name']) {
$tsql->add("nwi_image3",$nwi_image3_id);
$tsql->add("nwi_alignment3",$_POST['nwi_alignment3']);
} else {

if(!$_POST['nwi_image3_del']) {
$tsql->exclude("nwi_image3");
}

}
$tsql->add("nwi_text3",$_POST['nwi_text3']);

$tsql->add("nwi_subheading4",$_POST['nwi_subheading4']);
if($_FILES['nwi_image4']['name']) {
$tsql->add("nwi_image4",$nwi_image4_id);
$tsql->add("nwi_alignment4",$_POST['nwi_alignment4']);
} else {

if(!$_POST['nwi_image4_del']) {
$tsql->exclude("nwi_image4");
}

}
$tsql->add("nwi_text4",$_POST['nwi_text4']);
$tsql->exclude("id");
$tsql->exclude("nwi_date_created");
$tsql->update("id",$_POST['id']);

unset($tsql);

unset($_FILES);

header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Location:newsitems.php");
#echo $tsql->getSQLupdate();

}

} else {

$SQL = "SELECT * FROM com_newsitems WHERE id = ".$_GET['id'];

$RESULT = mssql_query($SQL);

$RECORD = mssql_fetch_array($RESULT);

$tmp_nwi_name = $RECORD['nwi_name'];
$tmp_nwi_description = $RECORD['nwi_description'];

$tmp_nwi_heading = $RECORD['nwi_heading'];

$tmp_nwi_subheading1 = $RECORD['nwi_subheading1'];
$tmp_nwi_image1 = $RECORD['nwi_image1'];
if($RECORD['nwi_image1']) {

$SQLimg1 = "SELECT img_original_name FROM com_images WHERE id =
".$RECORD['nwi_image1'];

$RESULTimg1 = mssql_query($SQLimg1);

if(mssql_num_rows($RESULTimg1) > 0) {

$RECORDimg1 = mssql_fetch_array($RESULTimg1);

$nwi_image1_name = $RECORDimg1['img_original_name'];

}

}

$tmp_nwi_alignment1 = $RECORD['nwi_alignment1'];
$tmp_nwi_text1 = $RECORD['nwi_text1'];

$tmp_nwi_subheading2 = $RECORD['nwi_subheading2'];
$tmp_nwi_image2 = $RECORD['nwi_image2'];

if($RECORD['nwi_image2']) {

$SQLimg2 = "SELECT img_original_name FROM com_images WHERE id =
".$RECORD['nwi_image2'];

$RESULTimg2 = mssql_query($SQLimg2);

if(mssql_num_rows($RESULTimg2) > 0) {

$RECORDimg2 = mssql_fetch_array($RESULTimg2);

$nwi_image2_name = $RECORDimg2['img_original_name'];

}

}

$tmp_nwi_alignment2 = $RECORD['nwi_alignment2'];
$tmp_nwi_text2 = $RECORD['nwi_text2'];

$tmp_nwi_subheading3 = $RECORD['nwi_subheading3'];
$tmp_nwi_image3 = $RECORD['nwi_image3'];

if($RECORD['nwi_image3']) {

$SQLimg3 = "SELECT img_original_name FROM com_images WHERE id =
".$RECORD['nwi_image3'];

$RESULTimg3 = mssql_query($SQLimg3);

if(mssql_num_rows($RESULTimg3) > 0) {

$RECORDimg3 = mssql_fetch_array($RESULTimg3);

$nwi_image3_name = $RECORDimg3['img_original_name'];

}

}

$tmp_nwi_alignment3 = $RECORD['nwi_alignment3'];
$tmp_nwi_text3 = $RECORD['nwi_text3'];

$tmp_nwi_subheading4 = $RECORD['nwi_subheading4'];
$tmp_nwi_image4 = $RECORD['nwi_image4'];

if($RECORD['nwi_image4']) {

$SQLimg4 = "SELECT img_original_name FROM com_images WHERE id =
".$RECORD['nwi_image4'];

$RESULTimg4 = mssql_query($SQLimg4);

if(mssql_num_rows($RESULTimg4) > 0) {

$RECORDimg4 = mssql_fetch_array($RESULTimg4);

$nwi_image4_name = $RECORDimg4['img_original_name'];

}

}

$tmp_nwi_alignment4 = $RECORD['nwi_alignment4'];
$tmp_nwi_text4 = $RECORD['nwi_text4'];

$tmp_id = $_GET['id'];

}

?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>domain.com CMS Newsletters</title>
<link href="styles/newslettercms.css" rel="stylesheet" type="text/css">
</head>
<body vlink="#000066" alink="#FF3300">
<a name="Top"></a>
<form action="test2.php" method="post" enctype="multipart/form-data"
name="form1">
<input type="hidden" name="id" value="<?php echo $tmp_id; ?>">
<table width="748" border="0" align="center" cellpadding="1" cellspacing="1"
bgcolor="#003875">
<tr>
<td width="744" bgcolor="#ffffff">
<table width="744" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="166" height="79">
<div align="center"><a href="http://www.domain.com"><img
src="images/mv-logo.gif" alt="domain.com" width="153" height="50"
border="0"></a></div>
</td>
<td width="578" align="right"><img src="images/header-1.jpg"
alt="domain.com" width="550" height="79"></td>
</tr>
<tr>
<td colspan="2" bgcolor="#003875">
<table width="744" border="0" cellspacing="0" cellpadding="4">
<tr>
<td width="468"><font color="#ffffff" face="Verdana, Arial, Helvetica,
sans-serif" size="2"><strong>domain.com
CMS Newsletters</strong></font></td>
<td width="260" align="right"><font color="#ffffff" face="Verdana, Arial,
Helvetica, sans-serif" size="2">Welcome
administrator</font></td>
</tr>
</table>
</td>
</tr>
</table>
<table width="744" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="748" valign="top">
<table width="744" border="0" align="center" cellpadding="4"
cellspacing="0">
<tr>
<td valign="top" align="center" bgcolor="#f1f1f1"><font color="#003875"
face="Arial, Helvetica, sans-serif" size="2"> <strong>|</strong> <a
href="emailaddresses.php">View/manage
e-mail adressess</a> <strong>|</strong> <a
href="newsletters.php">View/manage newsletters</a> <strong>|</strong> <a
href="newsitems.php">View/manage
newsitems</a> <strong>|</strong> <a href="#">View userhistory</a>
<strong>|</strong> </font></td>
</tr>
</table>
<br>
<table width="736" border="0" align="center" cellpadding="2"
cellspacing="0">
<tr>
<td width="732"><font color="#003875" face="Arial, Helvetica, sans-serif"
size="3"><strong>Edit newsitem </strong></font></td>
</tr>
<tr>
<td align="right"><font color="#000000" face="Arial, Helvetica, sans-serif"
size="2"><a href="addnewsitem.php">create new newsitem</a>
&raquo;</font></td>
</tr>
<?php
if($err_msg) {
?>
<tr>
<td><font color="#FF0000" face="Arial, Helvetica, sans-serif"
size="2"><strong><?php echo $err_msg; ?></strong></font></td>
</tr>
<?php
}
?>
</table>
<font face="Arial, Helvetica, sans-serif">
<table class="table3">
<tr>
<td>Newsitem name</td>
<td>
<input name="nwi_name" type="text" class="nwi_title" id="nwi_name"
value="<?php echo $tmp_nwi_name; ?>">
</td>
</tr>
<tr>
<td>Newsitem description</td>
<td>
<textarea name="nwi_description" id="nwi_description" cols="35"
rows="6"><?php echo $tmp_nwi_description; ?></textarea>
</td>
</tr>

<tr>
<td colspan="2"><hr /></td>
</tr>
<tr>
<td>Heading</td>
<td>
<input name="nwi_heading" type="text" class="nwl_nwi_name" id="nwi_heading"
value="<?php echo $tmp_nwi_heading; ?>">
</td>
</tr>
<tr>
<td colspan="2"><hr /></td>
</tr>

<!-- 1 -->
<tr>
<td>Subheading 1</td>
<td>
<input name="nwi_subheading1" type="text" class="nwl_nwi_name"
id="nwi_subheading1" value="<?php echo $tmp_nwi_subheading1; ?>">
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<?php echo $nwi_image1_name; ?><input name="nwi_image1_del" type="checkbox"
id="nwi_image1_del" value="<?php echo $nwi_image1_name; ?>">
</td>
</tr>
<tr>
<td>Image 1</td>
<td>
<input name="nwi_image1" type="file" class="nwl_nwi_name" id="nwi_image1"
value="<?php echo $tmp_nwi_image1; ?>">
</td>
</tr>
<tr>
<td>Horzontal alignment 1</td>
<td>
<input name="nwi_alignment1" type="radio" value="L" <?php
if($tmp_nwi_alignment1 == 'L') {echo 'checked';} ?>> Left
<input name="nwi_alignment1" type="radio" value="C" <?php
if($tmp_nwi_alignment1 == 'C') {echo 'checked';} ?>> Center
<input name="nwi_alignment1" type="radio" value="R" <?php
if($tmp_nwi_alignment1 == 'R') {echo 'checked';} ?>> Right
</td>
</tr>
<tr>
<td>Text 1</td>
<td>
<textarea name="nwi_text1" id="nwi_text1" cols="35" rows="6"><?php echo
$tmp_nwi_text1; ?></textarea>
</td>
</tr>
<tr>
<td colspan="2"><hr /></td>
</tr>

<!-- 2 -->
<tr>
<td>Subheading 2</td>
<td>
<input name="nwi_subheading2" type="text" class="nwl_nwi_name"
id="nwi_subheading2" value="<?php echo $tmp_nwi_subheading2; ?>">
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<?php echo $nwi_image2_name; ?><input name="nwi_image2_del" type="checkbox"
id="nwi_image2_del" value="<?php echo $nwi_image2_name; ?>">
</td>
</tr>
<tr>
<td>Image 2</td>
<td>
<input name="nwi_image2" type="file" class="nwl_nwi_name" id="nwi_image2"
value="<?php echo $tmp_nwi_image2; ?>">
</td>
</tr>
<tr>
<td>Horzontal alignment 2</td>
<td>
<input name="nwi_alignment2" type="radio" value="L" <?php
if($tmp_nwi_alignment2 == 'L') {echo 'checked';} ?>> Left
<input name="nwi_alignment2" type="radio" value="C" <?php
if($tmp_nwi_alignment2 == 'C') {echo 'checked';} ?>> Center
<input name="nwi_alignment2" type="radio" value="R" <?php
if($tmp_nwi_alignment2 == 'R') {echo 'checked';} ?>> Right
</td>
</tr>
<tr>
<td>Text 2</td>
<td>
<textarea name="nwi_text2" id="nwi_text2" cols="35" rows="6"><?php echo
$tmp_nwi_text2; ?></textarea>
</td>
</tr>
<tr>
<td colspan="2"><hr /></td>
</tr>
<!-- 3 -->
<tr>
<td>Subheading 3</td>
<td>
<input name="nwi_subheading3" type="text" class="nwl_nwi_name"
id="nwi_subheading3" value="<?php echo $tmp_nwi_subheading3; ?>">
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<?php echo $nwi_image3_name; ?><input name="nwi_image3_del" type="checkbox"
id="nwi_image3_del" value="<?php echo $nwi_image3_name; ?>">
</td>
</tr>
<tr>
<td>Image 3</td>
<td>
<input name="nwi_image3" type="file" class="nwl_nwi_name" id="nwi_image3"
value="<?php echo $tmp_nwi_image3; ?>">
</td>
</tr>
<tr>
<td>Horzontal alignment 3</td>
<td>
<input name="nwi_alignment3" type="radio" value="L" <?php
if($tmp_nwi_alignment3 == 'L') {echo 'checked';} ?>> Left
<input name="nwi_alignment3" type="radio" value="C" <?php
if($tmp_nwi_alignment3 == 'C') {echo 'checked';} ?>> Center
<input name="nwi_alignment3" type="radio" value="R" <?php
if($tmp_nwi_alignment3 == 'R') {echo 'checked';} ?>> Right
</td>
</tr>
<tr>
<td>Text 3</td>
<td>
<textarea name="nwi_text3" id="nwi_text3" cols="35" rows="6"><?php echo
$tmp_nwi_text3; ?></textarea>
</td>
</tr>
<tr>
<td colspan="2"><hr /></td>
</tr>

<!-- 4 -->
<tr>
<td>Subheading 4</td>
<td>
<input name="nwi_subheading4" type="text" class="nwl_nwi_name"
id="nwi_subheading4" value="<?php echo $tmp_nwi_subheading4; ?>">
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<?php echo $nwi_image4_name; ?><input name="nwi_image4_del" type="checkbox"
id="nwi_image4_del" value="<?php echo $nwi_image4_name; ?>">
</td>
</tr>
<tr>
<td>Image 4</td>
<td>
<input name="nwi_image4" type="file" class="nwl_nwi_name" id="nwi_image4"
value="<?php echo $tmp_nwi_image4; ?>">
</td>
</tr>
<tr>
<td>Horzontal alignment 4</td>
<td>
<input name="nwi_alignment4" type="radio" value="L" <?php
if($tmp_nwi_alignment4 == 'L') {echo 'checked';} ?>> Left
<input name="nwi_alignment4" type="radio" value="C" <?php
if($tmp_nwi_alignment4 == 'C') {echo 'checked';} ?>> Center
<input name="nwi_alignment4" type="radio" value="R" <?php
if($tmp_nwi_alignment4 == 'R') {echo 'checked';} ?>> Right
</td>
</tr>
<tr>
<td>Text 4</td>
<td>
<textarea name="nwi_text4" id="nwi_text4" cols="35" rows="6"><?php echo
$tmp_nwi_text4; ?></textarea>
</td>
</tr>
<tr>
<td colspan="2"><hr /></td>
</tr>

<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input type="submit" name="Submit" value="gereed &raquo;">
</td>
</tr>
</table>
</font> <br>
<br>
</td>
</tr>
<tr>
<td bgcolor="#008C9A">&nbsp;</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
### sql class

# class column om info over columns in op te slaan
class column {

var $name; # columnname
var $xtype; # datatype
var $colid; # positie
var $isnullable; # of er null in deze column mag staan
var $newval; # value die geinsert of updated moet worden

}

# class sql
class sql {

var $table; # de table waar dit sql-object betrekking op heeft
var $columns = array(); # de columns in deze table, in deze array worden
alle columns uit de tabel opgeslagen, per column wordt een column-object
aangemaakt die diverse info bevat over de column
var $excluded_columns = array();
# default constructor, neemt als argument de tabel waarop dit sql object
betrekking heeft
public function __construct($table) {

$this->table = $table;

# sql statement om info over columns in deze tabel te verkrijgen
$SQLsys = "SELECT syscolumns.name, syscolumns.xtype, syscolumns.colid,
syscolumns.isnullable FROM sysobjects INNER JOIN syscolumns ON sysobjects.id
= syscolumns.id WHERE (sysobjects.name = N'".$this->table."')";

$RESULTsys = mssql_query($SQLsys);

# while-loop om alle info van de diverse columns uit te lezen en toe te
kennen aan column-objecten
while($RECORDsys = mssql_fetch_array($RESULTsys)) {

# aanmaken nieuw column object
$tmp_column = new column;

# toekennen waarden uit database aan net gemaakte column-object
$tmp_column->name = $RECORDsys['name'];
$tmp_column->xtype = $RECORDsys['xtype'];
$tmp_column->colid = $RECORDsys['colid'];
$tmp_column->isnullable = $RECORDsys['isnullable'];

# net gemaakte column-object toevoegen aan columns array
$this->columns[$RECORDsys['name']] = $tmp_column;

}

}

function add($column,$value) {

$this->columns[$column]->newval = "$value";

}

# this is the static comparing function
function cmp_obj($a, $b) {

$al = $a->colid;

$bl = $b->colid;

if ($al == $bl) {

return 0;

}

return ($al > $bl) ? +1 : -1;

}

# functie om te kijken of een bepaalde column een string-column of een int
column is
function is_stringval($val_to_check) {

/*
61 = datetime
167 = varchar
56 = int
175 = char
52 = smallint
106 = decimal
35 = text
*/

if($val_to_check == 61 || $val_to_check == 167 || $val_to_check == 175 ||
$val_to_check == 35) {
return true;
} else {
return false;
}

}

function mssql_escape($data) {

if( get_magic_quotes_gpc() ) {
$data = stripslashes($data);
}

return str_replace("'", "''", $data);

}
function insert() {

# op volgorde zetten van columns
uasort($this->columns,array("sql", "cmp_obj"));

# start sql-statement
$SQLins = "";

$SQLins .= "INSERT INTO ".$this->table." (";

foreach($this->columns as $value) {
if(isset($value->newval) && $value->newval != '') {
$SQLins .= $value->name.",";
}
}

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

$SQLins .= ") VALUES (";
foreach($this->columns as $value) {
if(isset($value->newval) && $value->newval != '') {
if($this->is_stringval($value->xtype)) {
$SQLins .= "'".$this->mssql_escape($value->newval)."',";
} else {
$SQLins .= $value->newval.",";
}

}
}

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

$SQLins .= ")";

#echo '<hr />'.$SQLins.'<hr />';

mssql_query($SQLins);

}

function exclude($column_name) {

array_push($this->excluded_columns,$column_name);

}

function
update($keycolumn1,$keyval1,$keycolumn2='',$keyval 2='',$keycolumn3='',$keyval3='')
{

# op volgorde zetten van columns
uasort($this->columns,array("sql", "cmp_obj"));

# start sql-statement
$SQLupd = "";

$SQLupd .= "UPDATE ".$this->table." SET ";

foreach($this->columns as $value) {
if(!in_array($value->name,$this->excluded_columns)) {
if(isset($value->newval) && trim($value->newval) != '') {
if($this->is_stringval($value->xtype)) {
$SQLupd .= $value->name." =
'".$this->mssql_escape($value->newval)."',";
} else {
$SQLupd .= $value->name."= ".$value->newval.",";
}

} else {
$SQLupd .= $value->name."= NULL,";
}
}
}

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

$SQLupd .= " WHERE ";

if($keycolumn1) {

if($this->is_stringval($this->columns[$keycolumn1]->xtype)) {
$SQLupd .= $keycolumn1." = '".$keyval1."'";
} else {
$SQLupd .= $keycolumn1." = ".$keyval1;
}

}
if($keycolumn2) {

if($this->is_stringval($this->columns[$keycolumn2]->xtype)) {
$SQLupd .= " AND ".$keycolumn2." = '".$keyval2."'";
} else {
$SQLupd .= " AND ".$keycolumn2." = ".$keyval2;
}

}
if($keycolumn3) {

if($this->is_stringval($this->columns[$keycolumn3]->xtype)) {
$SQLupd .= " AND ".$keycolumn3." = '".$keyval3."'";
} else {
$SQLupd .= " AND ".$keycolumn3." = ".$keyval3;
}

}

#echo $SQLupd;

mssql_query($SQLupd);

}
function
getSQLupdate($keycolumn1,$keyval1,$keycolumn2='',$ keyval2='',$keycolumn3='',$keyval3='')
{

# op volgorde zetten van columns
uasort($this->columns,array("sql", "cmp_obj"));

# start sql-statement
$SQLupd = "";

$SQLupd .= "UPDATE ".$this->table." SET ";

foreach($this->columns as $value) {
if(!in_array($value->name,$this->excluded_columns)) {
if(isset($value->newval) && trim($value->newval) != '') {
if($this->is_stringval($value->xtype)) {
$SQLupd .= $value->name." =
'".$this->mssql_escape($value->newval)."',";
} else {
$SQLupd .= $value->name."= ".$value->newval.",";
}

} else {
$SQLupd .= $value->name."= NULL,";
}
}
}

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

$SQLupd .= " WHERE ";

if($keycolumn1) {

if($this->is_stringval($this->columns[$keycolumn1]->xtype)) {
$SQLupd .= $keycolumn1." = '".$keyval1."'";
} else {
$SQLupd .= $keycolumn1." = ".$keyval1;
}

}
if($keycolumn2) {

if($this->is_stringval($this->columns[$keycolumn2]->xtype)) {
$SQLupd .= " AND ".$keycolumn2." = '".$keyval2."'";
} else {
$SQLupd .= " AND ".$keycolumn2." = ".$keyval2;
}

}
if($keycolumn3) {

if($this->is_stringval($this->columns[$keycolumn3]->xtype)) {
$SQLupd .= " AND ".$keycolumn3." = '".$keyval3."'";
} else {
$SQLupd .= " AND ".$keycolumn3." = ".$keyval3;
}

}

return $SQLupd;

}

function getLastID() {

$SQLlastid = "SELECT lastid = @@IDENTITY";

$RESULTlastid = mssql_query($SQLlastid);

$RECORDlastid = mssql_fetch_array($RESULTlastid);

return $RECORDlastid['lastid'];

}

}
Jun 1 '06 #5
El Thu, 1 Jun 2006 16:34:40 +0200
Marcel escribió:
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the
past header("Location:newsitems.php");


just a thing, try to always exit after sending a location header, keep
in mind that only sending it does NOT end the .php file.

also if for example you are redirecting someone because they're not
logged in, the rest of the page WILL be generated, and if you download
it with wget or curl you'll be able to see without validation.

header('Location: your-new-location');
exit;

don't know if it has any connection to your problem, but change it
anyway

--
Juan José Gutiérrez de Quevedo
Director Técnico (ju****@iteisa.com)
ITEISA (http://www.iteisa.com)
942544036 - 637447953
Jun 1 '06 #6
Marcel wrote:

"Erwin Moller"
<si******************************************@spam yourself.com> schreef in
bericht news:44***********************@news.xs4all.nl...
Marcel wrote:
I have a problem with a PHP page that seems to get executed twice.

I am running PHP5 ISAPI on 2003 server.

Hi Marcel,

Sorry to say, but this is most likely a problem in your code, not in the
server/webserver/PHP.


Yeah, maybe you are right but i am an experienced coder and i have been
searching for 2 days now where this is coming from.


I was willing to believe you up until I read the code you posted.

The first place you should have been looking to solve this was in your
server logs. That would answer the question once and for all as to how many
times the page was invoked and by whom. You should also get something which
lets you see the traffic out of your browser - since you seem to be using
Microsoft server-side, try iehttpheaders.

If, after the above you still think the code was getting executed twice then
you should start with 'hello world' and work upwards till you've reproduced
the problem - then i you still can't explain why, try posting here.

Some recommended reading:

http://www.dagbladet.no/development/phpcodingstandard/
http://www.amazon.com/gp/product/159...lance&n=283155
http://www.catb.org/~esr/faqs/smart-questions.html

Can this be a proxy-setting or an ISA`server related subject???


I don't think so, but then again, I don't know what an ISAserver is.


Ah ignorance is bliss. Unfortunately its exactly the kind of the thing to
expect from ISA^HD so why didn't you try bypassing it, or reading IT's
logs?

C.
Jun 1 '06 #7

"Colin McKinnon"
<co**********************@ntlworld.deletemeunlessU RaBot.com> schreef in
bericht news:sy*****************@newsfe4-gui.ntli.net...
Marcel wrote:

"Erwin Moller"
<si******************************************@spam yourself.com> schreef
in
bericht news:44***********************@news.xs4all.nl...
Marcel wrote:

I have a problem with a PHP page that seems to get executed twice.

I am running PHP5 ISAPI on 2003 server.
Hi Marcel,

Sorry to say, but this is most likely a problem in your code, not in the
server/webserver/PHP.


Yeah, maybe you are right but i am an experienced coder and i have been
searching for 2 days now where this is coming from.


I was willing to believe you up until I read the code you posted.

The first place you should have been looking to solve this was in your
server logs. That would answer the question once and for all as to how
many
times the page was invoked and by whom. You should also get something
which
lets you see the traffic out of your browser - since you seem to be using
Microsoft server-side, try iehttpheaders.

If, after the above you still think the code was getting executed twice
then
you should start with 'hello world' and work upwards till you've
reproduced
the problem - then i you still can't explain why, try posting here.

Some recommended reading:

http://www.dagbladet.no/development/phpcodingstandard/
http://www.amazon.com/gp/product/159...lance&n=283155
http://www.catb.org/~esr/faqs/smart-questions.html

Can this be a proxy-setting or an ISA`server related subject???

I don't think so, but then again, I don't know what an ISAserver is.


Ah ignorance is bliss. Unfortunately its exactly the kind of the thing to
expect from ISA^HD so why didn't you try bypassing it, or reading IT's
logs?

C.


I solved it by replacing

header("Location:newsitems.php");

with a javascript redirect

<script>
location='newsitems.php';
</script>

And that solved my problem so i think (i am not sure but....) there is a bug
in PHP5.1.2 location header function implementation.....

Marcel
Jun 2 '06 #8
Marcel wrote:

I solved it by replacing

header("Location:newsitems.php");

with a javascript redirect

<script>
location='newsitems.php';
</script>

And that solved my problem so i think (i am not sure but....) there is a
bug in PHP5.1.2 location header function implementation.....

No there isn't.
I bet you forgot to exit after the header. :P

header("Location:newsitems.php");
exit;
Regards,
Erwin Moller
Marcel


Jun 2 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Alberto | last post by:
I have a linkButton with a method associated to the click event. The problem is that the code is executed twice. The causes validation property is set to false. What's happening? Thank you.
0
by: Magesh | last post by:
Hi, I have a search screen with a textbox and a button (server controls). The page has to be submitted when the user hits the enter key in the textbox. The code i am using to do this is.. ...
5
by: jonhyland | last post by:
Hey all, I'm writing a .NET application where I want all HTTP errors such as 404 to redirect back to the home page. Since .NET only handles HTTP errors if the client is requesting a .NET...
0
by: Alfons Puig | last post by:
Hi, There is a page called GesDoc.aspx that is a container for two frames: Actions.aspx and Word.aspx. On some machines running IE, when loading the container, on some clients Word.aspx code...
1
by: Adam Knight | last post by:
Hi all, I have the following code in a User Control. For some reason it appears as if the page load function is executed twice as the 'UserLoggedIn' function results are being outputted twice....
1
by: Elie Grouchko | last post by:
Hi I have an ASP page which is randomly (?) executed twice. I noticed that the http header is different, as if there are two different requests sent to the server. Header 2 below is the one that...
2
by: Chris | last post by:
In SQL 2005 I have a stored procedure as below: @sub_no smallint OUTPUT BEGIN BEGIN TRANSACTION INSERT...INTO
3
by: Ed Sonneveld | last post by:
Hi, I have hosted my webservice at a hosting company and it has been working fine for 2 years now. The webservice is called by winforms clients over the internet, using the proxy class generated...
0
by: Ed Sonneveld | last post by:
Hi, I have hosted my webservice at a hosting company and it has been working fine for 2 years now. The webservice is called by winforms clients over the internet, using the proxy class generated...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.