Tell A Friend Script

Here non-phpBB topics can be discussed.
Morris
Member
Member
Posts: 50
Joined: 15 Nov 2006, 13:10

Tell A Friend Script

Postby Morris » 08 Apr 2007, 13:14

Hello!

How do i get an redirect back to the main page in this script after clicking the submit button?

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>
<title>Tell A Friend</title>
</head>
<body>


<form method="post" action="tell_a_friend.php" />

<input name="dinemail" type="text" value="Your Email..." />

<input name="kompisemail" type="text" value="Friends Email..." />

<input name="tipsa" type="submit" value="Submit" />

</form>


<?php

$to = $_POST['friendsemail'];
$from = $_POST['youremail'];
$headers = "From: $from";


$subject = "Page"; // Header in email
$url = "http://www.sportextra.nu"; // Url'to your site
$mess = "text in the email: $url"; // Message

if (isset($_POST['submit'])){


if (trim($to) == "" or trim($from) == "" or trim($to) == "Your Friends Email..." or trim($from) == "Your Email..."){

echo "Both fields must be filled in"; }

else {

mail("$to", "$subject", "$mess", "$headers");

echo "The Link Is Send";

}

}

?>


</body>
</html>

User avatar
igorw
Past Contributor
Past Contributor
Posts: 1967
Joined: 01 Jun 2006, 20:48
Real name: Igor

Postby igorw » 08 Apr 2007, 13:22

After this:

Code: Select all

mail("$to", "$subject", "$mess", "$headers");


Add:

Code: Select all

header('Location: index.php');


index.php being your main script.

Morris
Member
Member
Posts: 50
Joined: 15 Nov 2006, 13:10

Postby Morris » 08 Apr 2007, 13:55

Dosen work, this comes up, Warning: Cannot modify header information - headers already sent
This script should be on the main page, not my forum, but it dosent work any way.

User avatar
igorw
Past Contributor
Past Contributor
Posts: 1967
Joined: 01 Jun 2006, 20:48
Real name: Igor

Postby igorw » 08 Apr 2007, 15:31

Ah i know why.

At the very top add:

Code: Select all

<?php
ob_start();
?>


And at the very end:

Code: Select all

<?php
ob_end_flush();
?>

Morris
Member
Member
Posts: 50
Joined: 15 Nov 2006, 13:10

Postby Morris » 11 Apr 2007, 14:58

Works great, big thank you eviL<3.

User avatar
igorw
Past Contributor
Past Contributor
Posts: 1967
Joined: 01 Jun 2006, 20:48
Real name: Igor

Postby igorw » 11 Apr 2007, 15:12

No problem.

trjonas
New member
New member
Posts: 1
Joined: 25 Sep 2007, 21:58

Re: Tell A Friend Script

Postby trjonas » 25 Sep 2007, 22:01

I also wanted to thank you! Your reply just helped me as well. :D

Tiffany


Return to “General Discussion”

Who is online

Users browsing this forum: CommonCrawl [Bot] and 0 guests