Buona giornata afosa a tutti
Dopo molto smanettamento finalmente sono riuscito a finire il mio progettino ma ho un ultimo ostacolo che non riesco a superare.
Iniziamo...

Il link in questione è questo: http://www.stefanoforcina.com/pages/...ndro%20Baricco

Scusate la lunghezza ma si porta dietro 4 variabili dalla pagina precedente (foto, galleria, citazione e autore).
I campi obbligatori nei form di richiesta acquisto foto sono solo nome e mail e se non vengono inseriti ovviamente la pagina avverte con un alert.
Il problema è che dopo generato l'alert la pagina viene ricaricata (shop.php) ma senza le 4 variabili che ho indicato in precedenza e quindi esce fuori una pagina incompleta perchè mi mancano delle informazioni.
Spero di essere stato chiaro...

Ho provato ad usare variabili di sessione credendo che dopo il refresh restassero ma non ha funzionato.

Il codice che controlla il form è il seguente:

Codice PHP:
<?
// OPTIONS - PLEASE CONFIGURE THESE BEFORE USE!

$yourEmail "stefanoforcina@gmail.com"// the email address you wish to receive these mails through
$yourWebsite "STEFANO FORCINA FOTO"// the name of your website
$thanksPage 'acquisto.php'// URL to 'thanks for sending mail' page; leave empty to keep message on the same page 
$maxPoints 4// max points a person can hit before it refuses to submit - recommend 4
$requiredFields "nome,email"// names of the fields you'd like to be required as a minimum, separate each field with a comma

// DO NOT EDIT BELOW HERE

$error_msg = array();
$result null;

$requiredFields explode(","$requiredFields);

function 
clean($data) {
   
$data trim(stripslashes(strip_tags($data)));
   return 
$data;
}
function 
isBot() {
    
$bots = array("Indy""Blaiz""Java""libwww-perl""Python",  "OutfoxBot""User-Agent""PycURL""AlphaServer""T8Abot""Syntryx",  "WinHttp""WebBandit""nicebot""Teoma""alexa""froogle",  "inktomi""looksmart""URL_Spider_SQL""Firefly",  "NationalDirectory""Ask Jeeves""TECNOSEEK""InfoSeek",  "WebFindBot""girafabot""crawler""www.galaxy.com""Googlebot",  "Scooter""Slurp""appie""FAST""WebBug""Spade""ZyBorg",  "rabaz");

   foreach (
$bots as $bot)
      if (
stripos($_SERVER['HTTP_USER_AGENT'], $bot) !== false)
         return 
true;

   if (empty(
$_SERVER['HTTP_USER_AGENT']) || $_SERVER['HTTP_USER_AGENT'] == " ")
      return 
true;
   
   return 
false;
}

if (
$_SERVER['REQUEST_METHOD'] == "POST") {
   if (
isBot() !== false)
      
$error_msg[] = "No bots please! UA reported as: ".$_SERVER['HTTP_USER_AGENT'];
      
   
// lets check a few things - not enough to trigger an error on their own, but worth assigning a spam score.. 
   // score quickly adds up therefore allowing genuine users with 'accidental' score through but cutting out real spam :)
   
$points = (int)0;
   
    
$badwords = array("adult""beastial""bestial""#######""clit",  "cum""cunilingus""cunillingus""cunnilingus""cunt""ejaculate",  "fag""felatio""fellatio""fuck""fuk""fuks""gangbang",  "gangbanged""gangbangs""hotsex""hardcode""jism""jiz",  "orgasim""orgasims""orgasm""orgasms""phonesex""phuk""phuq",  "pussies""pussy""spunk""xxx""viagra""phentermine""tramadol",  "adipex""advai""alprazolam""ambien""ambian""amoxicillin",  "antivert""blackjack""backgammon""texas""holdem""poker",  "carisoprodol""ciara""ciprofloxacin""debt""dating""porn",  "link=""voyeur""content-type""bcc:""cc:""document.cookie",  "onclick""onload""javascript");

   foreach (
$badwords as $word)
      if (
         
strpos(strtolower($_POST['note']), $word) !== false || 
         
strpos(strtolower($_POST['nome']), $word) !== false
      
)
         
$points += 2;
   
   if (
strpos($_POST['note'], "http://") !== false || strpos($_POST['note'], "www.") !== false)
      
$points += 2;
   if (isset(
$_POST['nojs']))
      
$points += 1;
   if (
preg_match("/(<.*>)/i"$_POST['note']))
      
$points += 2;
   if (
strlen($_POST['nome']) < 3)
      
$points += 1;
   if (
strlen($_POST['note']) < 15 || strlen($_POST['note'] > 1500))
      
$points += 2;
   if (
preg_match("/[bcdfghjklmnpqrstvwxyz]{7,}/i"$_POST['note']))
      
$points += 1;
   
// end score assignments

   
foreach($requiredFields as $field) {
      
trim($_POST[$field]);
      
       if (!isset(
$_POST[$field]) || empty($_POST[$field]) &&  array_pop($error_msg) != "Compila tutti i campi obbligatori per essere  ricontattato (nome ed email).\r\n")
         
$error_msg[] = "Compila tutti i campi obbligatori per essere ricontattato (nome ed email).";
   }

   if (!empty(
$_POST['nome']) && !preg_match("/^[a-zA-Z-'\s]*$/"stripslashes($_POST['name'])))
      
$error_msg[] = "Non puio inserire caratteri speciali nel nome.\r\n";
   if (!empty(
$_POST['cognome']) && !preg_match("/^[a-zA-Z-'\s]*$/"stripslashes($_POST['cognome'])))
      
$error_msg[] = "Non puio inserire caratteri speciali nel cognome.\r\n";
    if (!empty(
$_POST['email']) &&  !preg_match('/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])(([a-z0-9-])*([a-z0-9]))+'  '(\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)+$/i',  strtolower($_POST['email'])))
      
$error_msg[] = "Non hai inserito un indirizzo email valido.\r\n";
   if (!empty(
$_POST['note']) && !preg_match("/^[a-zA-Z-'\s]*$/"stripslashes($_POST['note'])))
      
$error_msg[] = "Non puio inserire caratteri speciali nelle note.\r\n";
   
   if (
$error_msg == NULL && $points <= $maxPoints) {
      
$subject "Acquisto stampa dal mio sito";
      
      
$message "Stefano, hai venduto una foto! \n\n";
      foreach (
$_POST as $key => $val) {
         if (
is_array($val)) {
            foreach (
$val as $subval) {
               
$message .= ucwords($key) . ": " clean($subval) . "\r\n";
            }
         } else {
            
$message .= ucwords($key) . ": " clean($val) . "\r\n";
         }
      }
      
$message .= "\r\n";
      
$message .= 'IP: '.$_SERVER['REMOTE_ADDR']."\r\n";
      
$message .= 'Browser: '.$_SERVER['HTTP_USER_AGENT']."\r\n";
      
$message .= 'Points: '.$points;

      if (
strstr($_SERVER['SERVER_SOFTWARE'], "Win")) {
         
$headers   "From: $yourEmail\r\n";
      } else {
         
$headers   "From: $yourWebsite <$yourEmail>\r\n";   
      }
      
$headers  .= "Reply-To: {$_POST['email']}\r\n";

      if (
mail($yourEmail,$subject,$message,$headers)) {
         if (!empty(
$thanksPage)) {
            
header("Location: $thanksPage");
            exit;
         } else {
            
$result 'Your mail was successfully sent.';
            
$disable true;
         }
      } else {
         
$error_msg[] = 'Your mail could not be sent this time. ['.$points.']';
      }
   } else {
      if (empty(
$error_msg))
         
$error_msg[] = 'Your mail looks too much like spam, and could not be sent this time. ['.$points.']';
   }
}
function 
get_data($var) {
   if (isset(
$_POST[$var]))
      echo 
htmlspecialchars($_POST[$var]);
}
?>
Mentre il codice che genera l'alert nel caso i campi fossero incompleti è il seguente:

Codice PHP:
<?
      
if (!empty($error_msg)) {
          echo 
'<div class="alert alert-dismissible  alert-danger">OPS! 'implode("<br />"$error_msg) .  "</div>";
      }
      if (
$result != NULL) {
         echo 
'<div class="alert alert-dismissible alert-success">'$result "</div>";
      }
   
?>
Ringrazio chiunque possa illuminarmi