•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 402,753 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,461 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1902 | Replies: 8
![]() |
•
•
Join Date: Jun 2005
Posts: 10
Reputation:
Rep Power: 4
Solved Threads: 0
I am absolutely 100% new to php programming, so go easy on me.
I have looked at php tutorials on how to create a simple form on a html page and then using a php script, have the contents of the form emailed to me, then it redirect to a "thank you" page. However, the php script i have at the moment is just showing a blank screen when executed.
The php code i am using:
<?php
$name = $_GET['name'] ; $company = $_GET['company'] ; $emailaddress = $_GET['emailaddress'] ; $message = $_GET['message'] ;
mail( "paul@coatesdesign.net", "Website form", $message, $company, $name, "From: $email" ); header( "Location: http://www.coatesdesign.net/thankyou.htm" );
?>
and the form code i am using on the html page:
<form action="form.php" method="post" name="form" id="form">
Name : <input name="name" type="text" id="name" size="25">
Company: <input name="company" type="text" id="company" size="30">
Email Address: <input name="emailaddress" type="text" id="emailaddress" size="50">
<textarea name="message" cols="80" rows="6" id="message"></textarea>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Clear">
</form>
The page i have it on is here
thank you very much for you help in advance.
Paul.
I have looked at php tutorials on how to create a simple form on a html page and then using a php script, have the contents of the form emailed to me, then it redirect to a "thank you" page. However, the php script i have at the moment is just showing a blank screen when executed.
The php code i am using:
<?php
$name = $_GET['name'] ; $company = $_GET['company'] ; $emailaddress = $_GET['emailaddress'] ; $message = $_GET['message'] ;
mail( "paul@coatesdesign.net", "Website form", $message, $company, $name, "From: $email" ); header( "Location: http://www.coatesdesign.net/thankyou.htm" );
?>
and the form code i am using on the html page:
<form action="form.php" method="post" name="form" id="form">
Name : <input name="name" type="text" id="name" size="25">
Company: <input name="company" type="text" id="company" size="30">
Email Address: <input name="emailaddress" type="text" id="emailaddress" size="50">
<textarea name="message" cols="80" rows="6" id="message"></textarea>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Clear">
</form>
The page i have it on is here
thank you very much for you help in advance.
Paul.
Hello vismund!
The problem is that you are not using the mail() function the right way... it is just a couple of details (check the manual ):
mail functions uses 4 parameters only. Everything goes right until the end of mail( "paul@coatesdesign.net", "Website form", $message ... the 4th parameter should be the headers. You will need to enter the company and other data inside your $message variable. If you remove everything that follows , $message you can see it work... like this:
mail( "paul@coatesdesign.net", "Website form", $message); header( "Location: http://www.coatesdesign.net/thankyou.htm" );
Try this to solve the problem:
[php]
<?php
$name = $_GET['name'] ; $company = $_GET['company'] ; $emailaddress = $_GET['emailaddress'] ; $message = $_GET['message'] ;
mail( "paul@coatesdesign.net", "Website form", $message.$company. $name. "From: $email" ); header( "Location: http://www.coatesdesign.net/thankyou.htm" );
?>
[/php]
The problem is that you are not using the mail() function the right way... it is just a couple of details (check the manual ):
mail functions uses 4 parameters only. Everything goes right until the end of mail( "paul@coatesdesign.net", "Website form", $message ... the 4th parameter should be the headers. You will need to enter the company and other data inside your $message variable. If you remove everything that follows , $message you can see it work... like this:
mail( "paul@coatesdesign.net", "Website form", $message); header( "Location: http://www.coatesdesign.net/thankyou.htm" );
Try this to solve the problem:
[php]
<?php
$name = $_GET['name'] ; $company = $_GET['company'] ; $emailaddress = $_GET['emailaddress'] ; $message = $_GET['message'] ;
mail( "paul@coatesdesign.net", "Website form", $message.$company. $name. "From: $email" ); header( "Location: http://www.coatesdesign.net/thankyou.htm" );
?>
[/php]
LOTRO Tips - Lord of the Rings Online Tips & Tricks
•
•
Join Date: Apr 2005
Location: Auckland, New Zealand
Posts: 136
Reputation:
Rep Power: 4
Solved Threads: 1
try
$message = "$message\n\n$company\n$name";
for some formatting where \n gives you a new line.
When you're feeling like experimenting take a look at http://phpmailer.sourceforge.net and try some html emails.
Sarah
$message = "$message\n\n$company\n$name";
for some formatting where \n gives you a new line.
When you're feeling like experimenting take a look at http://phpmailer.sourceforge.net and try some html emails.
Sarah
•
•
Join Date: Jun 2005
Posts: 10
Reputation:
Rep Power: 4
Solved Threads: 0
Thank you both very much for your help.
Although, i'm still finding out that it isnt working and it still shows a blank page while on www.coatesdesign.net/form.php
heres the code i have now:
[PHP]<?php
$name = $_REQUEST['name'] ; $company = $_REQUEST['company'] ; $emailaddress = $_REQUEST['emailaddress'] ; $message = "$_REQUEST['message']\n\n$company\n$name" ;
mail( "deathonthestairs@hotmail.com", "Website form", $message, "From:
$email" ); header( "Location: http://www.coatesdesign.net/thankyou.htm" );
?>[/PHP]
Is there anything i am doing wrong?
Although, i'm still finding out that it isnt working and it still shows a blank page while on www.coatesdesign.net/form.php
heres the code i have now:
[PHP]<?php
$name = $_REQUEST['name'] ; $company = $_REQUEST['company'] ; $emailaddress = $_REQUEST['emailaddress'] ; $message = "$_REQUEST['message']\n\n$company\n$name" ;
mail( "deathonthestairs@hotmail.com", "Website form", $message, "From:
$email" ); header( "Location: http://www.coatesdesign.net/thankyou.htm" );
?>[/PHP]
Is there anything i am doing wrong?
•
•
Join Date: Jun 2005
Posts: 10
Reputation:
Rep Power: 4
Solved Threads: 0
Ive got the email mailing to my email address now.
Although it just emails a blank email, with the header "Website form", doesnt say who sent it, even though i filled in the email address box. Also the "header" code doesnt redirect to that page.
heres the code im using:
[php]<?php
$name = $_GET['name'] ;
$company = $_GET['company'] ;
$emailaddress = $_GET['emailaddress'] ;
$message = $_GET['message'] ;
$message = "$message\n\n$company\n$name";
mail( "paul@coatesdesign.net", "Website form", $message, "From: $emailaddress" );
header( "Location: http://www.coatesdesign.net/thankyou.htm" );
?>[/php]
The error i get on the php page is:
Warning: Cannot modify header information - headers already sent by (output started at /home/coatesd/public_html/form.php:4) in /home/coatesd/public_html/form.php on line 13
Although it just emails a blank email, with the header "Website form", doesnt say who sent it, even though i filled in the email address box. Also the "header" code doesnt redirect to that page.
heres the code im using:
[php]<?php
$name = $_GET['name'] ;
$company = $_GET['company'] ;
$emailaddress = $_GET['emailaddress'] ;
$message = $_GET['message'] ;
$message = "$message\n\n$company\n$name";
mail( "paul@coatesdesign.net", "Website form", $message, "From: $emailaddress" );
header( "Location: http://www.coatesdesign.net/thankyou.htm" );
?>[/php]
The error i get on the php page is:
Warning: Cannot modify header information - headers already sent by (output started at /home/coatesd/public_html/form.php:4) in /home/coatesd/public_html/form.php on line 13
•
•
Join Date: Apr 2005
Location: Auckland, New Zealand
Posts: 136
Reputation:
Rep Power: 4
Solved Threads: 1
Somewhere at the top of the page you have a space, maybe a blank line before your <?php
Something like that. Effectively it's starting your page, get rid of it, you can't have anything before the <?php if you want to use header() in your script.
Try putting an exit; afterwards as well.
Sarah
Something like that. Effectively it's starting your page, get rid of it, you can't have anything before the <?php if you want to use header() in your script.
Try putting an exit; afterwards as well.
Sarah
•
•
Join Date: Jan 2005
Location: Sheffield, UK
Posts: 294
Reputation:
Rep Power: 4
Solved Threads: 6
Replace php
[PHP]header( "Location: http://www.coatesdesign.net/thankyou.htm" );[/PHP]
with javascript
[PHP]?>
<script>
<!--
window.location= "http://www.coatesdesign.net/thankyou.htm"
//-->
</script>
<?php[/PHP]
[PHP]header( "Location: http://www.coatesdesign.net/thankyou.htm" );[/PHP]
with javascript
[PHP]?>
<script>
<!--
window.location= "http://www.coatesdesign.net/thankyou.htm"
//-->
</script>
<?php[/PHP]
Ecommerce-Web-Store.com Building Your e-Business.
•
•
Join Date: Jun 2005
Posts: 10
Reputation:
Rep Power: 4
Solved Threads: 0
Thank you all very very much!!
I have it working now, with it redirecting to the thanks page using javascript.
for reference, heres my code:
[PHP]
<?
$name = $_REQUEST['name'] ;
$company = $_REQUEST['company'] ;
$emailaddress = $_REQUEST['emailaddress'] ;
$message = $_REQUEST['message'] ;
$message = "$message\n\n$company\n$name";
mail( "paul@coatesdesign.net", "Website form", $message, "From: $emailaddress" );
?>
<script>
<!--
window.location= "http://www.coatesdesign.net/thankyou.htm"
//-->
</script>
<?php
exit;?>[/PHP]
thanks again
I have it working now, with it redirecting to the thanks page using javascript.
for reference, heres my code:
[PHP]
<?
$name = $_REQUEST['name'] ;
$company = $_REQUEST['company'] ;
$emailaddress = $_REQUEST['emailaddress'] ;
$message = $_REQUEST['message'] ;
$message = "$message\n\n$company\n$name";
mail( "paul@coatesdesign.net", "Website form", $message, "From: $emailaddress" );
?>
<script>
<!--
window.location= "http://www.coatesdesign.net/thankyou.htm"
//-->
</script>
<?php
exit;?>[/PHP]
thanks again
•
•
Join Date: Jan 2005
Location: Sheffield, UK
Posts: 294
Reputation:
Rep Power: 4
Solved Threads: 6
well done!!
Just a remark: Never use header after any other php script is called.
Just a remark: Never use header after any other php script is called.
Ecommerce-Web-Store.com Building Your e-Business.
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
Other Threads in the PHP Forum
- Previous Thread: New to php - HELP!
- Next Thread: Please help with email form script


Linear Mode