Forum Home
Press F1
 
Thread ID: 98635 2009-04-01 03:42:00 Form Sending PHP csinclair83 (200) Press F1
Post ID Timestamp Content User
761469 2009-04-01 07:13:00 how can i edit to remove addy?

You can't edit posts outside the default 15 minute window - if you need to have something like this fixed, just let one of the mods know and we'll sort it out for you. I've replaced the email address in the above posts with a fake one, so hopefully you won't get too much spam as a result.
Chilling_Silence (9)
761470 2009-04-01 07:59:00 Ok now I'm annoyed! I went back and changed it to radio, and changed the PHP to match - and now I'm not even getting the emails :S

Am i even using the easiest program to make forms and have them email with uploaded image to me?
csinclair83 (200)
761471 2009-04-01 10:07:00 Can you paste here the exact code you're using for both the web page and the PHP script? I'll take a look and see if I can find where you're going wrong. Erayd (23)
761472 2009-04-02 08:08:00 Is it possible for me to email it to you? as its quite long for this.... csinclair83 (200)
761473 2009-04-02 09:10:00 Yes, but I'd prefer you pasted it here - that way others can also see it and help / learn from it. If it's long, put it inside [code] [/code] tags; that way it won't use up half a page (it renders inside a little scrolling window). Erayd (23)
761474 2009-04-02 10:23:00 Here is a free script that I can give the thumbs up for. :thumbs:
http://formtoemail.com/

Just make you form with HTML and post it to the php file, all done in minutes.
Rob99 (151)
761475 2009-04-03 01:58:00 I'm on the verge of giving up and getting a pro to do it - have been quoted $250 for a professional CMS website to my requirements . . . . but lets see what we can do here . . .

But here is the code for HTML and PHP . . .


<html>

<head>
<meta http-equiv= " Content-Language " content= " en-nz " >
<meta http-equiv= " Content-Type " content= " text/html; charset=windows-1252 " >
<title>Coffee Mug Order Form</title>
</head>

<body>
<form enctype= " multipart/form-data " >
<p align= " center " >
<img border= " 0 " src= " images/Oceanside%20Graphics%20Logo . jpg " width= " 283 " height= " 216 " ></p>
<form action= " simplescript . php " method= " post " >
<p align= " center " ><u><b><font size= " 4 " >Order Form for your Personalised
Coffee Mug</font></b></u></p>

<p align= " center " ><b><font size= " 4 " >$25 . 00 Including <br>
1x Photo, a message 50letters(or less) <br>
Postage anywhere NZ wide - Standard Post <br>
</font><font size= " 2 " > <br>
</font>For orders of more than 1 that is exactly the same, please write in
Notes <br>
and add $15 each extra mug onto the price of $25(an saving of $10 . 00 each
for 2nd Mug onward) <br>
<br>
If you prefer an personalised quote,
please fill in this form <br>
and I will respond within 4 hours, if sent between 8am and 5pm Monday to
Friday New Zealand Time <br>
<br>
Payment Options are at end of this order form . <br>
<br>
<u>Please select your Mug Colour (Click on colour for Image of Mug)</u> <br>
<input type= " radio " value= " WhiteInside " checked name= " MugColour " ></b>WHITE COFFEE MUG <br>
<input type= " radio " name= " MugColour " value= " BlackInside " >BLACK INSIDE COFFEE MUG <br>
<input type= " radio " name= " MugColour " value= " BlueInside " >BLUE INSIDE COFFEE MUG <br>
<input type= " radio " name= " MugColour " value= " MaroonInside " >MAROON INSIDE COFFEE MUG <br>
<input type= " radio " name= " MugColour " value= " YellowInside " >YELLOW INSIDE COFFEE MUG <br>
<input type= " radio " name= " MugColour " value= " GreenInside " >GREEN INSIDE COFFEE MUG <br>
<br>
<b><u>Upload an Photo for your Mug <br>
</u></b>To add your own personal photo please upload <br>
-click browse and attach file to this order, it will be sent to me when you
submit order at completion~</p>
<p align= " center " ><input type= " file " name= " FirstPhoto " size= " 20 " > <br>
<br>
Use this one for Additional Photos - Extra $5 . 00 <br>
<input type= " file " name= " ExtraPhoto " size= " 20 " > <br>
<br>

<b><u>An Message to go on your Mug</u></b> <br>
Do you want text on your Mug as well? <br>
<script language = " Javascript " >
maxL=50;
var bName = navigator . appName;
function taLimit(taObj) {
if (taObj . value . length==maxL) return false;
return true;
}

function taCount(taObj,Cnt) {
objCnt=createObject(Cnt);
objVal=taObj . value;
if (objVal . length>maxL) objVal=objVal . substring(0,maxL);
if (objCnt) {
if(bName == " Netscape " ){
objCnt . textContent=maxL-objVal . length;}
else{objCnt . innerText=maxL-objVal . length;}
}
return true;
}
function createObject(objId) {
if (document . getElementById) return document . getElementById(objId);
else if (document . layers) return eval( " document . " + objId);
else if (document . all) return eval( " document . all . " + objId);
else return eval( " document . " + objId);
}
</script>
<font>
<textarea onKeyPress= " return taLimit(this) " onKeyUp= " return taCount(this,'myCounter') " name= " TextonMug " rows=4 wrap= " physical " cols=40>
</textarea>
<br> You have <B><SPAN id=myCounter>50</SPAN></B> characters remaining
for your Order</font><p align= " center " >Additional Text Enter here - Please add
15c per letter and symbols, not including spaces . <br>

<textarea rows= " 2 " name= " ExtraText " cols= " 32 " ></textarea><p align= " center " >
<br>
<u><b>Additional Information</b></u> <br>
What Colour Text would you like <br>
<select size= " 1 " name= " TextColour " >
<option value= " Red " >Red</option>
<option value= " Black " >Black</option>
<option value= " Blue " >Blue</option>
<option value= " Pink " >Pink</option>
<option value= " Orange " >Orange</option>
<option value= " Purple " >Purple</option>
<option value= " Green " >Green</option>
<option value= " Yellow " >Yellow</option>
<option value= " Other - Please Specify " >Other - Please Specify</option>

</select> <br>
<input type= " text " name= " OtherColour " size= " 20 " > <br>
<font size= " 2 " >Note that sometimes your text colour choice <br>
might require to be changed <br>
depending on background . <br>
(You will be contacted first if this occurs) <br>
<br>

<br>
</font>Any Notes to go with this order? <br>
<textarea rows= " 2 " name= " ExtraInfo " cols= " 20 " ></textarea> <br>
<font size= " 2 " > <br>
<br>
<br>
</font><b><span style= " background-color: #FFFF00 " >Personal Details</span></b> <br>

Name:&nbsp;&nbsp; <input type= " text " name= " Name " size= " 32 " > <br>
<br>
Address&nbsp;&nbsp; : <textarea rows= " 2 " name= " Address " cols= " 26 " ></textarea> <br>
<br>
Phone Number&nbsp;&nbsp; <input type= " text " name= " Phone " size= " 20 " > <br>

<br>
Email Address&nbsp;&nbsp; <input type= " text " name= " Email " size= " 20 " > <br>
<br>
<br>
</p>
<div align= " center " >
<p>
<a onClick= " self . name = 'parent'; " target= " _blank " href= " . paymate . com/PayMate/ExpressPayment?mid=csinclair83 " ><img" target="_blank">www . paymate . com src= " . paymate . com/images/ebay/paymateexpmastervisa_88x31 . gif " " target="_blank">www . paymate . com border= " 0 " alt= " Pay with Paymate Express " ></a>

<br>
<font size= " 2 " >Click for Credit Card Payment - No Registration
Require</font>d <br>
<i>Amount to pay is $25 . 00 unless you added more text &amp; photo <br>
<b>IMPORTANT - Your Bank Account will show Payment as &quot;Paymate&quot;</b></i> <br>
<br> <a href= " AccountDetails . html " >If paying by Internet Banking - Click
here for Account Details</a> <br> &nbsp;</p>

</div>
<p align= " center " ><input name= " Submit " type= " submit " >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input name= " Reset " type= " reset " >
</form>
<p align= " center " >&nbsp;</p>

</body>

</html>


PHP


<?php
// Step 1
$subject = " Order Form " ;
$name = $_POST['Name'];
$email = $_POST['Email'];
$address = $_POST['Address'];
$phone = $_POST['Phone'];
$coffee = $_POST['MugColour'];
$mugtxt = $_POST['TextonMug'];
$colortxt = $_POST['Colour'];
$colortxt = $_POST['OtherColour'];
$othertxt = $_POST['ExtraText'];
$extrainfo = $_POST['ExtraInfo'];

$to = " nobody@example . com " ; // The e-mail address you want the message sent to

// Step 2
$header = " From: " . $name . " < " . $email . " > " ;
$message = " Name: $name \r
Address: $address \r
Phone: $phone \r
EMAIL: $email \r
Coffee Mug: $coffee \r
Coffee Mug Text: $mugtxt \r
Color Text: $colortxt \r
Additional Text: $othertxt \r
Additional Info: $extrainfo \r " ;

// Step 3
mail($to, $subject, $message, $header);

// Step 4
header( " Location: . oceansidegraphics . co . nz/thankyou . htm " " target="_blank">www . oceansidegraphics . co . nz);
?><head><title>Script to Send Form to Email</title></head>
csinclair83 (200)
761476 2009-04-03 01:59:00 Rob - Thanks but that doesnt do what I want - I require to have upload functions and my choice of textboxes / buttons...this is just a simple feedback form on form2email. csinclair83 (200)
761477 2009-04-03 02:09:00 Not sure about the upload, but the script will email you with whatever is on the form.

You just make any form with HTML and it will do the magic.
Rob99 (151)
761478 2009-04-03 02:52:00 Hi csinclair83,

I've just tested your script - it sends emails perfectly, and there are no syntax errors. The problem is in your HTML form - you have two form tags in there:
<form enctype="multipart/form-data">
...
<form action="simplescript.php" method="post">You should only have one, that looks like this:
<form action="simplescript.php" method="post" enctype="multipart/form-data">Fix that, and everything should be sweet. Note you don't seem to have written the bit for dealing with your uploaded file yet - file uploads don't just automagically email themselves to you ;).

You should also note that you are overwriting $colourtxt with three different values - you need to choose which one of these you want, otherwise it'll end up as ExtraText every time!

I've put the script online here (mirror.erayd.net) for you to test, so you can see it working.

And finally, are you aware you posted your email address in plain text here again?
Erayd (23)
1 2 3 4