Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 1230 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

form to email

Thread title: form to email
Closed Thread    
    Thread tools Search this thread Display Modes  
03-11-2007, 09:59 PM
#1
ali.black is offline ali.black
Status: I'm new around here
Join date: Feb 2007
Location:
Expertise:
Software:
 
Posts: 13
iTrader: 0 / 0%
 

ali.black is on a distinguished road

  Old  form to email

hello guys,
i was just wondering if you could tell me how to do something. i have made a part of my website so that people can contact me. so the fill in a form then click submit and it gets sent to my email address. it all works perfectly but i want to do something else. i want to have tick boxes in the in my form because just now they are all just text feilds.

Here is the php just now for the text fields:
$name=$_POST['name'];
$owner=$_POST['owner'];
$telephone=$_POST['telephone'];
$addressline1=$_POST['addressline1'];
$addressline2=$_POST['addressline2'];
$town=$_POST['town'];
$county=$_POST['county'];
$postcode=$_POST['postcode'];
$info=$_POST['info'];
$to="ali_b71@hotmail.co.uk";
$message="Restraunts Name: $name \n owner: \"$owner\"\n address line 1: $addressline1 \n address line 2: $addressline2 \n Town: $town \n county: $county \n Postcode: $postcode \n About their restraunt: $info";

its very simple becuase this is my first time using it. but wht would the code be for a tick box?

cheers for your help.

Ali

03-11-2007, 10:05 PM
#2
Steven Fergus is offline Steven Fergus
Status: Hey, I'm Steven
Join date: Feb 2007
Location:
Expertise:
Software:
 
Posts: 1,212
iTrader: 3 / 100%
 

Steven Fergus is on a distinguished road

  Old

For the tick boxes, they would go in the html not the php. They would then be included in your PHP so that the information is emailed to you.

How exactly you would do it though, i'm not sure. I know someone will be able to help you though.

03-11-2007, 10:19 PM
#3
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old

can we see full source code?

03-12-2007, 01:43 PM
#4
ali.black is offline ali.black
Status: I'm new around here
Join date: Feb 2007
Location:
Expertise:
Software:
 
Posts: 13
iTrader: 0 / 0%
 

ali.black is on a distinguished road

  Old

here is the form:

<table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<form name="form1" method="post" action="mail2.php">
<tr>
<td height="19" colspan="2" valign="top" nowrap><strong>
<LABEL for="name">Establishments Name</LABEL>
</strong></td>
<td width="6" valign="top">:</td>
<td colspan="4" rowspan="2" valign="top"><input name="name" type="text" id="subject" size="50"></td>
</tr>
<tr>
<td width="147" height="3"></td>
<td width="8"></td>
<td></td>
</tr>
<tr>
<td height="19"></td>
<td></td>
<td></td>
<td width="42"></td>
<td width="26"></td>
<td width="48"></td>
<td width="184"></td>
</tr>
<tr>
<td height="22" colspan="2" valign="top" nowrap>Your Contact Name </td>
<td valign="top">:</td>
<td colspan="4" valign="top"><input name="owner" type="text" id="subject2" size="50"></td>
</tr>

<tr>
<td height="35"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>

<tr>
<td height="22" colspan="2" valign="top" nowrap>Telephone Number </td>
<td valign="top">:</td>
<td colspan="4" valign="top"><input name="telephone" type="text" id="subject3" size="50"></td>
</tr>
<tr>
<td height="19"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>

<tr>
<td height="22" colspan="2" valign="top" nowrap>Address Line 1 </td>
<td valign="top">:</td>
<td colspan="4" valign="top"><input name="addressline1" type="text" id="subject4" size="50"></td>
</tr>
<tr>
<td height="19">&nbsp;</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="22" colspan="2" valign="top" nowrap>Address Line 2 </td>
<td valign="top">:</td>
<td colspan="4" valign="top"><input name="addressline2" type="text" id="subject5" size="50"></td>
</tr>
<tr>
<td height="19">&nbsp;</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="22" colspan="2" valign="top" nowrap>Town/City</td>
<td valign="top">:</td>
<td colspan="4" valign="top"><input name="town" type="text" id="subject6" size="50"></td>
</tr>
<tr>
<td height="19">&nbsp;</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="22" colspan="2" valign="top" nowrap>County</td>
<td valign="top">:</td>
<td colspan="4" valign="top"><input name="county" type="text" id="subject7" size="50"></td>
</tr>
<tr>
<td height="19">&nbsp;</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="22" colspan="2" valign="top" nowrap>Postcode </td>
<td valign="top">:</td>
<td colspan="4" valign="top"><input name="postcode" type="text" id="subject8" size="50"></td>
</tr>
<tr>
<td height="17"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="2" rowspan="2" valign="top" nowrap><p>Information about your<br> establishment<br> i.e. Delivery,<br> special offers etc. </p></td>
<td height="21" valign="top">:</td>
<td colspan="4" rowspan="2" valign="top">

<textarea name="info" cols="47" rows="5" ></textarea> </td>
</tr>
<tr>
<td height="62">&nbsp;</td>
</tr>

<tr>
<td height="22"></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="24"></td>
<td colspan="3" valign="top"><label>
<input type="submit" name="Submit" value="Submit">
</label>
<label></label></td>
<td>&nbsp;</td>
<td valign="top"><input type="reset" name="Submit2" value="Reset"></td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="31"></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</form>
</table>

Here is the php:

<?
$name=$_POST['name'];
$owner=$_POST['owner'];
$telephone=$_POST['telephone'];
$addressline1=$_POST['addressline1'];
$addressline2=$_POST['addressline2'];
$town=$_POST['town'];
$county=$_POST['county'];
$postcode=$_POST['postcode'];
$info=$_POST['info'];
$to="ali_b71@hotmail.co.uk";
$message="Restraunts Name: $name \n owner: \"$owner\"\n address line 1: $addressline1 \n address line 2: $addressline2 \n Town: $town \n county: $county \n Postcode: $postcode \n About their restraunt: $info";
if(mail($to,"restraunt $name",$message,"From: $name\n")) {
echo "Thanks!";
} else { echo "There was a problem sending your comments. Please check that you filled in the form correctly."; }
?>


and i want to put tick boxes in the form.

Cheers

03-12-2007, 05:06 PM
#5
ali.black is offline ali.black
Status: I'm new around here
Join date: Feb 2007
Location:
Expertise:
Software:
 
Posts: 13
iTrader: 0 / 0%
 

ali.black is on a distinguished road

  Old

i know my coding is pretty dire :P im very new to it. basically i want something like this http://everymenu.co.uk/main/add_listing.php (not my site, just an example) i know how to do the text feild but i dont no how to do the tick boxes

03-12-2007, 06:12 PM
#6
Xi0s is offline Xi0s
Status: Sin Binner
Join date: Dec 2006
Location: Huddersfield, UK
Expertise:
Software:
 
Posts: 384
iTrader: 3 / 83%
 

Xi0s is on a distinguished road

Send a message via MSN to Xi0s

  Old

<tr>
<td height="19">&nbsp;</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>

tidy up your coding and replace with:
<tr class="spacer"><td colspan="6"></td></tr>

checkbox xhtml
<input type="checkbox" checked="checked" name="NAME!" />

and as for mail scripts first:

change ur form tag to <form name="email" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

This will make your form post into the same document.

Then at the top add:

<?php
foreach($_POST as $key => $value){
$_POST[$key] = addslashes($value);
}
// tidied up the post and made it formatted .
mail(mail arguments);
?>

visit this page for more info on the mail(); command:

http://uk3.php.net/function.mail

03-14-2007, 07:07 PM
#7
mikeroq is offline mikeroq
mikeroq's Avatar
Status: Member
Join date: Feb 2006
Location: Ponca City, OK
Expertise: xHTML/CSS/PHP/Computer Tech
Software: Photoshop, Notepad++, Winamp
 
Posts: 332
iTrader: 5 / 100%
 

mikeroq is an unknown quantity at this point

Send a message via AIM to mikeroq Send a message via MSN to mikeroq Send a message via Yahoo to mikeroq

  Old

Originally Posted by Xi0s View Post
<form name="email" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
I would use:
Code:
<form name="email" action="#" method="post">
Its simple, short, and works. Of course, thats only if you move the PHP to the same page as the form, which should never been in such a big ugly table.

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed