/    Sign up×
Community /Pin to ProfileBookmark

textarea; preview, variable failure; using <a href="">

I am working on a simple newsletter/emailer
which will send from the email database.

Using <a href””> the textarea, when submitted, the
texarea variable fails, and the <a href> link is lost.

I cannot find a problem, am I missing something?
Here is the code:

[code=php]<?php

// ////////////////////////////// send message test ///////////////////
// ///////////////////////////////////////////////////////////////

if($_POST[send_message] == 1){ // form first

// code removed

}else{ // from if post send_message = 1;

// /////////////////////////////// end send message test //////////////////
// ///////////////////////////////////////////////////////////////////

// ////////////////////// edit contents /////////////////////////////
// //////////////////////////////////////////////////////////////////

if($_POST[edit_contents] == 1){ // edit contents
// retrieve form variables
$subject = $_POST[subject];
$reply_to = $_POST[reply_to];
$from = $_POST[from];
$date = $_POST[date];
$message = $_POST[message];
?>

<html>

<body>
edit contents<br>

<form method=”post” action=”<?php $_SERVER[PHP_SELF]; ?>”>

<input type=”text” name=”subject” value=”<?php echo $subject;?>” onclick=”this.select()”><br>
<input type=”text” name=”reply_to” value=”reply_to” onclick=”this.select()”><br>
<input type=”text” name=”from” value=”<?php echo $from;?>” onclick=”this.select()”><br>

<!– textarea –>
<textarea name=”message” rows=”20″ cols=”75″>
<?php echo $message; ?>
</textarea><br>

<input type=”hidden” name=”form_initialized” value=”1″>
<input type=”hidden” name=”preview” value=”1″>
<input type=”submit” value=”Preview”>

</form>

</body></html>

<?php
}else{ // if edit_contents =1

// ///////////////////// preview ////////////////////////////////////
// //////////////////////////////////////////////////////////////////

if($_POST[preview] == 1){ // display preview
// retrieve form variables
$subject = $_POST[subject];
$reply_to = $_POST[reply_to];
$from = $_POST[from];
$date = $_POST[date];
$message = $_POST[message];
?>

<html>
<body>
preview contents<br>
<table>
<tr><td><?php echo $date;?> </td></tr>
<tr><td><?php echo $subject;?> </td></tr>
<tr><td><?php echo $from;?> </td></tr>

<tr><td><?php echo $message;?> </td></tr>
</table>

<!– //////////////////// begin edit contents button //////////////// –>
<form method=”post” action=”<?php $_SERVER[PHP_SELF]; ?>”>
<input type=”hidden” name=”edit_contents” value=”1″>
<input type=”hidden” name=”date” value=”<?php echo $date; ?>”>
<input type=”hidden” name=”subject” value=”<?php echo $subject; ?>”>
<input type=”hidden” name=”from” value=”<?php echo $from; ?>”>
<input type=”hidden” name=”message” value=”<?php echo $message; ?>”>
<input type=”submit” value=”Edit Contents”>
</form>
<!– //////////////////// end edit contents button ////////////////// –>

</body>
</html>

<?php
} // from if post preview =1

// ///////////////////////////// end preview /////////////////////
// ///////////////////////////////////////////////////////////////

?>

<?php // do not show form once filled
if($_POST[form_initialized] != 1)
{ ?>

<html>

<body onLoad=”document.thevariables.subject.focus()”>

<!– /////////////////// initial form ///////////////////////// –>
<!– /////////////////////////////////////////////////////////// –>
initial form<br>

<form name=”thevariables” method=”post” action=”<?php $_SERVER[PHP_SELF]; ?>”>
<!– msg , recipient , subject , reply_to , from , date –>

<input type=”text” name=”subject” value=”subject” onfocus=”this.select()”><br>
<input type=”text” name=”reply_to” value=”reply_to” onclick=”this.select()”><br>
<input type=”text” name=”from” value=”from” onclick=”this.select()”><br>

<!– textarea –>
<textarea name=”message” rows=”20″ cols=”75″>
<html>
<a href=”http://www.epourania.com/mailScripts/emailblast/form_test01.php”>form test</a>
</html>
</textarea><br>

<input type=”hidden” name=”form_initialized” value=”1″>
<input type=”hidden” name=”preview” value=”1″>
<input type=”submit” value=”Preview”>

</form>

<!– //////////////// end initial form /////////// –>
<!– ///////////////////////////////////////////// –>

</body>
</html>

<?php
} // end if form_initialize !=1;
} // from else if edit_contents =1;
} // from else if send_message_test =1;
?>

<html><body>
<a href=”form_test01.php”>refresh</a>
</body></html>[/code]

During preview it will display:
[ATTACH]14760[/ATTACH]

and the $message variable fails.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@holyhttpApr 19.2012 — <!-- /////////////////// initial form ///////////////////////// -->

<!-- /////////////////////////////////////////////////////////// -->

initial form<br>

<form name="thevariables" method="post" action="<?php $_SERVER[PHP_SELF]; ?>">

<!-- msg , recipient , subject , reply_to , from , date -->

<input type="text" name="subject" value="subject" onfocus="this.select()"><br>

<input type="text" name="reply_to" value="reply_to" onclick="this.select()"><br>

<input type="text" name="from" value="from" onclick="this.select()"><br>

<!-- textarea -->

<textarea name="message" rows="20" cols="75">

<a href="http://www.epourania.com/mailScripts/emailblast/form_test01.php">form test</a>

</textarea><br>

<input type="hidden" name="form_initialized" value="1">

<input type="hidden" name="preview" value="1">

<input type="submit" value="Preview">

</form>
Copy linkTweet thisAlerts:
@anothenauthorApr 20.2012 — Thanks Holy http;

I spent an hour trying to figure out

what was different. ** duhhh **

However, I'm really trying to make

an HTML page and save it into the

variable "$message". I then wanted

to preview it before it was sent

to mail().

I noticed at the PHP documentation:

[URL="http://php.net/manual/en/function.mail.php"]http://php.net/manual/en/function.mail.php

[/URL]
(for HTML see example#4)

(see also: http://pear.php.net/package/Mail_Mime )

I can send mail using HTML, however, I

need a way to edit before it is sent.

I tried to read through the PEAR documentation

and I just got lost.

Currently, the only way I can edit is

to save my HTML page as a text, copy

and paste it into the textarea and send

it mail(); then make changes as needed.

The next thing I'll try is to use "include("html.txt");"

somehow.

...

y'know, I think my trouble may be in not

using escape "" for my quotes, but I'll

check on that later, I'm in a rush to get

this one finished.
×

Success!

Help @anothen spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...