Jump to content

how to do > once step 1 complete move to step 2


marksie1988

Recommended Posts

Hi,

 

i have a php script which will include other php files but this is causing some issues so i was wondering is there any way of changing this:

 

include('ingram.php');
include('etc.php');
include('c2000.php');

 

to something like

 

step 1 run ingram.php on success goto step2 on fail write to log then continue to step2

step2 run etc.php on success go to step3 on fail write to log then continue to step3

step3 run c2000.php on success finish on fail write to log then exit

 

 

is this possible if so how? ive never done this before so a point in the right direction or a snippet would be helpful :)

 

thanks

Steve

add the links and log your self straight froward....

 

 

this is a three page example where the user can only go from a.php,b.php,c.php

 

anywhere else get thrown back to the relevant page.

 

page name

a.php

<?php

if(!$_SERVER['PHP_SELF']=="a.php"){

header("location: b.php");
}
?>

page name

b.php

<?php

if(!$_SERVER['PHP_SELF']=="b.php"){

header("location: c.php");
}
?>

page name

c.php

<?php

if(!$_SERVER['PHP_SELF']=="c.php"){

header("location: b.php");
}
?>

what's your exact problem?

 

in each of the .php includes they import a csv file into mssql the issue with using include is that i get insert errors as if all of them are executing at once which is not good.

 

i need each of the .php includes to run one at a time and log any failures in a txt or log file and then move on to next step even if it fails.

 

 

add the links and log your self straight froward....

 

 

this is a three page example where the user can only go from a.php,b.php,c.php

 

anywhere else get thrown back to the relevant page.

 

page name

a.php

<?php

if(!$_SERVER['PHP_SELF']=="a.php"){

header("location: b.php");
}
?>

page name

b.php

<?php

if(!$_SERVER['PHP_SELF']=="b.php"){

header("location: c.php");
}
?>

page name

c.php

<?php

if(!$_SERVER['PHP_SELF']=="c.php"){

header("location: b.php");
}
?>

 

to do it this way would mean editing each individual .php file i dont want to do this as in the actual file i have about 50 of these included files. csvimport.php (the one with the include statements in) would need to run all of the scripts step by step i dont want to edit all of the other included files if there was no other way to do this than edit all of the files i guess i would need to just a pain in the butt.

any good?

 

They are examples, there only to be used or thort as a way to do something,  sorry if there no good but sometimes other programmers would say do it all a different way all again....

 

page name

a.php

<?php
echo"<a href='b.php?page=a></a>";

if(($_GET['page']=="b.php")||($_GET['page']=="c.php")){

	header("location: {$_GET['psgename']}");
}


$_SERVER['pagename']=$_SERVER['PHP_SELF'];

echo"<a href='b.php?page={$_SESSION['pagename']}></a>";
?>

 

page name

b.php

<?php session_start();

if($_GET['page']=="c.php"){

	header("location: {$_GET['page']}");
}

$_SERVER['pagename']=$_SERVER['PHP_SELF'];

echo"<a href='c.php?page={$_SESSION['pagename']}></a>";
?>

 

page name

c.php

<?php


if($_GET['page']=="c.php"){

	header("location: {$_GET['page']}");
}

$_SERVER['pagename']=$_SERVER['PHP_SELF'];

echo"<a href='b.php?page={$_SESSION['pagename']}></a>";
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.