Hi all,
here my simple code: -
<?php
-
-
$name = $_REQUEST['name'];
-
$email = $_REQUEST['text'];
-
$comment = $_REQUEST['comment'];
-
-
mail( "mymail@xyz.xz", "Feedback Form",
-
$name, $comment, "From: $email" );
-
header( "Location: http://www.megawhite.au" );
-
-
?>
-
I need to check, if ALL of the fields are filled. If yes - then go to www.megawhite.. if NOT - to some other www.
I know, that it is somehow possible with "empty" command.. :rolleyes:
Can You put me on the right way, please?
Thanx.
11 2834 Markus 6,050
Recognized Expert Expert
Hi all,
here my simple code: -
<?php
-
-
$name = $_REQUEST['name'];
-
$email = $_REQUEST['text'];
-
$comment = $_REQUEST['comment'];
-
-
mail( "mymail@xyz.xz", "Feedback Form",
-
$name, $comment, "From: $email" );
-
header( "Location: http://www.megawhite.au" );
-
-
?>
-
I need to check, if ALL of the fields are filled. If yes - then go to www.megawhite.. if NOT - to some other www.
I know, that it is somehow possible with "empty" command.. :rolleyes:
Can You put me on the right way, please?
Thanx.
You could use strlen()
i.e.
[php]
if((strlen($nam e) > 0) && (strlen($text) > 0) && strlen($comment ) > 0)){
// fields aren't empty - execute relevant code
} else {
// a field is empty - execute relevant code
}
[/php]
That's just an easy and robust way of doing it :)
thanx, man :)
so, now it looks like below: -
-
<?php
-
-
$name = $_REQUEST['name'];
-
$email = $_REQUEST['text'];
-
$comment = $_REQUEST['comment'];
-
-
if((strlen($name) > 0) && (strlen($email) > 0) && strlen($comment) > 0)){
-
header ("Location: http://www.pleasefilltheform.com");
-
}
-
-
else {
-
mail("mymail@xyz.xz", "Feedback Form",
-
$name, $comment, "From: $email");
-
header ("Location: http://www.thankyoupage.com");
-
}
-
-
?>
-
but the thing is, that when i receive form results on email, in sender's field i see the mail, i indicated in my hosting options, e.g. i write in form: blabla@bla.com, but when the message arrives, i see not blabla@com., but info@mywebsite. com... ?
why is it so, and how we can change it?
ak1dnar 1,584
Recognized Expert Top Contributor
Your question is not that much clear to me, but check this out. - $to = 'your_mail@domain.com';
-
$headers = "Reply-to: $email\n";
-
$headers .= 'MIME-Version: 1.0' . "\r\n";
-
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
-
$headers .= 'From: Web Mailer <from_addreass@goes_here.com>' . "\r\n";
-
mail($to, "Mail Subject", 'Mail Body Mail Body Mail Body', $headers);
Better to use these headers with your mail function
Markus 6,050
Recognized Expert Expert
Your question is not that much clear to me, but check this out. - $to = 'your_mail@domain.com';
-
$headers = "Reply-to: $email\n";
-
$headers .= 'MIME-Version: 1.0' . "\r\n";
-
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
-
$headers .= 'From: Web Mailer <from_addreass@goes_here.com>' . "\r\n";
-
mail($to, "Mail Subject", 'Mail Body Mail Body Mail Body', $headers);
Better to use these headers with your mail function
Also looking at your code, it would seem you had it wrong.
Doing this
[php]
if((strlen($nam e) > 0) && (strlen($email) > 0) && strlen($comment ) > 0)){
header ("Location: http://www.pleasefillt heform.com");
} else {
mail("mymail@xy z.xz", "Feedback Form",
$name, $comment, "From: $email");
header ("Location: http://www.thankyoupag e.com");
}
[/php]
would send the mail if the strlen function checks return false! i.e. sending the email if the fields havent been filled out.
Swap it around
i.e.
[php]
if(((strlen($na me) > 0) && (strlen($email) > 0) && strlen($comment ) > 0))){
//strlen() returns TRUE, send mail.
mail("mymail@xy z.xz", "Feedback Form",
$name, $comment, "From: $email");
header ("Location: http://www.thankyoupag e.com");
} else {
// email wasnt filled out properly! Redirect.
header ("Location: http://www.pleasefillt heform.com");
}
[/php]
[php]
if(((strlen($na me) > 0) && (strlen($email) > 0) && strlen($comment ) > 0))){
//strlen() returns TRUE, send mail.
mail("mymail@xy z.xz", "Feedback Form",
$name, $comment, "From: $email");
header ("Location: http://www.thankyoupag e.com");
} else {
// email wasnt filled out properly! Redirect.
header ("Location: http://www.pleasefillt heform.com");
}
[/php]
thanx again, now this part is clear for me :) but what about those headers from Ajaxrand? as i uderstand i should write the addresses like variables to send the mail correctly?
ak1dnar 1,584
Recognized Expert Top Contributor
thanx again, now this part is clear for me :) but what about those hAjaxrandrom Ajaxrandudersta nd i uderstand i should write the addresses like variables to send the mail correctly?
For the mail() function you can pass headers. Its only a enhancement for your script. first I thought that, you are having a problem with sending "FROM" header with the mail. Sorry If I got it on the wrong way. anyway have a look at these user comments on mail function anphpeaders in the php manual
You can set the parameters for mail(......) function as variable or directly, No matter. but for better manageability of the mail function I am always passing variables, rather than typing the values. That's It.
And also the headers, you need to learn more of them when time comes with HTML mails and mails with attachments.
Markus 6,050
Recognized Expert Expert
Like ajax mentioned, the headers aren't completely necessary; if you just wanted to send a plain text email then you could leave them out, but if you wanted to send a html formatted email, then you would need to include these headers.
:)
i have not understood about those headers clearly - will they help to solve this "from" problem or no? :)
seems, i dont need them , as Markus said, I want just plain text results from my form.
ak1dnar 1,584
Recognized Expert Top Contributor
i have not understood about those headers clearly - will they help to solve this "from" problem or no? :)
seems, i dont need them , as Markus said, I want just plain text results from my form.
This "from" problem, what's wrong with your "From" header. Is it not displaying in the mail?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Mindful_Spirit |
last post by:
I'm trying to set up a basic email feed back form
like
this, and was wondering about some basic configuration settings. I
have used code from
this
website. I have it working just fine. I'm running IIS on my home
machine.
My problem is that I need to upload this stuff to a webhosting place and
register a domain and I'm not sure what to put as the smtp mail server value
|
by: Vandana Rola |
last post by:
Hello Everyone,
I am a beginner in Javascript.I want to create fun quiz tool using
javascript (no database). The feature of that tool is every question
has five choices. The user needs to select three best choices. If they
do, a message window pops up which says good choices or something and
take them to next question. If they don't choose all of the best
choices they get another message like try again but these are not the
best choices...
|
by: Iain Miller |
last post by:
Now this shouldn't be hard but I've been struggling on the best way as to
how to do this one for a day or 3 so I thought I'd ask the assembled
company.....
I'm writing an application that tracks a group of Sales people, the
customers they deal with and the business they transact with them.
I've got my head around all the tables & some of the basic Query structures
OK and am beginning to delve into creating the forms I need to be able...
|
by: Paul Tremblay |
last post by:
Hi,
I can't seem to locate the visual C++ (pre .NET) ng. This may be slight
off topic here - please point me to the correct ng if it is.
Without going into much detail (and repeating myself several times), I
am using Visual C++ 6.0 to develop applications - *instead* of .Net. I
am using the MFC to create my GUI components.
I am particularly interested in doing the ff with my GUI:
|
by: Hasani \(remove nospam\) |
last post by:
The way the system works is, you create a user control (ascx) that will be a
template and must implement the interface IPageTemplate. You then create one
or more user controls (ascx) that implement the IPageContent interface. A
page (aspx) must then be created that loads (using Page.LoadControl) the
page template, and the page content. The page content adds itself to the
page template. The page template is then added to the aspx's control...
| |
by: ianbarton |
last post by:
Hello all
I am trying to setup a feedback form on my webpage using some script
provided by my ISP. I really don't know a lot about PHP and it's syntax
etc.
The feedback form only has 4 fields. These are UserName, UserEmail,
UserCountry & Comments. It works well with all of those fields
appearing in the body of an email that is sent to me. What I would now
like is for the UserEmail field to appear in the "From:" field in the
|
by: MikeB |
last post by:
Hi, I'd appreciate some help, please. I'm writing a VS2005 VB project
for school and one of the requirements is that every screen should have
a "Help" button.
I could do it by writing a clumsy case statement like this:
sub showHelp(byval frm as String)
Select Case (frm)
Case "Form1"
dim help as new Form1
|
by: JoeC |
last post by:
I have read books and have ideas on how to create objects. I often
create my own projects and programs. They end up getting pretty
complex and long. I often use objects in my programs they are some of
the most powerful programming tools I have found. Often times as my
program grows so do my objects. Often times I look back and see that
my objects could be broken down int several smaller more re-usable
module pieces of code. Is it a...
|
by: atiq |
last post by:
I basically have a mail to form on my website. When the form is filled and submitted by the user it processes the form using the file feedback.php. What i want is a Pop up window which says "thank you for your Feedback" for 5 second and then goes back to the home page... Below is the code for the feedback.php
<?php
/*
CHFEEDBACK.PHP Feedback Form PHP Script Ver 2.08
Generated by thesitewizard.com's Feedback Form Wizard.
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |