SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    writing to a file

    How can I write/edit a file from my web-page

    will it make a difference as im using this
    <?
    include("ini.php3");
    ?>
    in the file thats going to be used to write to ini.php3

    I checked a couple things and only found fopen() is this how i do it, could someone give me an example please, thanks.

    Here are the variables to update.
    //variables to update


    // settings

    $dbhost ='localhost';
    $dbuser ='';
    $dbpassword ='';
    $db ='forum';

    // table names

    $topics ='topics';
    $replies ='replies';
    $users ='users';
    $management ='admin';

    // globals

    $sitename ='forum';
    $dbversion ='1.0';
    $DOMAIN_URL ='../';

    // forum settings

    $db_entries ='5';
    $db_display_type ='forum';
    $db_email ='false';
    $url ='./index.php3';

    // meta settings

    $author ='Andrew Johnstone';
    $smarttags ='true';
    $keyword ='';
    $description ='';
    $rating ='general';
    $robots ='index,follow';
    $revisit ='';
    $copyright ='';

    $contentstyle ='';
    $contenttype ='';
    $expires ='';
    $pragma ='no-cache';
    $cache ='no-cache';
    $imagetoolbar ='';

    // page settings

    $title ='forum';
    $delay ='2';
    $db_css ='style.css';
    $db_tablewidth ='55%';
    $body_attributes ='';
    $signature ='Created by Andrew-J';

  2. #2
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  3. #3
    SitePoint Evangelist
    Join Date
    Oct 2001
    Posts
    592
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Keep in mind that you're using in a multi-user environment. That is, when multiple clients open that particular page at the same time, they all want to write to the same file. This is generally not a good idea!

    Vincent

  4. #4
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, I can give you the pages so far to give you a better idea of what i am trying to accomplish.

    what i am attempting is to make a setupfile, for my forum, for the ini file that stores all the data, ie the the above variables listed in my first post.

    heres my ini file.

    Page (iniSetup.php3)
    PHP Code:
    <!-- ini setup file -->

    <?
        
    include("ini.php3");
        
    pageheader('ini setup file')

    ?>

    <script>
    function openPanel(option)
    {
        var adminpanel = open(option,'adminpanel','');
        adminpanel.focus();
    }

    function verifyUserCheck()
    {
        if (document.users.checkUser.checked==1)
        {
            alert ("checked = " + document.users.checkUser.checked);
            if(document.users.updateUser.value=="")
                {
                        alert("textbox updateUser = " + document.users.updateUser.value)
                        document.users.updateUser.value="Enter Username to ";
                        document.users.verifyUser.value="change username";
                        document.users.checkUser.checked=0;
                        window.status=(document.users.updateUser.value + document.users.verifyUser.value);
                        setTimeout('window.status="' + document.users.updateUser.value + '"',5000)
                }
        }
        else
            alert ("checked = " + document.users.checkUser.checked);
        
    }
    </script>

    <body bgcolor='#FFFFFF' text='#FFFFFF' link='#000000' vlink='#000000' alink='#000000' topmargin='0' leftmargin='0'>
    <div align="center"><form name="users" method="post" action="">
        <table width="366" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
          <tr> 
            <td valign="middle" height="26" colspan="8" align="center" bgcolor="#000000">ini 
              setup file</td>
          </tr>
          <tr> 
            <td valign="top" height="19" colspan="8" align="center"> 
              <p><font color="#000000">Modify Setup</font></p>
            </td>
          </tr>
          <tr> 
            <td valign="top" height="19" colspan="3" bgcolor="#333333"> 
              <div align="center"><font color="#FFFFFF">description</font></div>
            </td>
            <td valign="middle" colspan="4" align="center" bgcolor="#333333"><font color="#FFFFFF">details</font></td>
            <td width="63" valign="top" bgcolor="#333333"> 
              <div align="center"><font color="#FFFFFF">update</font></div>
            </td>
          </tr>
          <tr> 
            <td valign="middle" height="28" align="left" bgcolor="#CCCCCC" colspan="3"> 
              <div align="left"><font color="#000000">Update Username</font></div>
            </td>
            <td valign="top" bgcolor="#CCCCCC" align="center" colspan="4"> <font color="#000000"> 
              <input type="text" name="updateUser" onchange='document.users.updateUser.value=document.users.updateUser.value'>
              </font> <font color="#000000"> </font> <font color="#000000"> </font></td>
            <td valign="top" bgcolor="#CCCCCC">&nbsp;</td>
          </tr>
          <tr> 
            <td height="28" valign="middle" colspan="3" align="left"> 
              <div align="left"><font color="#000000">Verify</font> <font color="#000000">Username</font></div>
            </td>
            <td valign="top" colspan="4"> 
              <div align="center"><font color="#000000"> 
                <input type="text" name="verifyUser">
                </font></div>
            </td>
            <td valign="top"> 
              <div align="center"> 
                <input type="checkbox" name="checkUser" onclick="verifyUserCheck()">
              </div>
            </td>
          </tr>
          <tr> 
            <td height="28" valign="middle" align="left" bgcolor="#999999" colspan="3"> 
              <div align="left"><font color="#000000">Update Password</font></div>
            </td>
            <td valign="top" bgcolor="#999999" align="center" colspan="4"><font color="#000000"> 
              <input type="password" name="updatePass">
              </font></td>
            <td valign="top" bgcolor="#999999"> 
              <div align="center"></div>
            </td>
          </tr>
          <tr> 
            <td height="28" valign="middle" colspan="3" align="left"> 
              <div align="left"><font color="#000000">Verify Password</font></div>
            </td>
            <td valign="top" colspan="4"> 
              <div align="center"><font color="#000000"> 
                <input type="password" name="verifyPass">
                </font></div>
            </td>
            <td valign="top" align="center"> 
              <input type="checkbox" name="checkPass">
            </td>
          </tr>
          <tr> 
            <td height="21" valign="middle" colspan="8" bgcolor="#CCCCCC" align="center"> 
              <hr>
            </td>
          </tr>
          <tr> 
            <td height="19" valign="top" colspan="2"> 
              <div align="center"> <font color="#000000"> <b> <a href="javascript:void(0)" style="text-decoration:none" onclick="openPanel('pass.htm')">admin 
                panel</a> </b> </font> </div>
            </td>
            <td valign="top" colspan="2"> 
              <div align="center"> <a href="javascript:void(0)" style="text-decoration:none" onclick="openPanel('pass.htm')"> 
                <font color="#009933">New admin </font> </a> </div>
            </td>
            <td valign="top" colspan="2"> 
              <div align="center"> <a href="javascript:void(0)" style="text-decoration:none" onclick="openPanel('pass.htm')"> 
                <font color="#0000FF">Edit admin </font> </a> </div>
            </td>
            <td valign="top" width="65"> 
              <div align="center"> <a href="javascript:void(0)" style="text-decoration:none" onclick="openPanel('pass.htm')"> 
                <font color="#9900FF">List admin </font> </a> </div>
            </td>
            <td valign="top"> 
              <div align="center"> <a href="javascript:void(0)" style="text-decoration:none" onclick="openPanel('pass.htm')"> 
                <font color="#FF0000">Remove</font> </a> </div>
            </td>
          </tr>
          <tr> 
            <td height="21" colspan="8" valign="middle" bgcolor="#CCCCCC" align="center"> 
              <hr>
            </td>
          </tr>
          <tr> 
            <td height="13" width="78"></td>
            <td width="20"></td>
            <td width="23"></td>
            <td width="52"></td>
            <td width="48"></td>
            <td width="17"></td>
            <td></td>
            <td></td>
          </tr>
        </table>
      </form>
    </div>
    So far I have only incorperated usernames and passwords to be updated. So if this is not the best way to use fopen/fwrite etc then how would you dynamically update these variables?

  5. #5
    SitePoint Evangelist
    Join Date
    Oct 2001
    Posts
    592
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Assuming every client has his/hers own personal settings (username/password), aren't you much better of if you use sessions? Check the PHP manual and you'll see!

    Vincent


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •