Jump to content

Output image


Ashoar

Recommended Posts

I have a small area where users can add an image tags for their signature images:

e.g: <img src="image url here">

This is done through a forum, you can add whatever you want, text, links or images.

 

There is one problem. When i add an image into this form to test it, when i echo it after fetching it from the database it does not show up, instead it just has the liee broken image icon.

 

What happens is that the code adds my website address to the beginning of the code and then the img tag does not work.

 

Here is the code to add the image:

<?php
session_start();
if($_SESSION['s_logged_n'] == 'true'){
$username = $_SESSION['s_username'];

include 'config.php';

if(isset($_POST['submit']))
{

$sig = addslashes(trim($_POST['sig']));
    $addsig="Update Users set signature='$signature' WHERE Username=$username";
}

?>
<html>
<head>
<title>Change your signature</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body>

<div id="wrapper">

<div id="head">Signature</div>
<br>
<div id="main"> 
  <p>Change your signature</p>
  <form action="<?= $_SERVER['PHP_SELF'] ?>" method="post">
  <table width="100%"  border="0" cellpadding="0" cellspacing="0">
	<tr class="firstRow">
	  <td width="50%">Signature</td>
	  <td width="50%"><input name="sig" type="text" class="textBox" id="sig"></td>
	</tr>
	<tr class="firstRow">
	  <td>Submit</td>
	  <td><input name="submit" type="submit" class="textBox" value="Submit"></td>
	</tr>
  </table>
  </form>
  </div>

</div>

</body>
</html>

<? } mysql_close($l); ?>

 

And i use this to fetch and output:

$postcount="SELECT * from Users where Username='$username'";
$postcount2=mysql_query($postcount) or die("Could not get postcount");

$postcount3=mysql_fetch_array($postcount2);

 

The output is then just added as an echo or a print.

e.g: $postcount3[signature]

 

If it is just text, this works just fine, but it won't work for images.

Any solution?

Link to comment
https://forums.phpfreaks.com/topic/153469-output-image/
Share on other sites

Im sure you would of noticed that mywebsite.com is just a dummy domain in the script i added.

My proper domain is being added to the front of the image URL and the <img> tags don't work.

 

I wanted to know if there was a way of stopping the web url being added to the front of the image.

Link to comment
https://forums.phpfreaks.com/topic/153469-output-image/#findComment-806310
Share on other sites

No i am actually fetching it straight from the database, seeing as the image tags are already on the image when they are entered into the input field.

"$postcount3[signature]"

 

I couldn't do it like that as if a user wanted to use text instead of an image that would put img tags around their text.

Link to comment
https://forums.phpfreaks.com/topic/153469-output-image/#findComment-806335
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.