Tutorialstream.com Forum Index
 FAQ   Search   Members   Usergroups   Register   Profile   Log in to check your private messages   Log in 

Log in
Username:    Password:      Log me on automatically each visit    
mailer php

 
Post new topic   Reply to topic    Tutorialstream.com Forum Index -> Web Design
View previous topic :: View next topic  
Author Message
pappszaby



Joined: 21 Nov 2005
Posts: 30

PostPosted: Mon Nov 21, 2005 8:02 am    Post subject: mailer php Reply with quote

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!";
}

?> Confused
Back to top
View user's profile Send private message
Fed
Site Admin


Joined: 12 Aug 2005
Posts: 176

PostPosted: Mon Nov 21, 2005 3:47 pm    Post subject: Reply with quote

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 Wink

EDIT - I edited the code, I forgot the part regarding the POST method Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pappszaby



Joined: 21 Nov 2005
Posts: 30

PostPosted: Mon Nov 21, 2005 4:13 pm    Post subject: Reply with quote

I just tried it but it still goes on if the fields are empty?

Do you have any more ideas?
Back to top
View user's profile Send private message
pappszaby



Joined: 21 Nov 2005
Posts: 30

PostPosted: Mon Nov 21, 2005 4:15 pm    Post subject: Reply with quote

should I send you the HTML also?
Back to top
View user's profile Send private message
Fed
Site Admin


Joined: 12 Aug 2005
Posts: 176

PostPosted: Mon Nov 21, 2005 4:16 pm    Post subject: Reply with quote

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 Wink
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pappszaby



Joined: 21 Nov 2005
Posts: 30

PostPosted: Mon Nov 21, 2005 4:20 pm    Post subject: Reply with quote

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
Very Happy
<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>&nbsp;</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">&nbsp;</font></i></b></p>
<p align="left">&nbsp;</p>
<p align="left">&nbsp;</p>
<p align="left">&nbsp;</p>
<p align="left">&nbsp;</p>
<p>&nbsp;</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&nbsp; Címe (utca, házszám)&nbsp;&nbsp; </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)&nbsp;&nbsp; </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">&nbsp;</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">&nbsp;
<input type="checkbox" name="C1" value="ON">Elfogadom a feltételeket
<font size="2">&nbsp;</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
View user's profile Send private message
Fed
Site Admin


Joined: 12 Aug 2005
Posts: 176

PostPosted: Mon Nov 21, 2005 4:30 pm    Post subject: Reply with quote

I see it uses the post method, have you tried with the edited code?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pappszaby



Joined: 21 Nov 2005
Posts: 30

PostPosted: Mon Nov 21, 2005 4:51 pm    Post subject: Reply with quote

Very Happy 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
View user's profile Send private message
Fed
Site Admin


Joined: 12 Aug 2005
Posts: 176

PostPosted: Tue Nov 22, 2005 7:43 pm    Post subject: Reply with quote

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 Wink
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pappszaby



Joined: 21 Nov 2005
Posts: 30

PostPosted: Thu Nov 24, 2005 9:43 am    Post subject: Reply with quote

Very Happy
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.
Laughing Laughing Laughing
Papp Szabolcs from Budapest Hungary
Back to top
View user's profile Send private message
Fed
Site Admin


Joined: 12 Aug 2005
Posts: 176

PostPosted: Sat Nov 26, 2005 9:46 am    Post subject: Reply with quote

hey, you're welcome, no need to do anything, just continue using the forums and remain active Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pappszaby



Joined: 21 Nov 2005
Posts: 30

PostPosted: Mon Nov 28, 2005 8:00 am    Post subject: Reply with quote

Hi again! Very Happy
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
View user's profile Send private message
Fed
Site Admin


Joined: 12 Aug 2005
Posts: 176

PostPosted: Mon Nov 28, 2005 9:44 am    Post subject: Reply with quote

I send you a PM Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Tutorialstream.com Forum Index -> Web Design 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

phpBB SEO URLs V2 - Icons by Mark James

Powered by phpBB © 2001, 2005 phpBB Group