View previous topic :: View next topic |
Author |
Message |
kev1952 -
Joined: 08 Sep 2005 Posts: 105 Location: Townsville Australia
|
Posted: Sun Dec 04, 2005 3:07 pm Post subject: Adding another variable |
|
|
This is my first attempt at a PHP script written entirely from scratch. I want to add some more info to my feedback form script. This is the code concerned:
Code: | <form method="POST" action="contact.php">
<p class="c4">Your Name: <input type="text" name="sender_name" size=30></p>
<p class="c4">Your Country: <input type="text" name="sender_loc" size=28></p>
<p class="c4">Your EMail: <input type="text" name="sender_email" size=30><font color=red><b>*</b></font></p>
<p><font color=red><b>* Required if you want a reply.</b></font></p>
<p class="c4">Your Feedback: <br>
<textarea name="message" cols=32 rows=10></textarea>
</p>
<input type="reset">
<input type="submit" value="Submit">
</form> |
and it calls this script:
Code: | <?php
$name = $_POST['sender_name'] ;
$email = $_POST['sender_email'] ;
$loc = $_POST['sender_loc'] ;
$msg = $_POST['message'] ;
$to = "freddo_frog@westnet.com.au" ;
mail($to, "Feedback From Kev's Place", $msg, "From: $email\n");
echo "<p> </p>";
echo "<p><h1 align=center>Thank You, $name</h1></p>";
echo "<p align=center><b>Your feedback is appreciated.</b></p>";
?> |
The above script works perfectly but as you can see the $loc variable is not used currently. I want to add it so that it appears in the body of the email generated. I tried a number of different ways but drew a blank every time. Can someone tell me (or point me in the right direction) how to add it. The variables are being passed from the <form> to the script just fine but will not give me the desired result. The odd thing is that I get no errors but sometimes the script just leaves me with a blank page depending on the method I tried.
I would like the email to read something like:
$name from $loc wrote: $msg
Thanks..... Kev |
|
Back to top |
|
 |
roganty -
Joined: 08 Jun 2004 Posts: 357 Location: Bristol, UK
|
Posted: Sun Dec 04, 2005 4:22 pm Post subject: Re: Adding another variable |
|
|
kev1952 wrote: | The above script works perfectly but as you can see the $loc variable is not used currently. I want to add it so that it appears in the body of the email generated. I tried a number of different ways but drew a blank every time. Can someone tell me (or point me in the right direction) how to add it. The variables are being passed from the <form> to the script just fine but will not give me the desired result. The odd thing is that I get no errors but sometimes the script just leaves me with a blank page depending on the method I tried.
I would like the email to read something like:
$name from $loc wrote: $msg
Thanks..... Kev |
Is this what you mean???
Code: | <?php
$name = $_POST['sender_name'] ;
$email = $_POST['sender_email'] ;
$loc = $_POST['sender_loc'] ;
$msg = $_POST['message'] ;
$to = "freddo_frog@westnet.com.au" ;
$body = "$name from $loc wrote: $msg";
mail($to, "Feedback From Kev's Place", $body, "From: $email\n");
echo "<p> </p>";
echo "<p><h1 align=center>Thank You, $name</h1></p>";
echo "<p align=center><b>Your feedback is appreciated.</b></p>";
?> |
_________________ Anthony R
Roganty | Links-Links.co.uk |
|
Back to top |
|
 |
kev1952 -
Joined: 08 Sep 2005 Posts: 105 Location: Townsville Australia
|
Posted: Sun Dec 04, 2005 10:44 pm Post subject: |
|
|
I knew it was going to be something dead simple. That was exactly what I meant and it worked a treat! Thank you very much........
Cheers.... Kev |
|
Back to top |
|
 |
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
Posted: Mon Dec 05, 2005 3:25 am Post subject: |
|
|
This is a bit embarrasing lol but i'ma .. NOOB! so could someone please help me getting a contact form working on my site thanks |
|
Back to top |
|
 |
kev1952 -
Joined: 08 Sep 2005 Posts: 105 Location: Townsville Australia
|
Posted: Mon Dec 05, 2005 5:21 am Post subject: |
|
|
chappy426 wrote: | This is a bit embarrasing lol but i'ma .. NOOB! so could someone please help me getting a contact form working on my site thanks | Feel free to use my code in post #1 and modify the PHP script as described by "roganty" in post #2. Edit the scripts to work in your site environment and away you go. |
|
Back to top |
|
 |
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
Posted: Mon Dec 05, 2005 7:21 am Post subject: |
|
|
No idea if it works lol
Test it at www.blazzingsun.com |
|
Back to top |
|
 |
|