PDA

View Full Version : PHP form issues


thoughtsinfonts
08-04-2010, 05:59 AM
Would someone please help me figure out what is wrong with my order form? My original issue was getting the 404 not found issue, so I searched the forum and tried many things. At this point I have created a simple script from a previous post <
PHP Code:
<?php

$to = '****'; //<< add your address here
$subject = 'test mail';
$message = 'hello world';
$headers = 'From: test from DWC';

mail($to, $subject, $message, $headers);

?>
and did get that mailtest to go through. Currently when I hit submit, it takes me to the actual sendresults.php code page instead of redirecting to my confirmation.html page. How do I go from the test from DWC to actually sending me my order form page and giving the customer a thanks instead of coding?

My page is www.thoughtsinfonts.com/Ordering.html (http://www.thoughtsinfonts.com/Ordering.html).

The 1st four items are required to have info.

Thank you verrrrryyy much in advance!

kelly

edbr
08-04-2010, 06:37 AM
post your mail handling script

edbr
08-04-2010, 06:46 AM
re the form you might want to look at the validation report

Result: 0 errors / 37 warnings

line 57 column 1 - Warning: inserting implicit <a>
line 57 column 1 - Warning: missing </a> before <area>
line 59 column 11 - Warning: <area> escaping malformed URI reference
line 60 column 11 - Warning: <area> escaping malformed URI reference
line 68 column 9 - Warning: <area> escaping malformed URI reference
line 69 column 9 - Warning: <area> escaping malformed URI reference
line 70 column 9 - Warning: <area> escaping malformed URI reference
line 71 column 9 - Warning: <area> escaping malformed URI reference
line 73 column 9 - Warning: <area> escaping malformed URI reference
line 74 column 9 - Warning: <area> escaping malformed URI reference
line 89 column 7 - Warning: <input> anchor "name" already defined
line 93 column 24 - Warning: <textarea> anchor "address" already defined
line 96 column 25 - Warning: <input> attribute "id" has invalid value "Phone Number"
line 97 column 24 - Warning: <input> attribute "id" has invalid value "phone number"
line 97 column 24 - Warning: <input> anchor "phone number" already defined
line 101 column 24 - Warning: <input> anchor "email" already defined
line 108 column 25 - Warning: <input> attribute "id" has invalid value "Board Color"
line 123 column 25 - Warning: <input> attribute "id" has invalid value "Background Name"
line 124 column 24 - Warning: <input> attribute "id" has invalid value "background name"
line 124 column 24 - Warning: <input> anchor "background name" already defined
line 127 column 25 - Warning: <input> attribute "id" has invalid value "Established Date"
line 128 column 24 - Warning: <input> attribute "id" has invalid value "established date"
line 128 column 24 - Warning: <input> anchor "established date" already defined
line 131 column 25 - Warning: <input> attribute "id" has invalid value "Vinyl Color"
line 154 column 25 - Warning: <input> attribute "id" has invalid value "Font Choice"
line 155 column 24 - Warning: <input> attribute "id" has invalid value "font choice"
line 155 column 24 - Warning: <input> anchor "font choice" already defined
line 162 column 25 - Warning: <input> attribute "id" has invalid value "Overlay Names"
line 163 column 24 - Warning: <input> attribute "id" has invalid value "overlay names"
line 163 column 24 - Warning: <input> anchor "overlay names" already defined
line 166 column 25 - Warning: <input> attribute "id" has invalid value "Vinyl Color"
line 166 column 25 - Warning: <input> anchor "Vinyl Color" already defined
line 190 column 25 - Warning: <input> attribute "id" has invalid value "Font Choice"
line 190 column 25 - Warning: <input> anchor "Font Choice" already defined
line 191 column 24 - Warning: <input> attribute "id" has invalid value "font choice2"
line 195 column 37 - Warning: <textarea> attribute "id" has invalid value "comment box"
line 198 column 38 - Warning: <input> attribute "id" has invalid value "Email PDF Proof of Sign"

thoughtsinfonts
08-04-2010, 04:48 PM
ok, mail handling script.


<p>&lt;?php<br />
</li>
//--------------------------Set these paramaters--------------------------</p>
<p>// Subject of email sent to you.<br />
$subject = 'Thoughts in Fonts Order'; </p>
<p>// Your email address. This is where the form information will be sent. <br />
$emailadd = 'ellies@thoughtsinfonts.com'; </p>
<p>// Where to redirect after form is processed. <br />
$url = 'http://www.thoughtsinfonts.com/confirmation.html'; </p>
<p>// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.<br />
$req = '0'; </p>
<p>// --------------------------Do not edit below this line--------------------------<br />
$text = &quot;Results from form:\n\n&quot;; <br />
$space = ' ';<br />
$line = '<br />
';<br />
foreach ($_POST as $key =&gt; $value)<br />
{<br />
if ($req == '1')<br />
{<br />
if ($value == '')<br />
{echo &quot;$key is empty&quot;;die;}<br />
}<br />
$j = strlen($key);<br />
if ($j &gt;= 20)<br />
{echo &quot;Name of form element $key cannot be longer than 20 characters&quot;;die;}<br />
$j = 20 - $j;<br />
for ($i = 1; $i &lt;= $j; $i++)<br />
{$space .= ' ';}<br />
$value = str_replace('\n', &quot;$line&quot;, $value);<br />
$conc = &quot;{$key}:$space{$value}$line&quot;;<br />
$text .= $conc;<br />
$space = ' ';<br />
}<br />
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');<br />
echo '&lt;META HTTP-EQUIV=Refresh CONTENT=&quot;0; URL='.$url.'&quot;&gt;';<br />
?&gt;</p>
</body>
</html>


As far as checking my form validation, I must not be doing something right because when I do, I don't see the messages that you are getting.

Thanks,
kelly

edbr
08-05-2010, 01:08 AM
i use ff plugin .while only warnings i would still look throwgh that list

code is a bit odd try this

take out all the html tags abd unicode .in fact co[py the script again and er configure it . example
<p>&lt;?php<br />
</li>

makes no sense should be

<?php

thoughtsinfonts
08-06-2010, 12:50 AM
ok, mailtest.php works as far as sending "Hello World" message but how do I get it to send actual form and then redirect to my thank you (confirmation) page? Is my form warning issue the problem? or do I need to add more code to "say" what should be sent?

Thanks again!

edbr
08-06-2010, 01:14 AM
did you change the script as i suggested if so it will work. the redirect is at the bottom of the script and will be fired after it is sent.
if it isnt post the script as it is now and ill check it again

thoughtsinfonts
08-06-2010, 03:17 AM
Here is my exact code. Pretty much copied/pasted from the site. I obviously put my email info in it. It "works" (at least it goes to a blank page -not my confirmation page- and the email goes through.) My code on my ordering page has this action <form action="sendresults.php" method="post" id="orderform"> but the id isn't anywhere in the sendresults script. Don't know if that makes any difference. Can I replace "$message = blah, blah,blah with $id = order form" ?

If this is a form problem, I don't mind simply re-doing it as it's a pretty basic one. I'm not confident that it's done correctly anyway.

Also, in the header, how do I script it so that the actual customer's email shows instead of the redundant Thoughts in Fonts order? Thx!


<?php
// Subject of email sent to you.
$subject = 'Thoughts in Fonts Order';
// Your email address. This is where the form information will be sent.
$emailadd = 'ellies@thoughtsinfonts.com';
// Where to redirect after form is processed.
$url = 'http://www.thoughtsinfonts.com/confirmation.html';
// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '0';
$to = 'ellies@thoughtsinfonts.com'; //<< add your address here
$subject = 'Thoughts in Fonts Order';
$message = 'i would like to place an order';
$headers = 'From: Thoughts in Fonts Order';
mail($to, $subject, $message, $headers);
?>

edbr
08-06-2010, 04:49 AM
no the script in its original for will send you all the submited form fields. so it sh0uld be like this
<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'Thoughts in Fonts Order';
// Your email address. This is where the form information will be sent.
$emailadd = 'ellies@thoughtsinfonts.com';
// Where to redirect after form is processed.
$url = 'http://www.thoughtsinfonts.com/confirmation.html';

// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '0';

// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>

this form will make all fields required but if you want individual fields only it will need editing

edbr
08-06-2010, 04:53 AM
in this threais an html version i edited with cc and bcc fields , tested and working
http://www.dreamweaverclub.com/forum/showthread.php?t=36548&page=3

thoughtsinfonts
08-06-2010, 03:04 PM
Thanks edbr! Got it working! In testing it, I noticed a couple of things. When I choose a selection from my jump menus, it goes to page file not found. Now, I can simply go back which takes me back to my order page and continue on. It sends me the information I chose with no problems. Just may confuse my customers.

Here is what gets sent in the email. Sorry to be a pain but is there scripting where I can only get the info that they put in the form not the actual labels like Name:Name, Address:Address, etc.?

And... how do I script the phone number requirements where putting the dash between area code, etc. is allowed.

Thanks again!!

Results from form:

Name: Name
name_box: rft
Address: Address
address_box:
Phone_Number: Phone Number
phone_number_box: 1111111111
Email: Email
email_box:
Board_Color: Board Color
jumpMenu: Black
Background_Name: Background Name
background_name_box:
Established_Date: Established Date
est__date_box:
Vinyl_Color: Vinyl Color
jumpMenu2: Black
Font_Choice: Font Choice
font_choice_box:
Overlay_Names: Overlay Names
overlay_names_box:
jumpMenu3: Black
font_choice2_box:
Comments: Comments
comment_box:
Email_PDF_Proof: Email PDF Proof of Sign
jumpMenu4: Email Proof ($2 each)
submit: Submit