Click to See Complete Forum and Search --> : How do I get Varibles to hold data after second page loads


smercer
02-10-2005, 05:24 PM
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:

<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>


and here is the Sending page:
<?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>


My website is www.macleaybec.com.au 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.

kevinmcqueen
02-10-2005, 05:32 PM
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

smercer
02-10-2005, 08:57 PM
Originally posted by kevinmcqueen
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
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.

BeachSide
02-11-2005, 06:31 AM
ya it will work all you have to do is insert your php code into the value of the hidden field i.e.

// 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']; ?>" />

smercer
02-11-2005, 06:56 AM
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:

<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 />


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