SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2008
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Input Field to PHP File

    Right now to build a static site I use index.php files and an info.php where I put things that will appear on all pages like the Menu so I can change it in that 1 file and it will change it on all the pages.

    For example, on my index.php I have an include to include the info.php and I would have somethin like this for a link in the menu

    Code php:
    <a href="<?php echo $contacturl ?>">Contact</a>

    and then in the info.php file

    Code php:
    <?php
    $contacturl = '/contact';
    ?>

    Is there a way I could have an input field on a seperate page that uses value= to display whats in the ' '; for $contacturl so I can see what it is before I enter a new value to change the information inside the ' '; which would then change the link on the site?

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)
    Something like?
    PHP Code:
    <input type="text" id="contacturl" value="<?php echo $contacturl ?>"/>

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2008
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mittineague View Post
    Something like?
    PHP Code:
    <input type="text" id="contacturl" value="<?php echo $contacturl ?>"/>
    That would work to display what is in the info.php file but what do I do so what I type into the input replaces whats in the info.php file for $contacturl?

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)
    I'm more accustomed to sending a form to a PHP file that UPDATEs a database, but you could have the PHP file read/write to a file too.

    For example, it could read info.php, replace the value of
    $contacturl = '/contact';
    with
    $contacturl = '/somethingnew';
    and write back to the info.php file.

    Not as efficient as a database perhaps, but as long as you're not doing too much of it too often it should work OK.


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
  •