View Full Version : email script help

10-16-2008, 08:34 PM
Hi all,

I have a script to send an email to a user so they can confirm ownership of their email address.

I have a page that informs that an email has been sent to them but I want to display their email address on that page.

I am redirecting from my submit.php ( script to send email ) and want to add a query string to the redirect URL but cant seem to figure it out. There is no form in submit.php so cant use $_POST so want to use $_GET. How do I add the query string to the redirect url.

I want to add $email to the url.

Here is my code....


$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$address = $_POST['address'];
$town = $_POST['town'];
$county = $_POST['county'];
$country = $_POST['country'];
$postcode = $_POST['postcode'];
$comments = $_POST['comments'];

//--------------------------Set these paramaters--------------------------

$subject = 'Petition Confirmation.'; // Subject of email sent to user.
$emailadd = $email; // Users email address. This is where the form information will be sent.
$from = 'name of sender here or senders email address';
$url = 'confirm2.php?email='; // Where to redirect after form is processed.
$req = '1'; // Makes all fields required. If set to '1' no field can be empty. If set to '0' any or all fields can be empty.

// --------------------------Do not edit below this line--------------------------
$text = "Please use the link below to confirm your email address. :\n\n";
$space = ' ';
$line = '
foreach ($_POST as $key => $value)
if ($req == '1')
if ($value == '')
{echo "$key is empty, please use your back button and complete the form. Thank you.";die;}
$j = strlen($key);
if ($j >= 50)
{echo "Name of form element $key cannot be longer than 50 characters";die;}
$j = 50 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$value}$line";
$text .= $conc;
$space = '';
mail($emailadd, $subject, $text, 'From: '.$from.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';

Thanks all, Paul

10-16-2008, 09:48 PM
what about a session?

mail($emailadd, $subject, $text, 'From: '.$from.'');

$_SESSION['email'] = $emailadd;

echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';

you'll need a session start

10-17-2008, 09:19 AM
Cheers Dj,

Now why didn't I think of that. Used a Session and sorted it all out.

With regards the OOP thing you PM'd about. Had lots cropped up over the last few evenings. I'll PM or MSN you over the w.end or early next week if thats ok with you.

Thanks again mate.