Jump to content


Photo

PHP inside HTML issue


  • Please log in to reply
2 replies to this topic

#1 lyndsey.pearce@ntlworld.com

lyndsey.pearce@ntlworld.com
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 12 April 2006 - 01:40 PM

Hello!

I have a simple HTML form with some PHP inside it:

<p>Upload new image: 
<input type="file" name="image_filename" id="image_filename" 
                           value="<?php echo $row['ImagePath']; ?>" /></p>

All I want to do is display the contents of the field called "ImagePath" which is the path to an image stored on the server.

The user can then click the browse button to change the path if they wish.

I have no errors returned, but the path to the image is not displayed in the input field in the browser.

I have done this for other input fields with a "type" of "text" and it works.

Can anyone tell me what I am doing wrong?


Cheers!

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 12 April 2006 - 02:07 PM

Does "$row['ImagePath']" contain anything at the time the HTML is rendered?

Can you post more of your code that leads up to this statement?

Ken

#3 lyndsey.pearce@ntlworld.com

lyndsey.pearce@ntlworld.com
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 12 April 2006 - 02:49 PM

Hiya!
I have checked field names and everything is correct.

This is some more code here:

<?php

  If (isset ($_SESSION['AdminAccess']))

 {

      $admin_username = $_SESSION['AdminUsername'];


          include ('common_db.php');


          $link_id = db_connect();

     //-----------------------PULL UP PAGE DETAILS-----------------------------------------


                  $selectquery = "SELECT * FROM table WHERE FieldIDNumber = '" . $_GET['id'] . "'";
                  $result = mysql_query($selectquery) or die("Invalid query: " . mysql_error());

                  $row = mysql_fetch_array($result)


  ?>

<p>Last updated:<em><?php echo $row['FieldLastUpdate']; ?></em></p>

<form action="edit.php" method ="post" enctype="multipart/form-data">

<p>Alter name: <input type="text" name="Name" size="25" value=" <?php echo $row['Name']; ?>" /></p>

<p>Alter heading: <input type="text" name="Heading" size="25" value=" <?php echo $row['Heading']; ?>" /></p>

<p>Alter Entry: <textarea name="Body" cols="50" rows="50"><?php echo $row['Body']; ?></textarea></p>

<p>Upload new image: <input type="file" name="image_filename" id="image_filename" value="<?php echo $row['PageImage']; ?>"/></p>

<p>Alter image title: <input type="text" name="ImageTitle" value="<?php echo $row['ImageTitle']; ?>" /></p>

<p>Alter image alt text: <input type="text" name="AltText" value="<?php echo $row['ImageAltText']; ?>" /></p>

<p><input type="submit" value="submit" />

</form>



<?php




}

else

                  {
                   echo "<p>**You are not authorised to access this page!**</p>";
                   echo "<p><a href=\"AdminLogin.html\">login</a></p>";
                   }




?>

What is interesting is when I view the page source for the output I get this:

<h2>Edit details</h2>

<form action="edit.php" method ="post" enctype="multipart/form-data">

<p>Alter name: <input type="text" name="Name" size="25" value=" Sitemap" /></p>

<p>Alter heading: <input type="text" name="Heading" size="25" value=" this is the heading" /></p>

<p>Alter body: <textarea name="Body" cols="50" rows="50">jf fjhjhuy  uy u yu </textarea></p>

<p>Upload new image: <input type="file" name="image_filename" id="image_filename" value="/uploadimages/image.gif"/></p>

<p>Alter image title: <input type="text" name="ImageTitle" value="image is the title" /></p>

<p>Alter image alt text: <input type="text" name="AltText" value="image is the alt text" /></p>

<p><input type="submit" value="submit" />

</form>


The value seems to be pulled out, but the path is not displayed in the browser.

Weird!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users