I need to get this PHP file to edit the HTML file.
So far i've got it working but it adds the html to the bottom of the page instead of where I want it (which is marked as ADD NEW HTML HERE in the HTML code)
What do I need to put in to get this working.
(Bearing mind im a complete PHP newb. :o)
Thanks!

Here is the PHP:

<html>
<head>
<title>Image Generate XML NeonImage</title>
<meta name="robots" content="noindex, nofollow">
</head>
<body>
<?php
if(!$_POST['submit']) { //is form submitted?
//no - show form
?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<br>
</label>Company</label>
<p><input type="text" maxlength="1000" name="comp"></p>
</label>Name</label>
<p><input type="text" maxlength="1000" name="name"></p>
</label>Testimonial</label>
<p><input type="text" maxlength="10000" name="test"></p>
<br>
</label>Username</label>
<p><input type="text" maxlength="300" name="user"></p>
</label>Password</label>
<p><input type="password" maxlength="300" name="pass"></p>
<br>
<p><input type="submit" value="Generate" name="submit"></p>
<form>
<?php
}
else { //else yes it is - process it
//define vars
$file = addslashes($_POST['file']);
$comp = addslashes($_POST['comp']);
$name = addslashes($_POST['name']);
$test = addslashes($_POST['test']);
$user_entered = addslashes($_POST['user']);
$pass_entered = addslashes($_POST['pass']);

if(($user_entered == 'neonimage') && (md5($pass_entered) == '******')) { //check user and pass
//ok

$myFile = "test2.html"; //name of xml file

$fh = fopen($myFile, 'a') or die("Can't open test2.html"); //open file
//what to write
$stringData .= "<dt>$comp</dt>";
$stringData .= "<dd class=\"date\">- $name</dd> \n";
$stringData .= "<dd class=\"desc\"><img src=\"include/images/icon_quotes_open.gif\" alt=\"\"/> $test <img src=\"include/images/icon_quotes_close.gif\" alt=\"\"/></dd> \n";
fwrite($fh, $stringData);
fclose($fh);

echo "<p>Done.</p>";
}
else {
//user or pass is wrong
echo '<p>User/Pass combination invalid!</p>';
}
}
?>
</html>

And Here is the HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Testimonials | Neonimage.com | Personal portfolio of Ben Silvertown</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="robots" content="noindex, nofollow" />
<link rel="stylesheet" href="include/style.css" />
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
</head>
<body>
<div id="main">
    <div id="headert"></div>

  <div id="nav_bar">
    <ul>
        <li id="port"><a href="index.html" title=""><span>Portfolio</span></a></li>
        <li id="logos"><a href="logos.html" title=""><span>Logos &amp; Identity</span></a></li>
        <li id="web"><a href="web.html" title=""><span>Web Design</span></a></li>
        <li id="print"><a href="print.html" title=""><span>Print Work</span></a></li>
        <li id="test"><a href="test.html" title=""><span>Testimonials</span></a></li>
        <li id="newslst"><a href="news.html" title=""><span>News</span></a></li>
        <li id="contact" class="last"><a href="contact.html" title=""><span>Get in touch</span></a></li>
    </ul>
    <div id="btm"></div>
  </div> <!-- nav_bar -->
<div id="recent">
    <h1>What clients have said:</h1>
      <div class="left_col">
            <dl id="news">

[COLOR="Red"]ADD NEW HTML HERE[/COLOR]

              <dt>Uwant Gadgets</dt>
              <dd class="date">- Annand Savjani</dd>
              <dd class="desc"><img src="include/images/icon_quotes_open.gif" alt=""/>  Ben's work is amazing!  I love the way how he makes everything look great yet it is so simple. Would definately recommend Ben.    <img src="include/images/icon_quotes_close.gif" alt=""/></dd>


              <dt>Floodplain</dt>
              <dd class="date">- Ellie Sargent</dd>
              <dd class="desc">
              <img src="include/images/icon_quotes_open.gif" alt=""/>
              Ben you are a star!!! <img src="include/images/icon_star.gif" alt=""/> It looks great!
              <img src="include/images/icon_quotes_close.gif" alt=""/></dd>

              <dt>Crowdspring Reccomendation</dt>
              <dd class="date">- Sean Harper</dd>
              <dd class="desc">
              <img src="include/images/icon_quotes_open.gif" alt=""/>
              We asked Crowdspring who the best designers for webpages are.  They recommended you.  Can I interest you in taking a look at our project?
              <img src="include/images/icon_quotes_close.gif" alt=""/></dd>
            </dl>
      </div>   <!-- left column -->

      <div class="right_col">
        <div class="img_block seven"></div>
        <br>
        <div class="img_block six"></div>
        <br>
        <div class="img_block five"></div>
        <br>
        <div class="img_block four"></div>
      </div>  <!-- right column -->

<div class="clearing"></div>
</div> <!-- recent -->
<div id="footer"> 
    <ul>
        <li><a href="index.html" title="">Home</a></li>
        <li><a href="logos.html" title="">Logos &amp; Identity</a></li>
        <li><a href="web.html" title="">Web Design</a></li>
        <li><a href="print.html" title="">Print Work</a></li>
        <li><a href="test.html" title="">Testimonials</a></li>
        <li><a href="news.html" title="">News</a></li>
        <li class="last"><a href="contact.html" title="">Get in touch</a></li>
     </ul>
</div>
</div> <!-- main -->
</body>
</html>

Thanks!

    Read the entire file into a variable using [man]file_get_contents/man, use [man]str_replace/man to replace '<dl id="news">' with '<dl id="news">(data you want after it)', then use [man]file_put_contents/man to write the data back to the file.

      bradgrafelman;10903871 wrote:

      Read the entire file into a variable using [man]file_get_contents/man, use [man]str_replace/man to replace '<dl id="news">' with '<dl id="news">(data you want after it)', then use [man]file_put_contents/man to write the data back to the file.

      Thanks for this, but as I explained I'm a really new at PHP and this means nothing to me. Can you show me how to do this?
      Thanks!

        Write a Reply...