Menu

Error. Possibly due to my Server Permissions?

Help
Jay
2009-01-22
2013-06-03
  • Jay

    Jay - 2009-01-22

    I tried my form on my other hosting account (Where I originally created it) and I get no issues. With this one in particular, I get the following error atop of the results page that typically shows after submitting any form. The weird thing is they both are from the same hosting company, X12host.com. Perhaps this particular Server I am on is slightly more restricted towards php files?

    P.S This form was copy pasted from another Server (I moved the entire folder while making no edits). Would that make a difference?

    Here is the error:

    Warning: fopen(admin/data.dat) [function.fopen]: failed to open stream: Permission denied in /home/baccmiam/public_html/app/process.php on line 51

    Warning: fwrite(): supplied argument is not a valid stream resource in /home/baccmiam/public_html/app/process.php on line 55

    Also here is the PHP Code:

    <?php
    include("global.inc.php");
    $errors=0;
    $error="The following errors occured while processing your form input.<ul>";
    pt_register('POST','FirstName');
    pt_register('POST','LastName');
    pt_register('POST','Title');
    pt_register('POST','Email');
    pt_register('POST','CompanyName');
    pt_register('POST','Position');
    pt_register('POST','MailingAddress');
    pt_register('POST','City');
    pt_register('POST','PostalCode');
    pt_register('POST','StateorProvince');
    pt_register('POST','Country');
    pt_register('POST','MainPhone');
    pt_register('POST','Fax');
    pt_register('POST','CompanyWebsite');
    pt_register('POST','MembershipCategory');
    pt_register('POST','AdditionalComments');
    $AdditionalComments=preg_replace("/(\015\012)|(\015)|(\012)/","&nbsp;<br />", $AdditionalComments);if($FirstName=="" || $LastName=="" || $Title=="" || $Email=="" || $CompanyName=="" || $Position=="" || $MailingAddress=="" || $City=="" || $PostalCode=="" || $StateorProvince=="" || $Country=="" || $MainPhone=="" || $MembershipCategory=="" || $AdditionalComments=="" ){
    $errors=1;
    $error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
    }
    if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$Email)){
    $error.="<li>Invalid email address entered";
    $errors=1;
    }
    if($errors==1) echo $error;
    else{
    $where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
    $message="First Name: ".$FirstName."
    Last Name: ".$LastName."
    Title: ".$Title."
    Email: ".$Email."
    Company Name: ".$CompanyName."
    Position: ".$Position."
    Mailing Address: ".$MailingAddress."
    City: ".$City."
    Postal Code: ".$PostalCode."
    State or Province: ".$StateorProvince."
    Country: ".$Country."
    Main Phone: ".$MainPhone."
    Fax: ".$Fax."
    Company Website: ".$CompanyWebsite."
    Membership Category: ".$MembershipCategory."
    Additional Comments: ".$AdditionalComments."
    ";
    $message = stripslashes($message);
    mail("terim711@gmail.com","Form Submitted at your website",$message,"From: phpFormGenerator");
    $make=fopen("admin/data.dat","a");
    $to_put="";
    $to_put .= $FirstName."|".$LastName."|".$Title."|".$Email."|".$CompanyName."|".$Position."|".$MailingAddress."|".$City."|".$PostalCode."|".$StateorProvince."|".$Country."|".$MainPhone."|".$Fax."|".$CompanyWebsite."|".$MembershipCategory."|".$AdditionalComments."
    ";
    fwrite($make,$to_put);
    ?>

    <!-- This is the content of the Thank you page, be careful while changing it -->

    <h2>Thank you!</h2>

    <table width=50%>
    <tr><td>First Name: </td><td> <?php echo $FirstName; ?> </td></tr>
    <tr><td>Last Name: </td><td> <?php echo $LastName; ?> </td></tr>
    <tr><td>Title: </td><td> <?php echo $Title; ?> </td></tr>
    <tr><td>Email: </td><td> <?php echo $Email; ?> </td></tr>
    <tr><td>Company Name: </td><td> <?php echo $CompanyName; ?> </td></tr>
    <tr><td>Position: </td><td> <?php echo $Position; ?> </td></tr>
    <tr><td>Mailing Address: </td><td> <?php echo $MailingAddress; ?> </td></tr>
    <tr><td>City: </td><td> <?php echo $City; ?> </td></tr>
    <tr><td>Postal Code: </td><td> <?php echo $PostalCode; ?> </td></tr>
    <tr><td>State or Province: </td><td> <?php echo $StateorProvince; ?> </td></tr>
    <tr><td>Country: </td><td> <?php echo $Country; ?> </td></tr>
    <tr><td>Main Phone: </td><td> <?php echo $MainPhone; ?> </td></tr>
    <tr><td>Fax: </td><td> <?php echo $Fax; ?> </td></tr>
    <tr><td>Company Website: </td><td> <?php echo $CompanyWebsite; ?> </td></tr>
    <tr><td>Membership Category: </td><td> <?php echo $MembershipCategory; ?> </td></tr>
    <tr><td>Additional Comments: </td><td> <?php echo $AdditionalComments; ?> </td></tr>
    </table>
    <!-- Do not change anything below this line -->

    <?php
    }
    ?>

     
    • TNTEverett

      TNTEverett - 2009-01-22

      First:
      Check that the folder and file exist and have the same permissions from one site to the other.  Th efile must exist and it must be writable. 
      The fwrite fails because fopen fails, so the source of both errors is the fopen function. 

      Next:
      Talk to your web host.  This should not be an issue. 

       
    • Jay

      Jay - 2009-01-22

      Yea I tried changing permissions to the process.php and (admin/data.dat) etc.. basically anything that did not have 777 as permissions I set it to lol.. Still giving my an issue, so i sent an email to my web host to see why this is happening. Lets see what they say.

      Thanks  (tnteveret1) your a genius! =P

       
    • Jay

      Jay - 2009-01-22

      I found this on their site. Do you think this has anything to do with my problem?

      "How to change a php.ini value?

      We use suPHP in all of our servers. This is the common reason why php_flag or php_value doesn't work on X12 servers. To change a value like "register_globals" or other you need to use a custom php.ini file put in the public_html folder. Suppose, if you want to change the value of register_globals using a custom php.ini file, just put the following inside a php.ini file created on your public_html folder:

      register_globals = On

      It should set your register_globals value to On, If you want to set the value to Off, use the following:

      register_gloabls = Off

      Use the same settings for all available php.ini values to be configurable by users.

      After you are done with setting up php.ini file, you need to set the suPHP configpath so that all other subdirectories in your public_html takes that php.ini as its default configuration file. To do this put the following line in your .htaccess:

      suPHP_ConfigPath /home/username/public_html

      You need to change two things to correct values from your account settings. Username set at the above configuration is your cpanel username. You also need to find what home directory you are on, if it is /home, you do not need to do any changes above, but if it is /home2 or /home3 etc, you need to change with correct values. This settings can be found in your file manager or Go to Cpanel and from the left menu find out the path to your "Root Directory" or "WWW Directory" or "Home Directory".

      Thats it, you should be all ON :)"

       
      • TNTEverett

        TNTEverett - 2009-01-22

        Possible but not likely unless it has been totally screwed up.  With default values I would still expect your form to work. 

         
        • Jay

          Jay - 2009-01-22

          Oh ok, I doubt it because I haven't really done any changes to any other folders. I will still compare the two sites side by side and make sure the problematic site matches the original with the same permissions on each folder.

          If anything I will request them to delete and refresh the entire site since I have the public_html backed up.

           
    • Dave H

      Dave H - 2009-01-28

      Jay,
      just curious, did creating the php.ini file and setting register_globals=Off work for you? I have had problems with various applications when register_globals=Off including problems with phpformgen.

      As of php 4.2 the default value for register_globals=On. It is one of the most controversial default setting changes.

      See here: http://us2.php.net/register_globals

      all in all, I really like phpformgen and it has done me well.

      Thanks.
      Dave

       
    • Jay

      Jay - 2009-01-30

      I tryed adding php_value register_globals on to my php.ini and my .htaccess and nothing... Still gives me the same error. I am going to try changing hosts and hope it works.

       
    • Dave H

      Dave H - 2009-01-30

      Jay,
      just wondering, did you happen to restart your web server daemon after making the additions to your php.ini or .htaccess?
      Dave

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.