简体   繁体   中英

MKDIR PHP & Header(location:)

I have the following problem .. I have to ensure that initially I enter data in the table below and then after pressing the "submit" button I run the script createDirectory () and that I be redirected to the page contained in the header function. In addition to being redirected, you must also put in the page link the field "idCantiere" .. With the attempts I've just made, once I press the button, it redirects me to the same page but all white.

Do you have any solutions to offer me? I thought that with a simple header I could do the redirect ...

 <!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('Ym-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>RI / CSE</strong></td> </tr> <tr> <td style=" border-style: none;"></td> <td bgcolor="#CDECFD"><strong>ID</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 } ?>

我的表

createDirectoryFunction 的结果

For starters your code for your header in the createDirectory() function has a problem:

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

Should be:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM