Adding another variable

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
kev1952
-


Joined: 08 Sep 2005
Posts: 105
Location: Townsville Australia

PostPosted: Sun Dec 04, 2005 3:07 pm    Post subject: Adding another variable Reply with quote

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>&nbsp;</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 View user's profile Send private message Send e-mail Visit poster's website
roganty
-


Joined: 08 Jun 2004
Posts: 357
Location: Bristol, UK

PostPosted: Sun Dec 04, 2005 4:22 pm    Post subject: Re: Adding another variable Reply with quote

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>&nbsp;</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 View user's profile Send private message Visit poster's website
kev1952
-


Joined: 08 Sep 2005
Posts: 105
Location: Townsville Australia

PostPosted: Sun Dec 04, 2005 10:44 pm    Post subject: Reply with quote

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 View user's profile Send private message Send e-mail Visit poster's website
Tom Chapman
-


Joined: 09 Jul 2005
Posts: 933
Location: Australia

PostPosted: Mon Dec 05, 2005 3:25 am    Post subject: Reply with quote

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 View user's profile Send private message Visit poster's website MSN Messenger
kev1952
-


Joined: 08 Sep 2005
Posts: 105
Location: Townsville Australia

PostPosted: Mon Dec 05, 2005 5:21 am    Post subject: Reply with quote

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 View user's profile Send private message Send e-mail Visit poster's website
Tom Chapman
-


Joined: 09 Jul 2005
Posts: 933
Location: Australia

PostPosted: Mon Dec 05, 2005 7:21 am    Post subject: Reply with quote

No idea if it works lol

Test it at www.blazzingsun.com
Back to top View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group