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:
/*
*/
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
/*
* move the images to the website.
$destination = ‘c:a_test’.”_FILES[‘pix1’][‘name’];
$temp_file = $
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 ?