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 2798
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($name) > 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?
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
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($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");
}
[/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($name) > 0) && (strlen($email) > 0) && strlen($comment) > 0))){
//strlen() returns TRUE, send mail.
mail("mymail@xyz.xz", "Feedback Form",
$name, $comment, "From: $email");
header ("Location: http://www.thankyoupage.com");
} else {
// email wasnt filled out properly! Redirect.
header ("Location: http://www.pleasefilltheform.com");
}
[/php]
[php]
if(((strlen($name) > 0) && (strlen($email) > 0) && strlen($comment) > 0))){
//strlen() returns TRUE, send mail.
mail("mymail@xyz.xz", "Feedback Form",
$name, $comment, "From: $email");
header ("Location: http://www.thankyoupage.com");
} else {
// email wasnt filled out properly! Redirect.
header ("Location: http://www.pleasefilltheform.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?
thanx again, now this part is clear for me :) but what about those hAjaxrandrom Ajaxranduderstand 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.
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.
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?
yes, when i receive form results on my mail, i see in "from" field, the mail, i identified as my default hosting mail (in my hosting options). this is happening, inspite of writing the mail in "email" field.
yes, when i receive form results on my mail, i see in "from" field, the mail, i identified as my default hosting mail (in my hosting options). this is happening, inspite of writing the mail in "email" field.
are there any advices you can give?
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |