Page 1 of 1
help with image src
Posted: Fri Feb 04, 2005 6:57 pm
by paqman
Hey
I've created a php email form on my site. The problem is when I send an email with it, a picture which I include has a problem with it's src. Here's what happens:
Code on the form:
Code: Select all
<tr>
<td><a href="javascript:popUp('help.php?type=index&subject=header')">Header:</a></td>
<td><input type="text" size="65" name="header" value="<img src="http://website.com/image/news/header.gif">"></td>
</tr>
That comes out as:
Code: Select all
<img src="http://webiste.com/image/news/header.gif">
That part works exactly as I want it to. The problem is when the form submits using that code for an image, I get the following for the image's src:
Code: Select all
http://website.com/"http://website.com/image/news/header.gif/"
I sort of have an idea of what the problem is, I just don't know how to ask it. How do I get rid of the website base url?
Thanks
Posted: Fri Feb 04, 2005 7:32 pm
by ibizconsultants
Can you paste the code that handles your form submit. Invariably you could also do a var_dump($_POST) before anything else gets displayed or processed to check contents of the variable.
Posted: Sat Feb 05, 2005 12:27 am
by paqman
Form:
Code: Select all
<form name="form" method="post" action="newsletter_send.php">
<table>
<tr>
<td><a href="javascript:popUp('help.php?type=index&subject=from')">From:</a></td>
<td><input type="text" size="30" name="from" value="Newsletter"></td>
</tr>
<tr>
<td><a href="javascript:popUp('help.php?type=index&subject=reply')">Reply Address:</a></td>
<td><input type="text" size="30" name="reply" value="newsletter@website.com"></td>
</tr>
<tr>
<td><a href="javascript:popUp('help.php?type=index&subject=subject')">Subject:</a></td>
<td><input type="text" size="30" name="subject" value="Newsletter #"></td>
</tr>
<tr>
<td colspan=2><hr></td></tr>
<tr>
<td><a href="javascript:popUp('help.php?type=index&subject=header')">Header:</a></td>
<td><input type="text" size="65" name="header" value="<img src="http://website.com/image/news/header.gif">"></td>
</tr>
<tr>
<td><a href="javascript:popUp('help.php?type=index&subject=body')">Body:</a></td>
<td><textarea cols="50" rows="7" name="body"></textarea></td>
</tr>
<tr>
<td><a href="javascript:popUp('help.php?type=index&subject=signature')">Signature:</a></td>
<td><textarea cols="50" rows="4" name="signature">
Website<br>
<a href="http://website.com" target="_blankw">
http://website.com</a><br>
<a href="mailto:newsletter@website.com" target="_blankm">
website@ttstage.com</a>
</textarea></td>
</tr>
<tr><td colspan=2><hr></td></tr>
<tr>
<td><input type="submit" value="Test" name="test_first"></td>
<td><input type="text" size="35" name="test_email" value="Enter Email Address to Send Test To"></td>
</tr>
<tr>
<td><input type="submit" value="Send" name="send_now"></td>
<td></td>
</tr>
</table>
</form>
Here's newsletter_send.php:
*I haven't done send_now yet because I'll just use the same code
Code: Select all
<?
if($_POSTї'test_first'])
{
?>
<html>
<head>
<title>Test a Newsletter</title>
<script language="JavaScript" src="check.js"></script>
</head>
<body>
<?
$_POSTї'from']=$from;
$_POSTї'reply']=$reply;
$_POSTї'subject']=$subject;
$_POSTї'header']=$header;
$_POSTї'body']=$body;
$_POSTї'signature']=$signature;
$_POSTї'test_email']=$test_email;
echo $header;
$headers ="From: ".$from." <".$reply.">\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$email_content="<html>
<head>
<title>".$email_subject."</title>
</head>
<body>
".$header."
<br><br>
".$body."
<br><br>
".$signature."
</html>";
mail($test_email, $subject, $email_content, $headers);
echo "Test email sent to $test_email.";
}
if($_POSTї'send_now'])
{
}
?>
Posted: Sat Feb 05, 2005 7:24 am
by feyd
Code: Select all
$_POSTї'from']=$from;
$_POSTї'reply']=$reply;
$_POSTї'subject']=$subject;
$_POSTї'header']=$header;
$_POSTї'body']=$body;
$_POSTї'signature']=$signature;
$_POSTї'test_email']=$test_email;
these are reverse of what should be. You appear to have register_globals on if the variables work later in the script.
as for the problem, I don't see where it's happening..
Posted: Sat Feb 05, 2005 5:22 pm
by paqman
the reason it's there a second time is for if the user chooses to send the email to everyone on the email list. That's why it's incomplete in the second submit. I see what you mean; it's backwards. I will change that, though it doesn't seem to affect the form at all...
The problem is that for some reason the form automatically adds
http://website.com to the header string. I have no idea why. Does anyone know how to stop it from doing this?