2014-01-27 2 views
0

hallo ребята извините за беспокойство .. код теперь работает..и было так много проблем в моих предыдущих сообщениях, но это последние проблемы, которые я получаю. Я заметил, когда я правильно вставляю CSV-файл inserting..but, если я обновляю данные страницы, дублируется из-за почтовых данных. Как я могу заставить это не повторять? я пытаюсь вставить это, но я получаю сообщение об ошибкеCSV Post reload

SAVED_REQUEST = $_REQEUST; 
$SAVED_POST = $_POST; 
$SAVED_GET = $_GET; 
// FINALLY, IN YOUR LAST LINE ERASE THE PROBLEM VARIABLES... 
$_REQUEST = $_POST = $_GET = NULL; 
<?php $_REQUEST = $_POST = $_GET = NULL; ?> 

это мой предыдущий сценарий

  <form enctype="multipart/form-data" method="POST" action="" > 
      CSV<input type="file" name="file" /> 
      <input type="submit" value="submit" name="submit"/> 
      </form> 
      <?php 
      $connection = mysql_connect("localhost","root","") 
      or die ("Couldn't connect to server"); 
      $db = mysql_select_db("map", $connection) 
      or die ("Couldn't select database"); 
      if(isset($_POST['submit'])) 
      { 
      $file = $_FILES['file']['tmp_name']; 
      $handle = fopen($file,"r"); 
      if (($handle = fopen($file, "r")) !== FALSE) { 

      while ($fileop = fgetcsv($handle,1000,",","'")) 
      { 
      $a = $fileop[0]; 
      $b = $fileop[1]; 
      $c = $fileop[2]; 
      $d = $fileop[3]; 
      $e = $fileop[4]; 
      $f = $fileop[5]; 

     $sql = mysql_query("INSERT INTO hzy3o_zhgooglemaps_markers (title, addresstext, published, baloon, icontype, mapid) 
values('$a', '$b', '$c', '$d', '$e', '$f')"); 

      } 

     } 
     } 

ответ

1

После успешной вставки делают переадресацию на той же странице:

header("Location: http://www.yourwebsite.com/yourpage"); /* Redirect browser */ 
exit(); 

сделать Также проверьте базу данных, чтобы предотвратить дублирование данных.

Ваш переработан код:

<?php 
if (isset($_POST['submit'])) { 
$file = $_FILES['file']['tmp_name']; 
$handle = fopen($file, "r"); 
if (($handle = fopen($file, "r")) !== false) { 
    while ($fileop = fgetcsv($handle, 1000, ",", "'")) { 
     list($a, $b, $c, $d, $e, $f) = $fileop; 
     $sql = mysql_query(" 
      INSERT INTO hzy3o_zhgooglemaps_markers (title, addresstext, published, baloon, icontype, mapid) 
      values('$a', '$b', '$c', '$d', '$e', '$f') 
     "); 

    } 
} 
} 
?> 

<?php if (isset($_POST) && count($_POST) > 0):?> 
<form enctype="multipart/form-data" method="POST" action="" > 
    CSV<input type="file" name="file" /> 
    <input type="submit" value="submit" name="submit"/> 
</form> 
<?php else: ?> 
<?php 
header("Location: http://www.shambani.org /index.php?option=com_zhgooglemap&view=zhgooglemap&id=1&mapzoom=13&placemarklistid=&explacemarklistid=&grouplistid=&categorylistid=¢erplacemarkid=¢erplacemarkaction=&externalmarkerlink=0&mapwidth=&mapheight=&Itemid=177"); 
exit(); 
?> 

Попробуйте.

+0

sory..i имел чрезвычайную ситуацию .... – Mary

+0

я получаю неожиданный «} – Mary

+0

@ oleksii.svarychevskyi..are вы там? – Mary

1
many thanks to gurus who Assisted me to Develope this.. i thank you very much 
<?php 
$connection = mysql_connect("localhost","root","") 
or die ("Couldn't connect to server"); 
$db = mysql_select_db("map", $connection) 
or die ("Couldn't select database"); 
if(isset($_POST['submit'])) 
{ 

$file = $_FILES['file']['tmp_name']; 
$handle = fopen($file,"r"); 
if (($handle = fopen($file, "r")) !== FALSE) { 

while ($fileop = fgetcsv($handle,1000,",","'")) 
{ 
$a = $fileop[0]; 
$b = $fileop[1]; 
$c = $fileop[2]; 
$d = $fileop[3]; 
$e = $fileop[4]; 
$f = $fileop[5]; 

$sql = mysql_query("INSERT INTO hzy3o_zhgooglemaps_markers (title, addresstext,  published, baloon, icontype, mapid) 

values('$a', '$b', '$c', '$d', '$e', '$f')"); 

} 
} 
} 

?> 

<?php 
if (isset($_POST) && count($_POST) > 0) { 
    header("Location:  http://localhost/map/"); /* Redirect browser */ 
    exit(); 
} 

?> 
<form enctype="multipart/form-data" method="POST" action="" > 
CSV<input type="file" name="file" /> 
<input type="submit" value="submit" name="submit"/> 
</form>