473,715 Members | 2,235 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4037
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************ *************** *************** @spamyourself.c om> 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_reportin g(E_ALL); // alle fouten weergeven
#error_reportin g(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_communi cation.php");

# mssql_escape function
require_once(". ./php_functions/mssql_escape.ph p");

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

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

$uploaddir = 'C:/Inetpub/domain.com/newsletters/uploaded_images/';
mail("in**@medi aquest.nl","Tes t Newsletters",$_ SERVER['HTTP_REFERER'].' -
'.$_SERVER['REMOTE_HOST'].' - '.$_SERVER['REQUEST_URI']);
function img_exists($fil ename_to_check) {

$SQLcheck = "SELECT id FROM com_images WHERE img_original_na me =
'".trim($filena me_to_check)."' ";

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

$RESULTcheck = mssql_query($SQ Lcheck);

if(mssql_num_ro ws($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($_FI LES['nwi_image1']['name']) &&
img_exists($_FI LES['nwi_image1']['name']),
"The filename of Image 1 that you are trying to upload allready exists");

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

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

rule(isset($_FI LES['nwi_image4']['name']) &&
img_exists($_FI LES['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
clearValidation s();

$tmp_nwi_name = $_POST['nwi_name'];
$tmp_nwi_descri ption = $_POST['nwi_descriptio n'];

$tmp_nwi_headin g = $_POST['nwi_heading'];

$tmp_nwi_subhea ding1 = $_POST['nwi_subheading 1'];
$tmp_nwi_image1 = $_POST['nwi_image1'];
$tmp_nwi_alignm ent1 = $_POST['nwi_alignment1 '];
$tmp_nwi_text1 = $_POST['nwi_text1'];

$tmp_nwi_subhea ding2 = $_POST['nwi_subheading 2'];
$tmp_nwi_image2 = $_POST['nwi_image2'];
$tmp_nwi_alignm ent2 = $_POST['nwi_alignment2 '];
$tmp_nwi_text2 = $_POST['nwi_text2'];

$tmp_nwi_subhea ding3 = $_POST['nwi_subheading 3'];
$tmp_nwi_image3 = $_POST['nwi_image3'];
$tmp_nwi_alignm ent3 = $_POST['nwi_alignment3 '];
$tmp_nwi_text3 = $_POST['nwi_text3'];

$tmp_nwi_subhea ding4 = $_POST['nwi_subheading 4'];
$tmp_nwi_image4 = $_POST['nwi_image4'];
$tmp_nwi_alignm ent4 = $_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 />';

clearValidation s();

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

$tsql_img1 = new sql('com_images ');

$tsql_img1->add("img_origi nal_name",$_FIL ES['nwi_image1']['name']);
$tsql_img1->add("img_tmp_n ame",$_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_dimensio ns[0]);
$tsql_img1->add("img_heigh t",$img_dimensi ons[1]);

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

# C:\Inetpub\doma in.com\newslett ers\uploaded_im ages

if(move_uploade d_file($_FILES['nwi_image1']['tmp_name'],
$uploaddir.$_FI LES["nwi_image1 "]["name"])) {

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

}

$tsql_img1->insert();

$nwi_image1_id = $tsql_img1->getLastID();

unset($tsql_img 1);

}

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

$tsql_img2 = new sql('com_images ');

$tsql_img2->add("img_origi nal_name",$_FIL ES['nwi_image2']['name']);
$tsql_img2->add("img_tmp_n ame",$_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_dimensio ns[0]);
$tsql_img2->add("img_heigh t",$img_dimensi ons[1]);

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

# C:\Inetpub\doma in.com\newslett ers\uploaded_im ages

if(move_uploade d_file($_FILES['nwi_image2']['tmp_name'],
$uploaddir.$_FI LES["nwi_image2 "]["name"])) {

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

}

$tsql_img2->insert();

$nwi_image2_id = $tsql_img2->getLastID();

unset($tsql_img 2);

}

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

$tsql_img3 = new sql('com_images ');

$tsql_img3->add("img_origi nal_name",$_FIL ES['nwi_image3']['name']);
$tsql_img3->add("img_tmp_n ame",$_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_dimensio ns[0]);
$tsql_img3->add("img_heigh t",$img_dimensi ons[1]);

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

# C:\Inetpub\doma in.com\newslett ers\uploaded_im ages

if(move_uploade d_file($_FILES['nwi_image3']['tmp_name'],
$uploaddir.$_FI LES["nwi_image3 "]["name"])) {

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

}

$tsql_img3->insert();

$nwi_image3_id = $tsql_img3->getLastID();

unset($tsql_img 3);

}

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

$tsql_img4 = new sql('com_images ');

$tsql_img4->add("img_origi nal_name",$_FIL ES['nwi_image4']['name']);
$tsql_img4->add("img_tmp_n ame",$_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_dimensio ns[0]);
$tsql_img4->add("img_heigh t",$img_dimensi ons[1]);

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

# C:\Inetpub\doma in.com\newslett ers\uploaded_im ages

if(move_uploade d_file($_FILES['nwi_image4']['tmp_name'],
$uploaddir.$_FI LES["nwi_image4 "]["name"])) {

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

}

$tsql_img4->insert();

$nwi_image4_id = $tsql_img4->getLastID();

unset($tsql_img 4);

}


$tsql = new sql('com_newsit ems');
$tsql->add("nwi_name" ,$_POST['nwi_name']);
$tsql->add("nwi_descr iption",$_POST['nwi_descriptio n']);

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

$tsql->add("nwi_subhe ading1",$_POST['nwi_subheading 1']);
if($_FILES['nwi_image1']['name']) {
$tsql->add("nwi_image 1",$nwi_image1_ id);
$tsql->add("nwi_align ment1",$_POST['nwi_alignment1 ']);
} else {

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

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

$tsql->add("nwi_subhe ading2",$_POST['nwi_subheading 2']);
if($_FILES['nwi_image2']['name']) {
$tsql->add("nwi_image 2",$nwi_image2_ id);
$tsql->add("nwi_align ment2",$_POST['nwi_alignment2 ']);
} else {

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

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

$tsql->add("nwi_subhe ading3",$_POST['nwi_subheading 3']);
if($_FILES['nwi_image3']['name']) {
$tsql->add("nwi_image 3",$nwi_image3_ id);
$tsql->add("nwi_align ment3",$_POST['nwi_alignment3 ']);
} else {

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

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

$tsql->add("nwi_subhe ading4",$_POST['nwi_subheading 4']);
if($_FILES['nwi_image4']['name']) {
$tsql->add("nwi_image 4",$nwi_image4_ id);
$tsql->add("nwi_align ment4",$_POST['nwi_alignment4 ']);
} else {

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

}
$tsql->add("nwi_text4 ",$_POST['nwi_text4']);
$tsql->exclude("id" );
$tsql->exclude("nwi_d ate_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("Locatio n:newsitems.php ");
#echo $tsql->getSQLupdate() ;

}

} else {

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

$RESULT = mssql_query($SQ L);

$RECORD = mssql_fetch_arr ay($RESULT);

$tmp_nwi_name = $RECORD['nwi_name'];
$tmp_nwi_descri ption = $RECORD['nwi_descriptio n'];

$tmp_nwi_headin g = $RECORD['nwi_heading'];

$tmp_nwi_subhea ding1 = $RECORD['nwi_subheading 1'];
$tmp_nwi_image1 = $RECORD['nwi_image1'];
if($RECORD['nwi_image1']) {

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

$RESULTimg1 = mssql_query($SQ Limg1);

if(mssql_num_ro ws($RESULTimg1) > 0) {

$RECORDimg1 = mssql_fetch_arr ay($RESULTimg1) ;

$nwi_image1_nam e = $RECORDimg1['img_original_n ame'];

}

}

$tmp_nwi_alignm ent1 = $RECORD['nwi_alignment1 '];
$tmp_nwi_text1 = $RECORD['nwi_text1'];

$tmp_nwi_subhea ding2 = $RECORD['nwi_subheading 2'];
$tmp_nwi_image2 = $RECORD['nwi_image2'];

if($RECORD['nwi_image2']) {

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

$RESULTimg2 = mssql_query($SQ Limg2);

if(mssql_num_ro ws($RESULTimg2) > 0) {

$RECORDimg2 = mssql_fetch_arr ay($RESULTimg2) ;

$nwi_image2_nam e = $RECORDimg2['img_original_n ame'];

}

}

$tmp_nwi_alignm ent2 = $RECORD['nwi_alignment2 '];
$tmp_nwi_text2 = $RECORD['nwi_text2'];

$tmp_nwi_subhea ding3 = $RECORD['nwi_subheading 3'];
$tmp_nwi_image3 = $RECORD['nwi_image3'];

if($RECORD['nwi_image3']) {

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

$RESULTimg3 = mssql_query($SQ Limg3);

if(mssql_num_ro ws($RESULTimg3) > 0) {

$RECORDimg3 = mssql_fetch_arr ay($RESULTimg3) ;

$nwi_image3_nam e = $RECORDimg3['img_original_n ame'];

}

}

$tmp_nwi_alignm ent3 = $RECORD['nwi_alignment3 '];
$tmp_nwi_text3 = $RECORD['nwi_text3'];

$tmp_nwi_subhea ding4 = $RECORD['nwi_subheading 4'];
$tmp_nwi_image4 = $RECORD['nwi_image4'];

if($RECORD['nwi_image4']) {

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

$RESULTimg4 = mssql_query($SQ Limg4);

if(mssql_num_ro ws($RESULTimg4) > 0) {

$RECORDimg4 = mssql_fetch_arr ay($RESULTimg4) ;

$nwi_image4_nam e = $RECORDimg4['img_original_n ame'];

}

}

$tmp_nwi_alignm ent4 = $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.c om CMS Newsletters</title>
<link href="styles/newslettercms.c ss" rel="stylesheet " type="text/css">
</head>
<body vlink="#000066" alink="#FF3300" >
<a name="Top"></a>
<form action="test2.p hp" method="post" enctype="multip art/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="#00387 5">
<tr>
<td width="744" bgcolor="#fffff f">
<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="#00387 5">
<table width="744" border="0" cellspacing="0" cellpadding="4" >
<tr>
<td width="468"><fo nt color="#ffffff" face="Verdana, Arial, Helvetica,
sans-serif" size="2"><stron g>domain.com
CMS Newsletters</strong></font></td>
<td width="260" align="right">< font color="#ffffff" face="Verdana, Arial,
Helvetica, sans-serif" size="2">Welcom e
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="#f1f1f 1"><font color="#003875"
face="Arial, Helvetica, sans-serif" size="2"> <strong>|</strong> <a
href="emailaddr esses.php">View/manage
e-mail adressess</a> <strong>|</strong> <a
href="newslette rs.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"><fo nt color="#003875" face="Arial, Helvetica, sans-serif"
size="3"><stron g>Edit newsitem </strong></font></td>
</tr>
<tr>
<td align="right">< font color="#000000" face="Arial, Helvetica, sans-serif"
size="2"><a href="addnewsit em.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"><stron g><?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_titl e" id="nwi_name"
value="<?php echo $tmp_nwi_name; ?>">
</td>
</tr>
<tr>
<td>Newsitem description</td>
<td>
<textarea name="nwi_descr iption" id="nwi_descrip tion" cols="35"
rows="6"><?php echo $tmp_nwi_descri ption; ?></textarea>
</td>
</tr>

<tr>
<td colspan="2"><hr /></td>
</tr>
<tr>
<td>Heading</td>
<td>
<input name="nwi_headi ng" type="text" class="nwl_nwi_ name" id="nwi_heading "
value="<?php echo $tmp_nwi_headin g; ?>">
</td>
</tr>
<tr>
<td colspan="2"><hr /></td>
</tr>

<!-- 1 -->
<tr>
<td>Subheadin g 1</td>
<td>
<input name="nwi_subhe ading1" type="text" class="nwl_nwi_ name"
id="nwi_subhead ing1" value="<?php echo $tmp_nwi_subhea ding1; ?>">
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<?php echo $nwi_image1_nam e; ?><input name="nwi_image 1_del" type="checkbox"
id="nwi_image1_ del" value="<?php echo $nwi_image1_nam e; ?>">
</td>
</tr>
<tr>
<td>Image 1</td>
<td>
<input name="nwi_image 1" 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_align ment1" type="radio" value="L" <?php
if($tmp_nwi_ali gnment1 == 'L') {echo 'checked';} ?>> Left
<input name="nwi_align ment1" type="radio" value="C" <?php
if($tmp_nwi_ali gnment1 == 'C') {echo 'checked';} ?>> Center
<input name="nwi_align ment1" type="radio" value="R" <?php
if($tmp_nwi_ali gnment1 == '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>Subheadin g 2</td>
<td>
<input name="nwi_subhe ading2" type="text" class="nwl_nwi_ name"
id="nwi_subhead ing2" value="<?php echo $tmp_nwi_subhea ding2; ?>">
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<?php echo $nwi_image2_nam e; ?><input name="nwi_image 2_del" type="checkbox"
id="nwi_image2_ del" value="<?php echo $nwi_image2_nam e; ?>">
</td>
</tr>
<tr>
<td>Image 2</td>
<td>
<input name="nwi_image 2" 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_align ment2" type="radio" value="L" <?php
if($tmp_nwi_ali gnment2 == 'L') {echo 'checked';} ?>> Left
<input name="nwi_align ment2" type="radio" value="C" <?php
if($tmp_nwi_ali gnment2 == 'C') {echo 'checked';} ?>> Center
<input name="nwi_align ment2" type="radio" value="R" <?php
if($tmp_nwi_ali gnment2 == '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>Subheadin g 3</td>
<td>
<input name="nwi_subhe ading3" type="text" class="nwl_nwi_ name"
id="nwi_subhead ing3" value="<?php echo $tmp_nwi_subhea ding3; ?>">
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<?php echo $nwi_image3_nam e; ?><input name="nwi_image 3_del" type="checkbox"
id="nwi_image3_ del" value="<?php echo $nwi_image3_nam e; ?>">
</td>
</tr>
<tr>
<td>Image 3</td>
<td>
<input name="nwi_image 3" 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_align ment3" type="radio" value="L" <?php
if($tmp_nwi_ali gnment3 == 'L') {echo 'checked';} ?>> Left
<input name="nwi_align ment3" type="radio" value="C" <?php
if($tmp_nwi_ali gnment3 == 'C') {echo 'checked';} ?>> Center
<input name="nwi_align ment3" type="radio" value="R" <?php
if($tmp_nwi_ali gnment3 == '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>Subheadin g 4</td>
<td>
<input name="nwi_subhe ading4" type="text" class="nwl_nwi_ name"
id="nwi_subhead ing4" value="<?php echo $tmp_nwi_subhea ding4; ?>">
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<?php echo $nwi_image4_nam e; ?><input name="nwi_image 4_del" type="checkbox"
id="nwi_image4_ del" value="<?php echo $nwi_image4_nam e; ?>">
</td>
</tr>
<tr>
<td>Image 4</td>
<td>
<input name="nwi_image 4" 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_align ment4" type="radio" value="L" <?php
if($tmp_nwi_ali gnment4 == 'L') {echo 'checked';} ?>> Left
<input name="nwi_align ment4" type="radio" value="C" <?php
if($tmp_nwi_ali gnment4 == 'C') {echo 'checked';} ?>> Center
<input name="nwi_align ment4" type="radio" value="R" <?php
if($tmp_nwi_ali gnment4 == '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="#008C9 A">&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_colum ns = array();
# default constructor, neemt als argument de tabel waarop dit sql object
betrekking heeft
public function __construct($ta ble) {

$this->table = $table;

# sql statement om info over columns in deze tabel te verkrijgen
$SQLsys = "SELECT syscolumns.name , syscolumns.xtyp e, syscolumns.coli d,
syscolumns.isnu llable FROM sysobjects INNER JOIN syscolumns ON sysobjects.id
= syscolumns.id WHERE (sysobjects.nam e = N'".$this->table."')";

$RESULTsys = mssql_query($SQ Lsys);

# while-loop om alle info van de diverse columns uit te lezen en toe te
kennen aan column-objecten
while($RECORDsy s = mssql_fetch_arr ay($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,$va lue) {

$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($v al_to_check) {

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

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

}

function mssql_escape($d ata) {

if( get_magic_quote s_gpc() ) {
$data = stripslashes($d ata);
}

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($SQ Lins);

}

function exclude($column _name) {

array_push($thi s->excluded_colum ns,$column_name );

}

function
update($keycolu mn1,$keyval1,$k eycolumn2='',$k eyval2='',$keyc olumn3='',$keyv al3='')
{

# 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($v alue->name,$this->excluded_colum ns)) {
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 ".$keycolum n2." = '".$keyval2."'" ;
} else {
$SQLupd .= " AND ".$keycolum n2." = ".$keyval2;
}

}
if($keycolumn3) {

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

}

#echo $SQLupd;

mssql_query($SQ Lupd);

}
function
getSQLupdate($k eycolumn1,$keyv al1,$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($v alue->name,$this->excluded_colum ns)) {
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 ".$keycolum n2." = '".$keyval2."'" ;
} else {
$SQLupd .= " AND ".$keycolum n2." = ".$keyval2;
}

}
if($keycolumn3) {

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

}

return $SQLupd;

}

function getLastID() {

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

$RESULTlastid = mssql_query($SQ Llastid);

$RECORDlastid = mssql_fetch_arr ay($RESULTlasti d);

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("Locatio n: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('Locatio n: 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************ *************** *************** @spamyourself.c om> 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************ **********@ntlw orld.deletemeun lessURaBot.com> schreef in
bericht news:sy******** *********@newsf e4-gui.ntli.net...
Marcel wrote:

"Erwin Moller"
<si************ *************** *************** @spamyourself.c om> 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("Locatio n:newsitems.php ");

with a javascript redirect

<script>
location='newsi tems.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("Locatio n:newsitems.php ");

with a javascript redirect

<script>
location='newsi tems.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("Locatio n: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
1244
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
1127
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.. this.txtCorpId.Attributes = "if(event.keyCode == 13){ if (Page_ClientValidate()) document.getElementById('btnSearch').click();}"; But i find that the page_load event is executed twice when the enter key is
5
3447
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 resource (.ASPX, whatever), I need to go into IIS -> Custom Errors tab and set my homepage under each HTTP error I want to handle. This allows my page to be shown if someone requests an .ASP or .HTM page that doesn't exist.
0
1015
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 behind is executed twice, producing a bad result. On the requests from clients that fail, I noticed: * Enabling trace on web.config file and looking at the trace.axd, on the second call the ASP.NET_SessionID is different. * Looking at the IIS logs...
1
1036
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. If this is the case, i suspect it is something i have missed about a pages life cycle. Can anyone point in the right direction???
1
1948
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 randomly occur. Although the 2 headers are different I don't understand why Help will be greatly appreciated
2
6686
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
5712
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 by visual studio. What I do not understand, however, is that sometimes (say 1% of all calls) are being executed twice on the server side. I notice that because each call makes an entry in the database. This problem has been around as long as...
0
1085
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 by visual studio. What I do not understand, however, is that sometimes (say 1% of all calls) are being executed twice on the server side. I notice that because each call makes an entry in the database. This problem has been around as long as...
0
8820
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8718
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9332
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9100
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9044
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6645
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5966
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4476
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4738
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.