Mailform

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
blomman
Forum Newbie
Posts: 5
Joined: Wed May 22, 2002 8:10 am

Mailform

Post by blomman »

Hi im new on this forum, i have a problem with a mailform, onsubmit it sends the mail, but dosent return the new php-page....
Anyone please!

This is my code:

<?$to_email="michael.blomberg@automotorsport.se";
$subject="Intresserad av en bil";
$message="Hej jag heter $namn\nJag ar intresserad av en bil som du har ilager\nDu kan ringa mig pa telefonnummer:$tel\neller skicka ett mail till $dinmail\n";
mail($to_email,$subject,$message);
header("Location: tackar.php");------But this dosent work!!
exit;?>

Im getting this in the browser window:

Warning: Cannot add header information - headers already sent by (output started at /home/httpd/html/linden/mail.php:2) in /home/httpd/html/linden/mail.php on line 2
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post by mydimension »

the header function dosen't work with relative url's. try using this:

Code: Select all

Header("Location: http://" . $_SERVER['HTTP_HOST'] . "/takar.php");
edit
-----
do not include the color stuff in the middle theren dosen't work with relative url's. try using this:

Code: Select all

Header("Location: http://" . $_SERVER&#1111;'HTTP_HOST'] . "/takn dosen't work with relative url's. try using this:

Code: Select all

Header("Location: http://" . $_SERVER['HTTP_HOST'n dosen't work with relative url's. try using this:

Code: Select all

Header("Location: http://" . $_SERVER&#1111;'HTTP_HOST'] . "/takar.php");
[/php:1:fe889e9n dosen't work with relative url's. try using this:

Code: Select all

Header("Location: http://" . $_SERVER&#1111;'HTTP_HOST'] . "/takar.php");
[/n dosen't work with relative url's. try using this:

Code: Select all

Header("Location: http://" . $_SERVER&#1111;'HTTP_HOST'] . "/takar.php");
edit
-----
dl's. try using this:

Code: Select all

Header("Location: http://" . $_SERVER['HTTP_HOST'] . "/takar.php");
edit
-----
do not include the color stuff in the mi http://" . $_SERVER['HTTP_HOST'] . "/takar.php");
[/php:1:fe889e9e2n dosen't work with relative url's. try using this:

Code: Select all

Header("Location: http://" . $_SERVER&#1111;'HTTP_HOST'] . "/takar.php");
n dosen't work with relative url's. try using this:

Code: Select all

Header("Location: http://" . $_SERVER['HTTP_HOST'] . "/tn dosen't work with relative url's. try using this:

Code: Select all

Header("Location: http://" . $_SERVER['HTTP_HOST'] . "/takar.php");
edit
-----
do not include the color stuff in the middle therer stuff in the middle thererl's. try using this:

Code: Select all

Header("Location: http://" . $_SERVER['HTTP_HOST'] . "/takar.php");
edit
-----
do not include the color stuff in the middle thereHeader("Location: http://" . $_SERVER['HTTP_HOST'] . "/takar.php");


edit
-----
do not include the color stuff in the middle there
blomman
Forum Newbie
Posts: 5
Joined: Wed May 22, 2002 8:10 am

Post by blomman »

Thanks for your time....But now im getting this:

Parse error: parse error in /home/httpd/html/linden/mail.php on line 3
User avatar
cwcollins
Forum Commoner
Posts: 79
Joined: Thu May 16, 2002 3:51 pm
Location: Milwaukee, WI, USA

Post by cwcollins »

correction...



Header("Location: http://". $_SERVER['HTTP_HOST'] . "/takar.php");
blomman
Forum Newbie
Posts: 5
Joined: Wed May 22, 2002 8:10 am

Post by blomman »

Thanks again you guys are to kind......This is my code:



<?$to_email="michael.blomberg@automotorsport.se";
$subject="Intresserad av en bil";
$message="Hej jag heter $namn\nJag ar intresserad av en bil som du har ilager\nDu kan ringa mig pa telefonnummer:$tel\neller skicka ett mail till $dinmail\n";
mail($to_email,$subject,$message);
Header("Location: http://". $_SERVER['HTTP_HOST'] . "/tackar.php");
exit;?>

And now im getting this again:

Warning: Cannot add header information - headers already sent by (output started at /home/httpd/html/linden/mail.php:2) in /home/httpd/html/linden/mail.php on line 2
User avatar
cwcollins
Forum Commoner
Posts: 79
Joined: Thu May 16, 2002 3:51 pm
Location: Milwaukee, WI, USA

Post by cwcollins »

make sure you don't have any empry lines before the <?.
blomman
Forum Newbie
Posts: 5
Joined: Wed May 22, 2002 8:10 am

Post by blomman »

Hi again!
Whitespace was the major problem, but now the url is not found....

Header("Location: http://". $_SERVER['HTTP_HOST'] . "/takar.php");

Mail.php and takar.php is both in the root of the server, strange why it cant find the url??
Anyone?
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

Change the URL back to what you had originally.

header("Location: tackar.php");

That is the way I do header stuff and never had any problem.

Mike
Last edited by mikeq on Thu May 23, 2002 3:25 am, edited 1 time in total.
blomman
Forum Newbie
Posts: 5
Joined: Wed May 22, 2002 8:10 am

Post by blomman »

Thanks man!
No it works fine.....
Post Reply