woodsonoversoul Posted December 17, 2008 Share Posted December 17, 2008 Hi all, I've got a multi-file, mp3 upload system that works (kinda) like this - there are two pages, one takes in information about the group of files ( band, date, etc.) and also the song names, separated by a comma. This page then passes this information to the actual uploading page which displays the file group information and also creates an upload box for each one of the songs listed on the previous page. There is one submit button, which, when pressed causes the page to call itself and upload the files. Most of this works all well and good, that is, until the page calls itself. When the page calls itself, it uploads the files fine, but doesn't pass any other variables (band, date, etc.) I've tried to solve this by echoing out hidden inputs in the html section, but no luck. Here's the code from the page that calls itself (the upload page). Anyone else see anything? <?php #File uploading script ////////////////////////////////////////////////////////////////// //File: upload_script.php //Author: Daniel Woodson (w/ help from gevans from phpfreaks.org //Purpose: Upload multiple files //Last update: 12-10-08 //Comment: Working on renaming uploaded files ////////////////////////////////////////////////////////////////// ////////////////functions//////////////////// function create_song_array($set, $unique_show_id, $set_num) { /*function takes in show.set object, splits that object into an array, and then makes it multidiminsional. It then creates and assigns song ids to the first row of the array and song titles to the third row */ //split the object($set) into a dummy array based on ',' and '>', using perl-type regex $dummy_array = preg_split("/(,|>)/", $set); //use the trim() function to remove leading/trailing white spaces for($i=0;$i<count($dummy_array);$i++){ $dummy_array[$i] = trim($dummy_array[$i]); } //then create the real array as a copy of dummy array $song_array = array(count($dummy_array)); //make the real array multidiminsional and create eight //rows to hold the song's various properties for($i = 0; $i < count($dummy_array); $i++){ $song_array[$i] = array(; } //assign song title, set_one_songs[2] = dummy_array[1] for($m = 0; $m < count($dummy_array); $m++){ $song_array[$m][2] = $dummy_array[$m]; } //assign unique song ids (###NOTE: $n+1 should return a value which is in a 2 digit form###) for($n = 0; $n < count($dummy_array); $n++) { $song_array[$n][0] = $unique_show_id . "s" . $set_num . "s" . ($n+1); } //return newly created array return $song_array; }//create_song_array function showIdCreator($band, $date) { /*this function takes in the user inputed band name and show date. It then produces an abbreviation from the band name. It then returns this abbreviation combined with the show date to create the show id*/ //variable declarations $abb;//store the abbreviated band name //convert the band name to lower case for easier comparison $band = strtolower($band); //set abbreviation based on band name switch($band) { case "widespread panic" : $abb = "wsp"; break; case "grateful dead" : $abb = "gd"; break; case "phish" : $abb = "ph"; break; case "ryan adams" : $abb = "ra"; break; default: $abb = "unknown"; break; } //return a combination of the band name abbreviation and the show date return $abb . $date; }//end showIdCreator() function printHead(){ echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>File Uploader</title> <style type="text/css" title ="text/css" media="all"> .error { font-weight: bold; color: #C00 } </style> </head> <body>'; }//end printHead() ////////////////end of functions//////////////////// ////////////////begin lead-in php/////////////////// //turn on error reporting ini_set('display_errors', 'On'); error_reporting(E_ALL | E_STRICT); //print html header printHead(); #print html head //Initailize and assign values to starter variables. $show_id = ""; $band = $_POST['band']; $date = $_POST['date']; $setOne = $_POST['setOne']; //create a unique show id $unique_show_id = showIdCreator($band, $date); //create an array of songs based on set on and save it to an array of the same name $set_one = create_song_array($setOne, $unique_show_id, "1"); //check to see if file has been submitted if(isset($_POST['submitted'])){ //start a loop to move through all the files for($i = 0; $i < count($_FILES['upload']['name']); $i++){ //debug - show all pertinate file info /*echo "<pre>"; print_r($_FILES); echo "</pre>";*/ //create an array of allowed types (###NOTE: need MIME type for Flac###) $allowed = array('audio/mpeg'); //now evaluate current file //check to see if current file's type is in the array of allowed types if(in_array($_FILES['upload']['type'][$i], $allowed)){ //If True, move the file to new location if(move_uploaded_file($_FILES['upload']['tmp_name'][$i], "/home/dan/MusicDataBase/" . $set_one[$i][0] . ".mp3")){ echo '<p><em>The file has been uploaded!</em></p>'; //Delete file if if still exist if(file_exists($_FILES['upload']['tmp_name'][$i]) && is_files($_FILES['upload']['tmp_name'][$i])){ unlink($_FILES['upload']['tmp_name'][$i]); } } else { if($_FILES['upload']['error'][$i] > 0){ echo '<p class="error">The file could not be uploaded because: <strong>'; //print message based on error switch($_FILES['upload']['error'][$i]){ case 1: print 'The file exceeds the upload_max_filesize settiing in php.ini'; break; case 2: print 'The file exceeds the MAX_FILE_SIZE setting in the html form'; break; case 3: print 'The file was only partially uploaded'; break; case 4: print 'No file was uploaded'; break; case 6: print 'No temporary folder was available'; break; case 7: print 'Unable to write to the disk'; break; case 8: print 'File upload was stopped'; break; default: print 'A system error occured'; break; }//end of switch print '</strong></p>'; }//end of error if } } else {//invaild type echo '<p class="error">Error: Wrong filetype. Must be mp3</p>'; }//end else }//end for loop }//end isset ////////////////begin actual page/////////////////// //display show information echo "The band is: " . $band . "<br>"; echo "The show date is: " . $date . "<br>"; echo "Unique show id: " . $unique_show_id . "<br><br>"; //###This was my solution - FAIL!### //create hidden values to be passed to the next page //echo "<input type =\"hidden\" name =\"band\" value =\"" . $band . "\" />"; //end original php section ?> <form enctype="multipart/form-data" action="upload_script_ver2.php" method="post"> <?php //use a for loop to produce multiple upload boxes for($i = 0; $i < count($set_one); $i++){ ?> <input type ="hidden" name = "MAX_FILE_SIZE" value = "209715200" /> <fieldset><legend>Select a mp3 to upload:</legend> <p><b>file:</b><input type="file" name ="upload[]" /></p> </fieldset> <?php //end for loop } ?> <div align="center"><input type="submit" name="submit" value="Submit" /></div> <input type="hidden" name="submitted" value="TRUE" /> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/137460-variables-not-passing-from-page-to-page/ Share on other sites More sharing options...
flyhoney Posted December 17, 2008 Share Posted December 17, 2008 Your solution would work but you placed the hidden form element outside of the form tags. Quote Link to comment https://forums.phpfreaks.com/topic/137460-variables-not-passing-from-page-to-page/#findComment-718335 Share on other sites More sharing options...
woodsonoversoul Posted December 18, 2008 Author Share Posted December 18, 2008 Thanks flyhoney! works great now Quote Link to comment https://forums.phpfreaks.com/topic/137460-variables-not-passing-from-page-to-page/#findComment-718348 Share on other sites More sharing options...
woodsonoversoul Posted December 18, 2008 Author Share Posted December 18, 2008 Well actually it was working great until I added variables for year, month, and day. I was trying to avoid errors so I changed a text input named "date" into 3 select boxes named "year", "month", and "day" (on the first page) and added a function to piece them all together (on the second page). I did all tis the same way I changed my code to make it receive the variables of "band" and "date" but this time I get a bunch of undefined index notices. Any more ideas? Code from the second page: <?php #File uploading script ////////////////////////////////////////////////////////////////// //File: upload_script.php //Author: Daniel Woodson (w/ help from gevans from phpfreaks.org) //Purpose: Upload multiple files //Last update: 12-10-08 //Comment: Working on renaming uploaded files ////////////////////////////////////////////////////////////////// ////////////////functions//////////////////// function create_date($year, $month, $day){ //function combines year, month, and day into an acceptable format if($month < 10){ $month = '0' . $month; } if($day < 10){ $day = '0' . $day; } return $year . "-" . $month . "-" . $day; } function create_song_array($set, $unique_show_id, $set_num) { /*function takes in show.set object, splits that object into an array, and then makes it multidiminsional. It then creates and assigns song ids to the first row of the array and song titles to the third row */ //split the object($set) into a dummy array based on ',' and '>', using perl-type regex $dummy_array = preg_split("/(,|>)/", $set); //use the trim() function to remove leading/trailing white spaces for($i=0;$i<count($dummy_array);$i++){ $dummy_array[$i] = trim($dummy_array[$i]); } //then create the real array as a copy of dummy array $song_array = array(count($dummy_array)); //make the real array multidiminsional and create eight //rows to hold the song's various properties for($i = 0; $i < count($dummy_array); $i++){ $song_array[$i] = array(; } //assign song title, set_one_songs[2] = dummy_array[1] for($m = 0; $m < count($dummy_array); $m++){ $song_array[$m][2] = $dummy_array[$m]; } //assign unique song ids (###NOTE: $n+1 should return a value which is in a 2 digit form###) for($n = 0; $n < count($dummy_array); $n++) { $song_array[$n][0] = $unique_show_id . "s" . $set_num . "s" . ($n+1); } //return newly created array return $song_array; }//create_song_array function showIdCreator($band, $date) { /*this function takes in the user inputed band name and show date. It then produces an abbreviation from the band name. It then returns this abbreviation combined with the show date to create the show id*/ //variable declarations $abb;//store the abbreviated band name //convert the band name to lower case for easier comparison $band = strtolower($band); //set abbreviation based on band name switch($band) { case "widespread panic" : $abb = "wsp"; break; case "grateful dead" : $abb = "gd"; break; case "phish" : $abb = "ph"; break; case "ryan adams" : $abb = "ra"; break; default: $abb = "unknown"; break; } //return a combination of the band name abbreviation and the show date return $abb . $date; }//end showIdCreator() function printHead(){ echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>File Uploader</title> <style type="text/css" title ="text/css" media="all"> .error { font-weight: bold; color: #C00 } </style> </head> <body>'; }//end printHead() ////////////////end of functions//////////////////// ////////////////begin lead-in php/////////////////// //turn on error reporting ini_set('display_errors', 'On'); error_reporting(E_ALL | E_STRICT); //print html header printHead(); #print html head //Initailize and assign values to starter variables. $show_id = ""; $band = $_POST['band']; $year = $_POST['year']; $month = $_POST['month']; $day = $_POST['day']; $date = create_date($year, $month, $day); $setOne = $_POST['setOne']; //create a unique show id $unique_show_id = showIdCreator($band, $date); //create an array of songs based on set on and save it to an array of the same name $set_one = create_song_array($setOne, $unique_show_id, "1"); //check to see if file has been submitted if(isset($_POST['submitted'])){ //start a loop to move through all the files for($i = 0; $i < count($_FILES['upload']['name']); $i++){ //debug - show all pertinate file info /*echo "<pre>"; print_r($_FILES); echo "</pre>";*/ //create an array of allowed types (###NOTE: need MIME type for Flac###) $allowed = array('audio/mpeg'); //now evaluate current file //check to see if current file's type is in the array of allowed types if(in_array($_FILES['upload']['type'][$i], $allowed)){ //If True, move the file to new location if(move_uploaded_file($_FILES['upload']['tmp_name'][$i], "/home/dan/MusicDataBase/" . $set_one[$i][0] . ".mp3")){ echo '<p><em>The file has been uploaded!</em></p>'; //Delete file if if still exist if(file_exists($_FILES['upload']['tmp_name'][$i]) && is_files($_FILES['upload']['tmp_name'][$i])){ unlink($_FILES['upload']['tmp_name'][$i]); } } else { if($_FILES['upload']['error'][$i] > 0){ echo '<p class="error">The file could not be uploaded because: <strong>'; //print message based on error switch($_FILES['upload']['error'][$i]){ case 1: print 'The file exceeds the upload_max_filesize settiing in php.ini'; break; case 2: print 'The file exceeds the MAX_FILE_SIZE setting in the html form'; break; case 3: print 'The file was only partially uploaded'; break; case 4: print 'No file was uploaded'; break; case 6: print 'No temporary folder was available'; break; case 7: print 'Unable to write to the disk'; break; case 8: print 'File upload was stopped'; break; default: print 'A system error occured'; break; }//end of switch print '</strong></p>'; }//end of error if } } else {//invaild type echo '<p class="error">Error: Wrong filetype. Must be mp3</p>'; }//end else }//end for loop }//end isset ////////////////begin actual page/////////////////// //display show information echo "The band is: " . $band . "<br>"; echo "The show date is: " . $date . "<br>"; echo "Unique show id: " . $unique_show_id . "<br><br>"; //end original php section ?> <form enctype="multipart/form-data" action="upload_script_ver2.php" method="post"> <?php //create hidden values to be passed to the next page echo "<input type =\"hidden\" name =\"band\" value =\"" . $band . "\" />"; echo "<input type =\"hidden\" name =\"year\" value =\"" . $year . "\" />"; echo "<input type =\"hidden\" name =\"month\" value =\"" . $month . "\" />"; echo "<input type =\"hidden\" name =\"day\" value =\"" . $day . "\" />"; echo "<input type =\"hidden\" name =\"setOne\" value =\"" . $setOne . "\" />"; //use a for loop to produce multiple upload boxes for($i = 0; $i < count($set_one); $i++){ ?> <input type ="hidden" name = "MAX_FILE_SIZE" value = "209715200" /> <fieldset><legend>Select a mp3 to upload:</legend> <p><b>file:</b><input type="file" name ="upload[]" /></p> </fieldset> <?php //end for loop } ?> <div align="center"><input type="submit" name="submit" value="Submit" /></div> <input type="hidden" name="submitted" value="TRUE" /> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/137460-variables-not-passing-from-page-to-page/#findComment-718373 Share on other sites More sharing options...
woodsonoversoul Posted December 18, 2008 Author Share Posted December 18, 2008 Actually, some times it works perfectly and sometimes it doesn't work at all. I have no idea what I could be doing differently... Quote Link to comment https://forums.phpfreaks.com/topic/137460-variables-not-passing-from-page-to-page/#findComment-718417 Share on other sites More sharing options...
woodsonoversoul Posted December 18, 2008 Author Share Posted December 18, 2008 I hate to bump myself, but I guess I'll do it anyway... bump Quote Link to comment https://forums.phpfreaks.com/topic/137460-variables-not-passing-from-page-to-page/#findComment-718506 Share on other sites More sharing options...
woodsonoversoul Posted December 18, 2008 Author Share Posted December 18, 2008 I'm getting errors on these lines: $band = $_POST['band']; $year = $_POST['year']; $month = $_POST['month']; $day = $_POST['day']; and $setOne = $_POST['setOne']; I think the error(s) lies somewhere in here: <form enctype="multipart/form-data" action="upload_script_ver2.php" method="post"> <?php //create hidden values to be passed to the next page echo "<input type =\"hidden\" name =\"band\" value =\"" . $band . "\" />"; echo "<input type =\"hidden\" name =\"year\" value =\"" . $year . "\" />"; echo "<input type =\"hidden\" name =\"month\" value =\"" . $month . "\" />"; echo "<input type =\"hidden\" name =\"day\" value =\"" . $day . "\" />"; echo "<input type =\"hidden\" name =\"setOne\" value =\"" . $setOne . "\" />"; //use a for loop to produce multiple upload boxes for($i = 0; $i < count($set_one); $i++){ ?> <input type ="hidden" name = "MAX_FILE_SIZE" value = "209715200" /> <fieldset><legend>Select a mp3 to upload:</legend> <p><b>file:</b><input type="file" name ="upload[]" /></p> </fieldset> <?php //end for loop } ?> <div align="center"><input type="submit" name="submit" value="Submit" /></div> <input type="hidden" name="submitted" value="TRUE" /> </form> </body> </html> Anyone see any errors? Maybe even somewhere deeper (in php.ini)? Quote Link to comment https://forums.phpfreaks.com/topic/137460-variables-not-passing-from-page-to-page/#findComment-718533 Share on other sites More sharing options...
flyhoney Posted December 18, 2008 Share Posted December 18, 2008 You are getting errors because you are checking for $_POST data when no form has been posted, or you are checking for $_POST data that does not exist. It is often a good idea to make sure a form has been submitted before accessing $_POST data. Something like this: if ($_POST && $_POST['submit'] == 'Submit') { $band = $_POST['band']; $year = $_POST['year']; $month = $_POST['month']; $day = $_POST['day']; } Quote Link to comment https://forums.phpfreaks.com/topic/137460-variables-not-passing-from-page-to-page/#findComment-718666 Share on other sites More sharing options...
woodsonoversoul Posted December 18, 2008 Author Share Posted December 18, 2008 Alright well now I'm kinda of lost. Anyone want to take a once over look at my code? The setup of two pages, one calling itself, for a total of three page calls is still the same. The code: <?php #File uploading script ////////////////////////////////////////////////////////////////// //File: upload_script.php //Author: Daniel Woodson (w/ help from gevans from phpfreaks.org) //Purpose: Upload multiple files //Last update: 12-10-08 //Comment: Working on renaming uploaded files ////////////////////////////////////////////////////////////////// ////////////////functions//////////////////// function create_date($year, $month, $day){ //function combines year, month, and day into a yyyy-mm-dd format if($month < 10){ $month = '0' . $month; } if($day < 10){ $day = '0' . $day; } return $year . "-" . $month . "-" . $day; }//end create_date() function create_song_array($set, $unique_show_id, $set_num) { /*function takes in show.set object, splits that object into an array, and then makes it multidiminsional. It then creates and assigns song ids to the first row of the array and song titles to the third row */ //split the object($set) into a dummy array based on ',' and '>', using perl-type regex $dummy_array = preg_split("/(,|>)/", $set); //use the trim() function to remove leading/trailing white spaces for($i=0;$i<count($dummy_array);$i++){ $dummy_array[$i] = trim($dummy_array[$i]); } //then create the real array as a copy of dummy array $song_array = array(count($dummy_array)); //make the real array multidiminsional and create eight //rows to hold the song's various properties for($i = 0; $i < count($dummy_array); $i++){ $song_array[$i] = array(; } //assign song title, set_one_songs[2] = dummy_array[1] for($m = 0; $m < count($dummy_array); $m++){ $song_array[$m][2] = $dummy_array[$m]; } //assign unique song ids (###NOTE: $n+1 should return a value which is in a 2 digit form###) for($n = 0; $n < count($dummy_array); $n++) { $song_array[$n][0] = $unique_show_id . "s" . $set_num . "s" . ($n+1); } //return newly created array return $song_array; }//create_song_array() function showIdCreator($band, $date) { /*this function takes in the user inputed band name and show date. It then produces an abbreviation from the band name. It then returns this abbreviation combined with the show date to create the show id*/ //variable declarations $abb;//store the abbreviated band name //convert the band name to lower case for easier comparison $band = strtolower($band); //set abbreviation based on band name switch($band) { case "widespread panic" : $abb = "wsp"; break; case "grateful dead" : $abb = "gd"; break; case "phish" : $abb = "ph"; break; case "ryan adams" : $abb = "ra"; break; default: $abb = "unknown"; break; } //return a combination of the band name abbreviation and the show date return $abb . $date; }//end showIdCreator() function printHead(){ echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>File Uploader</title> <style type="text/css" title ="text/css" media="all"> .error { font-weight: bold; color: #C00 } </style> </head> <body>'; }//end printHead() ////////////////end of functions//////////////////// ////////////////begin lead-in php/////////////////// //turn on error reporting ini_set('display_errors', 'On'); error_reporting(E_ALL | E_STRICT); //print html header printHead(); #print html head //###This is the code recommended by fly honey###// //Initailize and assign values to starter variables. if ($_POST && $_POST['submit'] == 'Submit') { $band = $_POST['band']; $year = $_POST['year']; $month = $_POST['month']; $day = $_POST['day']; $date = create_date($year, $month, $day); $setOne = $_POST['setOne']; } //this is my original code /*$show_id = ""; $band = $_POST['band']; $year = $_POST['year']; $month = $_POST['month']; $day = $_POST['day']; $date = create_date($year, $month, $day); $setOne = $_POST['setOne']; */ //create a unique show id $unique_show_id = showIdCreator($band, $date); //create an array of songs based on set on and save it to an array of the same name $set_one = create_song_array($setOne, $unique_show_id, "1"); //check to see if file has been submitted if(isset($_POST['submitted'])){ //start a loop to move through all the files for($i = 0; $i < count($_FILES['upload']['name']); $i++){ //debug - show all pertinate file info /*echo "<pre>"; print_r($_FILES); echo "</pre>";*/ //create an array of allowed types (###NOTE: need MIME type for Flac###) $allowed = array('audio/mpeg'); //now evaluate current file //check to see if current file's type is in the array of allowed types if(in_array($_FILES['upload']['type'][$i], $allowed)){ //If True, move the file to new location if(move_uploaded_file($_FILES['upload']['tmp_name'][$i], "/home/dan/MusicDataBase/" . $set_one[$i][0] . ".mp3")){ echo '<p><em>The file has been uploaded!</em></p>'; //Delete file if if still exist if(file_exists($_FILES['upload']['tmp_name'][$i]) && is_files($_FILES['upload']['tmp_name'][$i])){ unlink($_FILES['upload']['tmp_name'][$i]); } } else { if($_FILES['upload']['error'][$i] > 0){ echo '<p class="error">The file could not be uploaded because: <strong>'; //print message based on error switch($_FILES['upload']['error'][$i]){ case 1: print 'The file exceeds the upload_max_filesize settiing in php.ini'; break; case 2: print 'The file exceeds the MAX_FILE_SIZE setting in the html form'; break; case 3: print 'The file was only partially uploaded'; break; case 4: print 'No file was uploaded'; break; case 6: print 'No temporary folder was available'; break; case 7: print 'Unable to write to the disk'; break; case 8: print 'File upload was stopped'; break; default: print 'A system error occured'; break; }//end of switch print '</strong></p>'; }//end of error if } } else {//invaild type echo '<p class="error">Error: Wrong filetype. Must be an mp3</p>'; }//end else }//end for loop }//end isset ////////////////begin actual page/////////////////// //display show information echo "The band is: " . $band . "<br>"; echo "The show date is: " . $date . "<br>"; echo "Unique show id: " . $unique_show_id . "<br><br>"; //end original php section ?> <form enctype="multipart/form-data" action="upload_script_ver2.php" method="post"> <?php //create hidden values to be passed to the next page echo "<input type =\"hidden\" name =\"band\" value =\"" . $band . "\" />"; echo "<input type =\"hidden\" name =\"year\" value =\"" . $year . "\" />"; echo "<input type =\"hidden\" name =\"month\" value =\"" . $month . "\" />"; echo "<input type =\"hidden\" name =\"day\" value =\"" . $day . "\" />"; echo "<input type =\"hidden\" name =\"setOne\" value =\"" . $setOne . "\" />"; //use a for loop to produce multiple upload boxes for($i = 0; $i < count($set_one); $i++){ ?> <input type ="hidden" name = "MAX_FILE_SIZE" value = "209715200" /> <fieldset><legend>Select a mp3 to upload:</legend> <p><b>file:</b><input type="file" name ="upload[]" /></p> </fieldset> <?php //end for loop } ?> <div align="center"><input type="submit" name="submit" value="Submit" /></div> <input type="hidden" name="submitted" value="TRUE" /> </form> </body> </html> and here's my errors: (Note:these all appear on the first load of the second page, that is, before I try to upload anything) Notice: Undefined index: submitted in /opt/lampp/htdocs/MSNTesting/upload_script_ver2.php on line 128 Which is the line: if ($_POST && $_POST['submit'] == 'Submit') { Notice: Undefined variable: date in /opt/lampp/htdocs/MSNTesting/upload_script_ver2.php on line 146 Which is the line: $unique_show_id = showIdCreator($band, $date); and Notice: Undefined variable: date in /opt/lampp/htdocs/MSNTesting/upload_script_ver2.php on line 218 Which is the line: echo "The show date is: " . $date . "<br>"; Since I'm getting errors for some of the variables but not others I'm a little confused Quote Link to comment https://forums.phpfreaks.com/topic/137460-variables-not-passing-from-page-to-page/#findComment-719247 Share on other sites More sharing options...
woodsonoversoul Posted December 18, 2008 Author Share Posted December 18, 2008 You are getting errors because you are checking for $_POST data when no form has been posted I understand why I'm getting the errors, I just don't understand why the variables aren't posting. P.S. Thanks for your help flyhoney Quote Link to comment https://forums.phpfreaks.com/topic/137460-variables-not-passing-from-page-to-page/#findComment-719253 Share on other sites More sharing options...
woodsonoversoul Posted December 18, 2008 Author Share Posted December 18, 2008 Now I'm using the code: if ($_POST && $_POST['submit'] == 'Submit') { $band = $_POST['band']; $year = $_POST['year']; $month = $_POST['month']; $day = $_POST['day']; $date = create_date($year, $month, $day); $setOne = $_POST['setOne']; } $year = $_POST['year']; $month = $_POST['month']; $day = $_POST['day']; $date = create_date($year, $month, $day); $setOne = $_POST['setOne']; and the only error I get is: Notice: Undefined index: submit in /opt/lampp/htdocs/MSNTesting/upload_script_ver2.php on line 128 Which I guess I'm fine with, but I'd like to understand why I need both the if statement and the assignment statements when it looks to me like they do the exact same thing. Plus there's no assignment statement for $band outside of the if statement but It's still passed both times the page is called, and I don't understand that either. Any insight? Quote Link to comment https://forums.phpfreaks.com/topic/137460-variables-not-passing-from-page-to-page/#findComment-719298 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.