Jump to content

variables


anf.etienne

Recommended Posts

is it possible to transfer variables from 1 file to another?

 

for example is you go to http://www.ve-creative.com/test/8/templateEdit.php

 

at the bottom where it says upload new image and click the form will appear and you can upload....from then it will submit to a php file, i have set it so that it prints the location of the uploaded files so i know its working. After uploading the images i want to redirect it back to the original page. In the original page.

 

I have created a variable with the full location of where the images are uploaded to but need to know how i can get that variable from 1 file to the other without the use of mysql....is this possible?

 

thank you in advance

Link to comment
https://forums.phpfreaks.com/topic/145563-variables/
Share on other sites

i have just got the following message

 

Warning: Cannot modify header information - headers already sent by (output started at /home/vecre0/public_html/test/8/addimgck.php:10) in /home/vecre0/public_html/test/8/addimgck.php on line 67

 

 

here is my coding....what have i done wrong?

 


<!doctype html public "-//w3c//dtd html 3.2//en">

<html>

<head>
<title>Multiple image upload script from plus2net.com</title>
</head>

<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<?
$random_digit=rand(0000000000,9999999999);

$folderIn=mkdir("upload/$random_digit", 0777); 
?>
<?
while(list($key,$value) = each($_FILES['images']['name']))
	{
		if(!empty($value))
		{
			$filename = $value;
				$filename=str_replace(" ","_",$filename);// Add _ inplace of blank space in file name, you can remove this line

				$add = "upload/$random_digit/$filename";
                       //echo $_FILES['images']['type'][$key];
		     // echo "<br>";
				copy($_FILES['images']['tmp_name'][$key], $add);
				chmod("$add",0777);

$full_path="http://ve-creative.com/test/4/$random_digit/$filename<br />";

$folderPath="http://ve-creative.com/test/4/$random_digit";
		}
	}

$id= "$random_digit";
header ("Location templateEdit.php?id=$id");
?>
<?
$username="vecre0_tempU";
$password="auction";
$database="vecre0_templates";


// OPEN CONNECTION ---> 
$connection=mysql_connect("localhost","$username", "$password") or die("Unable to connect!");

mysql_select_db("$database") or die("Unable to select database!");


//  EXECUTE QUERY ---> 
$query="INSERT INTO paths (

		folderPath)

        VALUES(		
            '".$folderPath."')";
//////-----> 
$result=mysql_query($query) or die("Error in query:".mysql_error()); 
//if ($result) 
    //echo mysql_affected_rows()." row inserted into the database effectively."; 

//  CLOSE CONNECTION ---> 
mysql_close($connection); 
?>

<?php

?>



</body>

</html>


Link to comment
https://forums.phpfreaks.com/topic/145563-variables/#findComment-764212
Share on other sites

To address you main issue:

header ("Location templateEdit.php?id=$id");

 

Is after data was outputted to the screen. Read header for more information. To fix it, you should have your output as the last item (or at least after header calls)  in your script, not inter-mixed because of this very issue. Your code needs to be re-thought and corrected.

 

The other option is ob_start which is a bandaid for the real issue.

Link to comment
https://forums.phpfreaks.com/topic/145563-variables/#findComment-764350
Share on other sites

hi im a newbie at all this, i just needed a simple way to pass a random generated number from 1 page to the next and once it submitted for that number to go back to the 1st page so i can continue to use it.

 

i have been reading different sites and forums and so far i think session, get or post might be the best solution....i have no data that i want to protect. I am just wary of how to actually get them to pass the variable to the submit page and back to the 1st page once it redirects back

Link to comment
https://forums.phpfreaks.com/topic/145563-variables/#findComment-764371
Share on other sites

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.