MKDIR PHP & Header (местоположение :) - PullRequest
0 голосов
/ 09 января 2019

У меня следующая проблема. Я должен убедиться, что сначала я ввожу данные в таблицу ниже, а затем, после нажатия кнопки «отправить», запускаю скрипт createDirectory () и меня перенаправляют на страницу, содержащуюся в функция заголовка Помимо того, что вы перенаправлены, вы также должны добавить в ссылку на страницу поле "idCantiere" .. С попытками, которые я только что сделал, когда я нажимаю кнопку, он перенаправляет меня на ту же страницу, но все белое.

У вас есть какие-нибудь решения, чтобы предложить мне? Я думал, что с простым заголовком я мог бы сделать перенаправление ...

<!doctype html>
<?php 

	$idCantiere = $_GET["idCantiere"];


	session_start();
    if(!isset($_SESSION["username"])){
    	header('location: ../../../index.php');
    }
    else
    {
	
?>
<html>
<?php



?>

	
<head>
	<style>
		#senzaBordi{border-style: none;}
		
		.bordi{ 
				border-width: 5px;
				border-style: solid;
		}
	</style>
    <link href="../bootstrap/bootstrap.css" rel="stylesheet" id="bootstrap-css">
  	<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
  	<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>

	<meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Affidataria / Soci ATI</title>
	
</head>
<script>
	function color(el){
  if(el.value=="OK"){
    el.parentNode.parentNode.style.backgroundColor="#00ff00";
  }
  else{
    el.parentNode.parentNode.style.backgroundColor="#B35556";
  }
 }
	</script>
<body>



<?php
   
	function createDirectory()
		{
			$nomeCantiere = $_POST["nomeCantiere"];
			date_default_timezone_set('Europe/Rome');
			$date = date('Y-m-d');
			chdir("../../../../Archivio/Cantieri");    
			mkdir($date."_".$nomeCantiere);
			echo "<script type='text/javascript'>alert('Done!');</script>";
			header('location:affidatario2.php?idCantiere=<?php echo $idCantiere?>');
		}
?>
   
<form method="POST" action="">
 <?php
     $idAffidataria = rand();
 ?>
<table cellspacing="0" cellpadding="0" border="3px" id="myTable" class="table table-bordered" id="tab1" name="tab1" >
<?php
     if (!isset($_POST['submit'])) {
?>
 
  <tr>
    <td style=" border-style: none;" width="64"></td>
    <td width="1479" colspan="8" align="center" bgcolor="#a5dfff" style="border: 2px solid black;"><strong>AFFIDATARIA</strong></td>
    <td style=" border-style: none;" width="64"></td>
    <td width="1088" colspan="8" align="center" bgcolor="#B35556"><strong>R.I.    / C.S.E.</strong></td>
  </tr>
  <tr>
    <td style=" border-style: none;"></td>
    <td bgcolor="#CDECFD"><strong>I.D.</strong></td>
    <td colspan="4" bgcolor="#CDECFD"><strong>Documento</strong></td>
    <td colspan="2" bgcolor="#CDECFD"><strong>Note</strong></td>
	<td bgcolor="#CDECFD" ></td>
    <td style=" border-style: none;"></td>
    <td bgcolor="#B35556">Verifica</td>
    <td bgcolor="#B35556">Note sul doc</td>   
  </tr>
  <tr>
    <td style=" border-style: none;"></td>
    <td bgcolor="#CDECFD" style="font-weight: bold">1</td>
    <td colspan="2" bgcolor="#CDECFD" style="font-weight: bold">Cantiere</td>
    <td colspan="4" bgcolor="#CDECFD"><input type="text" class="form-control" style="width: 100%;" name="nomeCantiere" id="nomeCantiere" />&nbsp;</td>
	<td bgcolor="#CDECFD" ></td>
  </tr>
  <tr>
    <td style=" border-style: none;"></td>
    <td bgcolor="#CDECFD" style="font-weight: bold">1.1</td>
    <td colspan="2" bgcolor="#CDECFD" style="font-weight: bold">Ragione Sociale</td>
    <td colspan="4" bgcolor="#CDECFD"><input type="text" class="form-control" style="width: 100%;" name="ragioneSociale" id="ragioneSociale"/>&nbsp;</td>
		<td bgcolor="#CDECFD" ></td>

	
  </tr>
 
  <tr>
    <td style=" border-style: none;"></td>
	<td bgcolor="#CDECFD" style="font-weight: bold">1.2</td>
    <td colspan="2" bgcolor="#CDECFD" style="font-weight: bold">Tipologia Affidataria</td>
    <td  colspan="2" bgcolor="#CDECFD" style="font-weight: bold">
		
		 <select name="tipologiaAffidataria" class="form-control chkEdit" enable>
		   <option value="Affidataria" selected="selected">Affidataria</option>
		   <option value="Mandataria">Mandataria</option>
		   <option value="Mandante">Mandante</option>
		   <option value="Esecutrice">Esecutrice</option>
		  </select>
		
	</td>
			<td bgcolor="#CDECFD"style=" border-style: none;" ></td>
			<td bgcolor="#CDECFD"style=" border-style: none;" ></td>
			<td bgcolor="#CDECFD"style=" border-style: none;" ></td>

  </tr>
  <tr>
    <td style=" border-style: none;"></td>
    <td bgcolor="#CDECFD" style="font-weight: bold">2</td>
    <td bgcolor="#CDECFD" style="font-weight: bold">Addetto sicurezza</td>
	<td bgcolor="#CDECFD"><input type="text" style="width: 220px;" class="form-control" name="addettoSicurezza" id="addettoSicurezza" value="<?php echo $savedAddettoSicurezza; ?>"/></td>
    <td colspan="2" bgcolor="#CDECFD">Mail</td>
    <td bgcolor="#CDECFD"><input type="text" style="align:center;" class="form-control" style="width: 100%;" name="mailAffidataria" id="mailAffidataria" value="<?php echo $savedMailAffidataria; ?>"/></td>

   <td bgcolor="#CDECFD"colspan="2"><input type="submit" name="submit" value="Crea Directory Affidataria" href="affidatario2.php?idCantiere=<?php echo $idCantiere?>" class="btn btn-warning"></td>

</form>
  </tr>
  
<?php 
     }
     else{
       createDirectory();
    }
?>
</table>
	
	

	<script>
function openPage(pageName,elmnt,color) {
    var i, tabcontent, tablinks;
    tabcontent = document.getElementsByClassName("tabcontent");
    for (i = 0; i < tabcontent.length; i++) {
        tabcontent[i].style.display = "none";
    }
    tablinks = document.getElementsByClassName("tablink");
    for (i = 0; i < tablinks.length; i++) {
        tablinks[i].style.backgroundColor = "";
    }
    document.getElementById(pageName).style.display = "block";
    elmnt.style.backgroundColor = color;

}
// Get the element with id="defaultOpen" and click on it
document.getElementById("defaultOpen").click();
</script>
	<script language="javascript">
  function controlla(){
    x=document.prova;
    if (x.scelta.value=="si"){
      window.location.href = 'subAffidatario.php'
      return false;
    }
    if (x.scelta.value=="no"){
      alert("Hai risposto no");
       window.location.href = 'affidatario.php'
      return false;
    }
  }
</script>
	 <style>

    #drop_file_zone {

        background-color: #37bf00;

        border: #999 5px ;

        width: 150px;

        height: 150px;

        padding: 8px;

        font-size: 13px;
    }

    #drag_upload_file {

        width:50%;

        margin:0 auto;

    }

    #drag_upload_file p {

        text-align: center;

    }

    #drag_upload_file #selectfile {

        display: none;

    }
	
	.coloreTdDrop{
		background-color: #37bf00;
	}

</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript">
	var fileobj;
	function upload_file(e) {
		e.preventDefault();
		fileobj = e.dataTransfer.files[0];
		ajax_file_upload(fileobj);
	}

	function file_explorer() {
		document.getElementById('selectfile').click();
		document.getElementById('selectfile').onchange = function() {
		    fileobj = document.getElementById('selectfile').files[0];
			ajax_file_upload(fileobj);
		};
	}

	function ajax_file_upload(file_obj) {
		if(file_obj != undefined) {
		    var form_data = new FormData();                  
		    form_data.append('file', file_obj);
			$.ajax({
				type: 'POST',
				url: 'ajax.php',
				contentType: false,
				processData: false,
				data: form_data,
				success:function(response) {
					alert(response);
					$('#selectfile').val('');
				}
			});
		}
	}
</script>
<script language="JavaScript" type="text/javascript">
<!--
function protect(anObject, protection)
{
if (anObject == null) {
return true;
} // if (anObject == null)
var members = anObject.children.length;
var i = 0;
for (i=0;i<members;i++) 
{
	var curObject = anObject.children.item(i);
	if (curObject != null) 
	{
		protect(curObject,protection);
	} // if (curObject != null)
} // for (i=0;i<=members;i++)
anObject.disabled = protection;
return true;
} // function protect(anObject, protection)
//-->
 
</script>
</body>
</html>
<?php } ?>

MyTable

Result of createDirectoryFunction

1 Ответ

0 голосов
/ 09 января 2019

Для начала ваш код для вашего заголовка в функции createDirectory() имеет проблему:

header('location:affidatario2.php?idCantiere=<?php echo $idCantiere?>');

Должно быть:

header('location:affidatario2.php?idCantiere=' . $idCantiere);

...