| View previous topic :: View next topic |
| Author |
Message |
pappszaby
Joined: 21 Nov 2005 Posts: 30
|
Posted: Mon Nov 21, 2005 8:02 am Post subject: mailer php |
|
|
Hi there!
Can anybody help me.
Someone made for me this mailer php file for an online for for my site.
Everything is working properly but if somebody who forgot to fill out one or more fileds it is till going on whitout noticeing the person who is complete ing the form. That please return and complete the forgotten fields.
PLease help me I do not know anything about php.
I can give you this useful mailer file I think that is very good except this small issue.
Mailer PHP HERE
<?PHP
$to = "you@xyz.com";
$subject = "Order";
$headers = "Order";
$forward = 0;
$location = "";
$date = date ("l, F jS, Y");
$time = date ("h:i A");
$msg = "Message Date: $date Time: $time.\n\n";
if ($_SERVER['REQUEST_METHOD'] == "POST") {
foreach ($_POST as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "\n";
}
}
else {
foreach ($_GET as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "\n";
}
}
mail($to, $subject, $msg, $headers);
if ($forward == 1) {
header ("Location:$location");
}
else {
echo "Thank you for your order!";
}
?>  |
|
| Back to top |
|
 |
Fed Site Admin

Joined: 12 Aug 2005 Posts: 176
|
Posted: Mon Nov 21, 2005 3:47 pm Post subject: |
|
|
having a look at this tutoriali should be useful: http://www.tutorialstream.com/tutorials/php-mysql/form_fields_validation.php
| Code: | <?PHP
$to = "you@xyz.com";
$subject = "Order";
$headers = "Order";
$forward = 0;
$location = "";
$date = date ("l, F jS, Y");
$time = date ("h:i A");
$msg = "Message Date: $date Time: $time.\n\n";
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
foreach ($_POST as $key => $value)
{
if (empty($value))
{
echo "Please go back and fill all the required fields.";
Die();
}
$msg .= ucfirst ($key) ." : ". $value . "\n";
}
}
else
{
foreach ($_GET as $key => $value)
{
if (empty($value))
{
echo "Please go back and fill all the required fields.";
Die();
}
$msg .= ucfirst ($key) ." : ". $value . "\n";
}
}
mail($to, $subject, $msg, $headers);
if ($forward == 1) {
header ("Location:$location");
}
else {
echo "Thank you for your order!";
}
?> |
this should fix when someone leaves a field empty
I'm not sure if this code works as I wrote it on the fly and didn't try it, anyway having a look at your form would be helpful
by the way I'm sure that, looking at that tutorial and at the code I wrote here, you'll be able to solve this
and welcome to the forums
EDIT - I edited the code, I forgot the part regarding the POST method  |
|
| Back to top |
|
 |
pappszaby
Joined: 21 Nov 2005 Posts: 30
|
Posted: Mon Nov 21, 2005 4:13 pm Post subject: |
|
|
I just tried it but it still goes on if the fields are empty?
Do you have any more ideas? |
|
| Back to top |
|
 |
pappszaby
Joined: 21 Nov 2005 Posts: 30
|
Posted: Mon Nov 21, 2005 4:15 pm Post subject: |
|
|
| should I send you the HTML also? |
|
| Back to top |
|
 |
Fed Site Admin

Joined: 12 Aug 2005 Posts: 176
|
Posted: Mon Nov 21, 2005 4:16 pm Post subject: |
|
|
have you tried with the edited code? (as you can see I modified it a few minutes ago)
anyway, if you can show the code of your html form maybe we can solve it faster  |
|
| Back to top |
|
 |
pappszaby
Joined: 21 Nov 2005 Posts: 30
|
Posted: Mon Nov 21, 2005 4:20 pm Post subject: |
|
|
I delet some of the contrys only because it was too long
Here is the html file that is together with the above mailer php. file
Thanks fopr your time you are so kind
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Címzett Neve</title>
</head>
<body>
<form action="mailer.php" method="post" enctype="multipart/form-data">
<p> </p>
<p align="left"><font size="7" face="Bookman Old Style">
<img border="0" src="../ajanlottb/levellogo.JPG" align="left" width="344" height="159"></font></p>
<p align="left"><i><b><font size="5" color="#800080">Belföldi Levél</font></b></i><b><i><font size="5" color="#800080"> </font></i></b></p>
<p align="left"> </p>
<p align="left"> </p>
<p align="left"> </p>
<p align="left"> </p>
<p> </p>
<table width="728" height="807">
<tbody>
<tr>
<td width="98" height="21">Az Ön Neve</td>
<td width="646" height="21"><input size="72" name="Feladó Neve"></td>
</tr>
<tr>
<td width="98" height="38">Az Ön Irányítószáma</td>
<td width="646" height="38"><input size="13" name="Feladó Iranyitószáma"></td>
</tr>
<tr>
<td width="98" height="21">Az Ön Városa </td>
<td width="646" height="21"><input size="26" name="Feladó Városa"></td>
</tr>
<tr>
<td width="98" height="38">Az Ön Címe (utca, házszám) </td>
<td width="646" height="38"><input size="99" name="Feladó Címe"></td>
</tr>
<tr>
<td width="98" height="21">Az Ön Megyéje</td>
<td width="646" height="21"><input size="26" name="Feladó Megyéje"></td>
</tr>
<tr>
<td width="98" height="21">Az Ön Országa</td>
<td width="646" height="21"><select size="1" name="Az ön Országa">
<option value=" Afghanistan ">Afghanistan
<option value=" Albania ">Albania
<option value=" Algeria ">Algeria
<option value=" American Samoa ">American Samoa
<option value=" Andorra ">Andorra
</option>
</select></td>
</tr>
<tr>
<td width="98" height="38">Az Ön e-mail címe:</td>
<td width="646" height="38">
<input size="61" value="@" name=" Feladó Email címe"></td>
</tr>
<tr>
<td width="98" height="21">A Címzett Neve</td>
<td width="646" height="21"><input size="75" name="Címzett Neve"></td>
</tr>
<tr>
<td width="98" height="38">A Címzett Irányítószáma</td>
<td width="646" height="38"><input size="13" name=" Címzett Iranyitószáma"></td>
</tr>
<tr>
<td width="98" height="38">A Címzett Varosa </td>
<td width="646" height="38"><input size="28" name="Cimzett Városa"></td>
</tr>
<tr>
<td width="98" height="38">A Címzett Címe (utca, házszám) </td>
<td width="646" height="38"><input size="102" name="Címzett Címe"></td>
</tr>
<tr>
<td width="98" height="1">A Címzett Megyéje
</td>
<td width="646" height="1"><input size="26" name="Címzett Megyéje"></td>
</tr>
<tr>
<td vAlign="top" width="98" height="444">Az Ön üzenete:</td>
<td width="646" height="444"><textarea name="Uzenet" rows="29" cols="78"></textarea></td>
</tr>
<tr>
<td width="98" height="25">
<p align="center"> </td>
<td width="646" height="25">
<p>Ár: <input type="text" name="300 HUF" size="20" value="300 HUF"><p><input type="submit" value="Levél Küldés">
<input type="checkbox" name="C1" value="ON">Elfogadom a feltételeket
<font size="2"> </font><a class="afooternav" href="szolgaltatas.htm"><font color="#800080">levelkuldes.com.
Szolgáltatási feltételek</font></a></td>
</tr>
</tbody>
</table>
</form>
</body>
</html> |
|
| Back to top |
|
 |
Fed Site Admin

Joined: 12 Aug 2005 Posts: 176
|
Posted: Mon Nov 21, 2005 4:30 pm Post subject: |
|
|
| I see it uses the post method, have you tried with the edited code? |
|
| Back to top |
|
 |
pappszaby
Joined: 21 Nov 2005 Posts: 30
|
Posted: Mon Nov 21, 2005 4:51 pm Post subject: |
|
|
Thank you so so so so much!!!!!
I was struggling with this for a while!
The person who made it for me said that I need an other file made in java and it is too complicated.
You are just grate.
The only remaining problem is that it does not have any effect for the checkbox on the bottom. |
|
| Back to top |
|
 |
Fed Site Admin

Joined: 12 Aug 2005 Posts: 176
|
Posted: Tue Nov 22, 2005 7:43 pm Post subject: |
|
|
you could try to add this in your html head section
| Code: | <script type="text/javascript">
function boxChecked(form)
{
if(!document.myform.C1.checked)
{
alert("Please check the checkbox and smile ;)");
return false;
}
return true;
}
</script> |
then edit your form html code to | Code: | | <form action="mailer.php" method="post" name=myform onsubmit='return boxChecked(this)' enctype="multipart/form-data" > |
I hope it works....also if I didn't tested it.....figers crossed  |
|
| Back to top |
|
 |
pappszaby
Joined: 21 Nov 2005 Posts: 30
|
Posted: Thu Nov 24, 2005 9:43 am Post subject: |
|
|
Hi there!
Thank you so much you helped me a lot.
Is there anything that I can do for you. I will add your site to my future web page links.
Many thanks and good luck.
Papp Szabolcs from Budapest Hungary |
|
| Back to top |
|
 |
Fed Site Admin

Joined: 12 Aug 2005 Posts: 176
|
Posted: Sat Nov 26, 2005 9:46 am Post subject: |
|
|
hey, you're welcome, no need to do anything, just continue using the forums and remain active  |
|
| Back to top |
|
 |
pappszaby
Joined: 21 Nov 2005 Posts: 30
|
Posted: Mon Nov 28, 2005 8:00 am Post subject: |
|
|
Hi again!
Do you know any cheep hosting servers for my domain name. What is your oppinoin about this Lab 91 advertised on your site? |
|
| Back to top |
|
 |
Fed Site Admin

Joined: 12 Aug 2005 Posts: 176
|
Posted: Mon Nov 28, 2005 9:44 am Post subject: |
|
|
I send you a PM  |
|
| Back to top |
|
 |
|