/    Sign up×
Community /Pin to ProfileBookmark

How do I get Varibles to hold data after second page loads

Hi all,

I am having a problem with a php script where a contact us page collects visitor info, and they click send, and that takes them to a confirm page and they click send again it will not hold the variables.

at the moment I only have it to show the message but will not hold the message variable.

Here is my code:
This is the confirmation page:

[code=php]
<html>
<head>
<title>
Please confirm the information is correct
</title>

</head>

<body>

<h1>Please confirm this message</h1>
<p><?php

echo “<b>First Name:</b> $fname <br />”;
echo “<b>Surname:</b> $surname<br />”;
echo “<b>Phone:</b> $phone<br />”;
echo “<b>Fax:</b> $fax<br />”;
echo “<b>Email:</b> $email<br />”;
echo “<b>Company Name:</b> $busname<br />”;
echo “<b>Subject:</b> $subject<br />”;
echo “<b>Attention:</b> $attention<br />”;
echo “<b>Message:</b> $message<br />”;
?>
</p>
<form method=”post” action=”correspondence_submited.php”>
<input type=”button” value=”Edit” onclick=”_back”>
<input type=”submit” value=”Send”>
</form>
</body>
</html>
[/code]

and here is the Sending page:

[code=php]<?php

if ($attention==’Manager’) {
//$toaddress = ‘Email address removed’;
$toaddress = ‘Email address removed’;
}
//echo “<b>Attention:</b> <br />”;
/*’Client Name: ‘$fname’ ‘$surname “N”
‘Phone: ‘$phone “N”
‘Fax: ‘$fax “N”
‘Email: ‘$email “N”
‘Company Name: ‘ $busname “N” */

$mailcontent = ‘Clients message: $message’;

mail($toaddress, $subject, $mailcontent);

?>

<html>
<head>
<title>
Message has been sent.

</title>

</head>

<body>

<h1>This message has been sent.</h1>
<?php
echo ‘<b>Attention:</b> ‘.$attention.'<br />’;
echo ‘<b>to address:</b> ‘.$toaddress.'<br />’;

?>
</body>
</html>
[/code]

My website is [url]www.macleaybec.com.au[/url] and click on “Contact Us” in the frame to get the page, and choose manager for attention and enter a subject and something in the message box and click on send.

The other fields have I not added code for them yet.

If you say it is not well designed, that is because I have not finished it yet.

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@kevinmcqueenFeb 10.2005 — there is probarly a better way to do this somehow, but after the first send is pressed, the next page that loads, i would create hidden fields with the same name as the original ones, and values equal to those submitted in the first page, then the next send should get values from those hidden fields....i think
Copy linkTweet thisAlerts:
@smercerauthorFeb 11.2005 — [i]Originally posted by kevinmcqueen [/i]

[B]i would create hidden fields with the same name as the original ones, and values equal to those submitted in the first page, then the next send should get values from those hidden fields....i think [/B][/QUOTE]

Tryed that but it did not work, then gave the hidden fields different names and that did work.

You were half right though.

Thanks for helping.
Copy linkTweet thisAlerts:
@BeachSideFeb 11.2005 — ya it will work all you have to do is insert your php code into the value of the hidden field i.e.
[code=php]
// your first input field
<input name="username" type="text" id="username" />

// Your hidden field
<input name="hiddenusername" type="hidden" id="hiddenusername" value="<?php echo $_POST['username']; ?>" />
[/code]
Copy linkTweet thisAlerts:
@smercerauthorFeb 11.2005 — Thanks Beachside,

I have fixed the send buttons, but now I am having two problems when I click on the edit button using your suggestions.

I have two separtate forms with hidden fields but containing the same data, one for the send button, and one for the edit button.

The problem is when the page is loaded from clicking the edit button, the "Attention" radio buttons are not selected even though I have the code like this:
[code=php]
<input type="radio" name="attention" value="Manager" <?php
if (attention_second=='Manager') { echo 'checked'; } ?>>Manager<br />

<input type="radio" name="attention" value="Aboriginal Enterprise Development Officer" <?php
if (attention_second=='Aboriginal Enterprise Development Officer') { echo 'checked'; } ?>>Aboriginal Enterprise Development Officer<br />
[/code]


Another problem is if you have a appostraphe in the either the origanal message or the edited message, I get / before the appostraphe to escape the '

Could someone please help me here?

Thanks
×

Success!

Help @smercer 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 6.18,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...