Jump to content

LucaCrippa

Members
  • Posts

    20
  • Joined

  • Last visited

Everything posted by LucaCrippa

  1. Hello all, I'm trying to embed a public google calendar to my website using iframe, but this is not woorking in safari, chrome (private window) and i.e. The calendar is alrady set to public. This is the page: you can check it on multiple browsers. http://www.omcc03.net/testcinemanew/page.php?p=calendario How can I fix it? Thank you
  2. Hi, please could you tell me where I'm doing wrong? Page php 1: list of directories where to upload images (galleryedit.php) <?php $path = '../public/gallery';$dirs = scandir($path);foreach ($dirs as $valore) { if($valore === '.' || $valore === '..') { continue; } echo "<a href=uploadimage.php?cartella=$valore> <img src="images/icons/edit.png" title="Carica" width="15" height="15"> </a> $valore </br>";}?> Page php 2: form to upload image, which takes the name of the folder where I want to upload (uploadimage.php) <?php$path = '../public/gallery';$cartella = $path .'/'. $_GET['cartella'];echo "<form action="upload.php?updir=$cartella" method="post" enctype="multipart/form-data"> <input name="image" type="file" size="40" /> <br /><br /> <input name="submit" type="submit" value="Carica immagine" /></form>";?> Page php 3: the uploading facility, which takes the name of the folder (upload.php) <?php $path = '../public/gallery';$dir = $_GET['updir'];if(!isset($_SERVER['DOCUMENT_ROOT'])){ if(isset($_SERVER['SCRIPT_FILENAME'])){ $_SERVER['DOCUMENT_ROOT'] = str_replace( '', '/', substr($_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF']))); };}; if(!isset($_SERVER['DOCUMENT_ROOT'])){ if(isset($_SERVER['PATH_TRANSLATED'])){ $_SERVER['DOCUMENT_ROOT'] = str_replace( '', '/', substr(str_replace('', '', $_SERVER['PATH_TRANSLATED']), 0, 0-strlen($_SERVER['PHP_SELF']))); };};$PercorsoDominio = $_SERVER['DOCUMENT_ROOT'];$public = "/$path/$dir/";if(is_dir($PercorsoDominio.$public)){ continue; }else{ exit; }if ((($_FILES["file"]["type"] == "image/gif") ||($_FILES["file"]["type"] == "image/jpeg") ||($_FILES["file"]["type"] == "image/pjpeg") && ($_FILES["file"]["size"] < 20000000)) ) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { if (file_exists($PercorsoDominio. $public . $_FILES["file"]["name"])) { continue; } else { move_uploaded_file($_FILES["file"]["tmp_name"], $PercorsoDominio. $public . $_FILES["file"]["name"]); include("uploadsuccess.php"); } } }else { include("uploaderror.php"); }}?> Thank you!!
  3. Sure, but if I ask for info directly in a forum I would like to have an answer, just because there are many guides on the web... if one cannot solve its problems with guides, he asks in forums... Anyway, I'm trying Ingolme solution
  4. You are not telling me the solution. I know that I need to redirect only if the submit button is pressed, but I don't know how to do it. header('Location: ./Index.php');bla bla blaecho "<h7>Modifica l'evento</h7><p><form action="$_SERVER[php_self]" method= "post" ><textarea name="newd" cols="100%" rows="18"> $data </textarea><input type="submit" value="Salva modifiche" name="submitted"></form>";if($_SERVER['REQUEST_METHOD'] == "POST") { exit;} Not working. Found here: http://electrokami.com/coding/the-correct-way-to-check-php-form-submission/ last paragraph.
  5. <?php // set file to read$path = '../public/events';$edit = $path .'/'. $_GET['edi']; $newdata = $_POST['newd'];if ($newdata != '') { $fw = fopen($edit, 'w') or die('Could not open file!'); $fb = fwrite($fw,stripslashes($newdata)) or die('Could not write to file'); fclose($fw);} $fh = fopen($edit, "r") or die("Could not open file!"); $data = fread($fh, filesize($edit)) or die("Could not read file!"); fclose($fh);echo "<h7>Modifica l'evento</h7><p><form action="$_SERVER[php_self]" method= "post" ><textarea name="newd" cols="100%" rows="18"> $data </textarea><input type="submit" value="Salva modifiche" ></form>";header('Location: ./Index.php');exit;?> Not working.
  6. Not working. This is redirecting to my new page as entering my php page, but I would like to redirect after clicking the button of the form.
  7. $path = '../public/events';$edit = $path .'/'. $_GET['edi']; $newdata = $_POST['newd'];if ($newdata != '') { $fw = fopen($edit, 'w') or die('Could not open file!'); $fb = fwrite($fw,stripslashes($newdata)) or die('Could not write to file'); fclose($fw);} $fh = fopen($edit, "r") or die("Could not open file!"); $data = fread($fh, filesize($edit)) or die("Could not read file!"); fclose($fh);echo "<h7>Modifica l'evento</h7><p><form action="$_SERVER[php_self]" method= "post" ><textarea name="newd" cols="100%" rows="18"> $data </textarea><input type="submit" value="Salva modifiche" ></form>"; Yeah, I managed to solve it. With this code is working, but now the problem is that when I click on button txt file is saved, but the textarea remains freezed. How can I redirect on another page, such as a edit-confirmed page? Thank you!
  8. Pheraps I fail to open stream, or I have no file or directory.. Or the supplied argument is not a valid stream resource, I don't know.. Or there are two /?
  9. First, I succeeded to make secure session to protect my pages. Secondly, removing the @ in the editevent page brings me these errors: Warning: fopen(../public/events//) [function.fopen]: failed to open stream: No such file or directory inD:Inetpubwebscoroconcorezzoitcircolinoeditevent.php on line 42Warning: fopen(../public/events//) [function.fopen]: failed to open stream: No such file or directory inD:Inetpubwebscoroconcorezzoitcircolinoeditevent.php on line 49Warning: fread(): supplied argument is not a valid stream resource in D:Inetpubwebscoroconcorezzoitcircolinoeditevent.php on line 50Warning: fclose(): supplied argument is not a valid stream resource in D:Inetpubwebscoroconcorezzoitcircolinoeditevent.php on line52
  10. Any idea about fixin' also this problem?
  11. Ok, I'm trying. No, the editing page is protected by a login page!
  12. Ok, the error for the delete was: $deleted = $path .'/'. $_GET['delete']; I'm stupid. I tried to fix the other problem (the edit) with the same code but I failed!
  13. 2.txt in this case is really located in ../public/events so how can I modify my code to make it working? edit: aaahhhh I missed a / I'm trying edit2: no, it's not working at all..
  14. $loadcontent has actually the right value, in fact when I press the edit button the content of my txt file appears! When I click on Save on the form I have that error. About the deleting code, I tried to comment the $path variable but I got the same result. It's a mess!!
  15. I can't have a database for the site I'm building.. it was hard also persuading my clients (friends) to create a website rather than a free blog...
  16. Hi there, I have two problems with php, in particular about variable passing. In the admin page of a website I created a form to public "news entries". The event is saved in a txt file: filename.txt contains: $title | $date | $text | $location | $time $path = '../public/events'; $file = fopen("../public/events/$filename","w"); echo fwrite ($file, " $title | $date | $text | $location | $time "); Ok, this is working. But now I would like to delete and edit text files! I tried such a thing: 1) press it to delete event: <a href=delconfirm.php?del=$valori>Delete event</A> 2) delconfirm.php <?php $path = '../public/events';$d = $_GET['del']; echo " <center></br></br></br></br></br></br> Confirm? <p> <p> <h5><a href=delete.php?delete=$d> Yes </a><br></h5> <p> <p> <h5><a href=Index.php> No </a><br></h5> </center> "; ?> 3) delete.php <?php$path = '../public/events';$deleted = $_GET['delete'];if (!unlink($deleted)){ echo ("Erasing of $deleted failed<br>"); } else { echo (" <CENTER></br></br></br></br></br></br> Event $deleted succesfully erased! <p> <p> <h5><a href="Index.php">Home Page</a></h5> </CENTER> "); } ?> But I have this error: Warning: unlink(2.txt) [function.unlink]: No such file or directory in D:Inetpubwebscoroconcorezzoitcircolinodelete.php on line 19Impossibile eliminare 2.txt Second, the editing of a text file: <a href=editevent.php?edi=$valori>Edit event</A> 1) editevent.php <?php$path = '../public/events';$edit = $_GET['edi'];$loadcontent = "$path/$edit"; if($save_file) { $savecontent = stripslashes($savecontent); $fp = @fopen($loadcontent, "w"); if ($fp) { fwrite($fp, $savecontent); fclose($fp); } } $fp = @fopen($loadcontent, "r"); $loadcontent = fread($fp, filesize($loadcontent)); $loadcontent = htmlspecialchars($loadcontent); fclose($fp);?><table width="100%" border="0" vertical-align="text-top"> <tr> <td><h7>Edit</h7><p><form method=post action="<?=$_SERVER['PHP_SELF']?>"><textarea name="savecontent" cols="55" rows="18"><?=$loadcontent?></textarea><br><input type="submit" name="save_file" value="Save!"> </form></td> Actually it allows me to have the txt file content in the textarea, but there are these errors: Warning: fread(): supplied argument is not a valid stream resource in D:Inetpubwebscoroconcorezzoitcircolinoeditevent.php on line 51Warning: fclose(): supplied argument is not a valid stream resource in D:Inetpubwebscoroconcorezzoitcircolinoeditevent.php on line53 How can I manage it?? Thank you!!
  17. Hi there, I have a problem with post/get method in php forms. Here it is a form that allows the user to insert a new "blog post", including a title, a date and the text of the post. <form action="sendmail.php" method="post"> <table align="left" width="80%"> <tr> <td align=right><font face="Verdana,Arial" size="1"><B>Titolo</td> <td><font face="Verdana,Arial" size="1"><input name="title" size=28 value=""></td> </tr> <tr> <td align=right><font face="Verdana,Arial" size="1"><B>Data</td> <td><font face="Verdana,Arial" size="1"><input name="date" size=28 value=""></td> </tr> <tr> <td colspan=2><font face="Verdana,Arial" size="1"><B>Testo<BR><textarea name="text" cols=51 rows=10 wrap=soft></textarea></td> </tr> <tr> <td></td> <td><font face="Verdana,Arial" size="1"><input type="submit" value="Pubblica"></td> </tr> </table> </form> Now, I echo these info in a txt file: $file = fopen("../public/events/$filename","w"); echo fwrite($file,"<h6> $title </h6> </br> <h5> $date </h5> <p> $text <p> </br>"); fclose($file); in order to put it on my webpage. Now, I would like to modify a post! Also delete it, if necessary! But how can I read the txt file, extract the strings $title, $date, $text, put them into the form above and save it? Thank you!
  18. Ok... but, what is my server path? How can I find it? D:\Inetpub\webs\coroconcorezzoit\upload4.php ?
  19. Hi there, I'm a novice on php programmin', and I just have a question 'bout a script for uploadin' pdf files on my website. I would like to allow administrator to upload pdf files in the restricted area of the site, then I would like to implement a script that generates automatically the links for the download of the uploaded pdf files. This is the code: The form for the upload: <form action="upload3.php" method="post" enctype="multipart/form-data"> <input type="file" name="filepdf" /><br /> <input type="submit" value="Upload menu pdf" name="upload_pdf" /></form> The upload3.php file included in the form: <?php $pdfPath = "http://www.coroconcorezzo.it/Spartiti/"; $maxSize = 102400000000; if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['upload_pdf'])) { if (is_uploaded_file($_FILES['filepdf']['tmp_name'])) { if ($_FILES['filepdf']['type'] != "application/pdf") { echo '<p>Il file non è un PDF</p>'; } else if ($_FILES['filepdf']['size'] > $maxSize) { echo '<p class="error">File troppo grande. Dimensione massima: ' . $maxSize . 'KB</p>'; } else { $menuName = 'file.pdf'; $result = move_uploaded_file($_FILES['filepdf']['tmp_name'], $pdfPath . $menuName); if ($result == 1) { echo '<p class="error">Menu caricato</p>'; } else { echo '<p class="error">Si è verficato un errore</p>'; } } } }?> But when I try to upload a pdf file I receive this error message: The website is www.coroconcorezzo.itHow can I fix it? Thank you! ps: the files attribution is 777 for every file and folder in my website.
×
×
  • Create New...