php add email to a list file csv -


i'm trying build list email using csv file , problem im using cms on simpel site works ! when integreted in cms stop working , says :

access forbidden!you don't have permission access requested object. either read-protected or not readable server.if think server error, please contact webmaster.error 403127.0.0.1apache/2.4.7 (win32) php/5.5.8

this code on offline page :

</div><div class="clear"></div>     <form name="form1" action="<?php echo $_server['php_self'];?>" method="post" class="subscribe">         <input type="text" id="notify_by_mail" name="notify_by_mail" class="email"/>         <input type="submit" name="submit" value="go" class="submit"/>     </form> 

this php file code :

<?php         if($_post['formsubmit'] == "go")         {             $varname = $_post['notify_by_mail'];             $file = 'user_emails.csv'; /* .csv file */             $fs = fopen($file,"a"); /* opens csv file called user_emails.csv. */             fwrite($fs,$varname . ", \n"); /* , writes submitted email */             fclose($fs);             chmod($file,0622); /* permissions */         ?>              <script type="text/javascript">                 $(document).ready(function() {                      /* when user submits e-mailaddress successfully, next comment show below form. */                     $("#notify_by_mail").after("<span class='error'>your e-mailaddress has been submitted us.</span>");                  });             </script>          <?php         }     ?> 

i'v added .htaccess file :

<filesmatch "\.(csv)$|^$">    order deny,allow    allow </filesmatch> 

access forbidden!you don't have permission access requested object. either read-protected or not readable server.if think server error, please contact webmaster.error 403127.0.0.1apache/2.4.7 (win32) php/5.5.8

can .htaccess ?

you using decimal value should using hex.

chmod($file,0622); equivalent to: chmod($file,0x026e);

change:

chmod($file,0622); 

to:

chmod($file,0x0622); 

not sure want chmod after open , write file:

$varname = $_post['notify_by_mail']; $file = 'user_emails.csv'; /* .csv file */ $fs = fopen($file,"a"); /* opens csv file called user_emails.csv. */ fwrite($fs,$varname . ", \n"); /* , writes submitted email */ fclose($fs); chmod($file,0622); /* permissions */ 

you may want move chmod before open , write.

$varname = $_post['notify_by_mail']; chmod($file,0622); /* permissions */ $file = 'user_emails.csv'; /* .csv file */ $fs = fopen($file,"a"); /* opens csv file called user_emails.csv. */  fwrite($fs,$varname . ", \n"); /* , writes submitted email */ fclose($fs); 

if problem persists, view permissions , file info:

echo substr(sprintf('%o', fileperms($file)), -4); var_dump(stat($file)); 

if have concerns public access, move file private directory such as: /home/user/etc


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -