/    Sign up×
Community /Pin to ProfileBookmark

Help – Problem with include()

Hello,

Help – I am a bit stuck !

I have written a script that gets data from a form and then writes it to a db.
thats fine, but then according to the data enetred, they can add pictures.

After running the included script I want to update the db with the pix file names.

The problem is that after running the included script, the main script does not
continue – the script just stops.

I think that it is because I have called the included script a second time with the
form that it uses ?? but I am not sure ! ?

How can I get the main script to continue ?

Here is the relevent code:

I use a simple if statement to decide to get the pictures like this:
The script actually deals with 4 pictures but I just shown the coding for one.

PHP Code:
/*
*
Now we get the pictures.
*/
if( $pict == “y”){

include(“a_picts.php”);

} // endif
else{
$N_pix1=$N_pix2=$N_pix3=$N_pix4=$N_pix5=”n”;
} // end else

Now the a_picts.php script also uses a form to collect the picture data.

PHP Code:
if(isset($_POST[‘run’])){ // BIG IF

$A_ref = strip_tags(trim($_POST[“adref”]));
$N_pix1 = strip_tags(trim($_FILES[‘pix1’][name]));
// Checking image in pix files.

if($N_pix1 != “”){
if($_FILES[‘pix1’][‘tmp_name’] == “none”) {
$message1 = “Picture file did not successfully upload: Pix 1” ;
$message2 = “Check the file size. Must be less than 500K”;
require_once (“a_picts_fm.php”);
exit();
} // endif

if(!ereg(“image”,$_FILES[‘pix1’][‘type’])) {
$message1 = “The file you have selected for Picture 1 is not”;
$message2 = “a recognised picture file – Please try a different file”;
require_once (“a_picts_fm.php”);
exit();
} // endif
$ctr = 1;
} // endif

/*
*
Everything seems ok – so we connect to the database and
* move the images to the website.
*
/

$destination = ‘c:a_test’.”“.$_FILES[‘pix1’][‘name’];
$temp_file = $_
FILES[‘pix1’][‘tmp_name’];
move_uploaded_file($temp_file,$destination);

exit(); // NOT SURE IF THIS IS NEEDED (tried it without it but still didn’t work)

} // end BIG IF

else {
$message1 = “none”;
$message2 = “none”;
require_once (“a_picts_fm.php”);
exit();
} // end else
?>

The form that it uses is this:

PHP Code:
<form name=”main_fm” enctype =”multipart/form-data” action=”a_picts.php” method=”POST”>
<input type = ‘hidden’ name=’run’ value=”on”>
<input type=”hidden” name =”MAX FILE SIZE” value=”500000″>
<input type = ‘hidden’ name=’adref’ value=”<?php echo $A_ref ?>”>

<div id=’Props_add2a’ style=’position:absolute; left:30px; top:200px’ >
<table CELLPADDING=”1″ BORDER=”0″ >
<tr><td> <br></td></tr>

<tr>
<td>Picture 1: </td>
<td><input type=”file” size=”50″ name=”pix1″></td>
</tr>
<td><input type=”submit” name=”upload” value=”Upload Pictures”> </td>
</tr>
</table>
</div>
</form>

Any help would be much appreciated – thanks ?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@yabsoftAug 02.2005 — if(isset($_POST['run'])){ // BIG IF

$A_ref = strip_tags(trim($_POST["adref"]));

$N_pix1 = strip_tags(trim($_
FILES['pix1'][name]));

// Checking image in pix files.

if($N_pix1 != ""){

if($_FILES['pix1']['tmp_name'] == "none") {

$message1 = "Picture file did not successfully upload: Pix 1" ;

$message2 = "Check the file size. Must be less than 500K";

require_once ("a_picts_fm.php");

exit();

} // endif

if(!ereg("image",$_FILES['pix1']['type'])) {

$message1 = "The file you have selected for Picture 1 is not";

$message2 = "a recognised picture file - Please try a different file";

require_once ("a_picts_fm.php");

exit();

} // endif

$ctr = 1;

} // endif[/QUOTE]

Don't "exit" a script by function "exit(); ".It will stop all page excutation.

use "return",to return the called scripts!
×

Success!

Help @DaveinLondon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...