Results 1 to 6 of 6
hi guys, this is my code at the moment
PHP Code:
<?php
if (isset( $_REQUEST [ 'email' ])) && $_REQUEST [ 'email' ]!= '0' {
$to = "chrisathisemail" ;
$subject ...
- 09-09-2010 #1Just Joined!
- Join Date
- Nov 2009
- Posts
- 11
Basic PHP Mail function help
hi guys, this is my code at the moment
this bit of the codePHP Code:<?php
if (isset($_REQUEST['email'])) && $_REQUEST['email']!='0'{
$to = "chrisathisemail";
$subject = "Contact Form Enquiry";
$message = $_REQUEST["message"];
$from = $_REQUEST["email"];
mail($to,$subject,$message,$from);
header('Location: thanks.php');}
else{
header('Location: error.php');}
exit();
?>
?>Its the bitjust above is what I am getting wrong, what is the correct way to say 'and if 'email' is not equal to 0 then send the mail.PHP Code:&& $_REQUEST['email']!='0'
Thanks, hope you understand what im trying to do.
- 09-09-2010 #2
Not that I know PHP, but it could be a problem with the parentheses. Try making the second ')' to embrace the second condition as well.
Debian GNU/Linux -- You know you want it.
- 09-09-2010 #3Just Joined!
- Join Date
- Nov 2009
- Posts
- 11
Thanks, I got it working now.

Now I have another issue with the same script. If I host the site locally through apache (127.0.0.1) the script executes but the email does not send, however it does redirect to the specified pages properly like it should.
However if I hose the exact same site on my proper server the script does not execute, when I click on the submit button a dialogue box pops up asking if i want to open or download the script. Any ideas why that is happening?
PHP is installed on the server as the site is created using php "includes" and they work fine, just not this annoying script!
- 09-09-2010 #4Debian GNU/Linux -- You know you want it.
- 09-09-2010 #5Just Joined!
- Join Date
- Nov 2009
- Posts
- 11
Ok thanks, do you know how I do that?
Actually, its not that as I have another site on the same server that processes a similar contact script fine.
.
- 09-10-2010 #6Linux Newbie
- Join Date
- Dec 2009
- Posts
- 241
First make sure the script has the right extension ...
most used for php files: .php
second make sure your web-server has the rights to execute it ...
you can take a look at that with ls -al
if there's no execution right it won't work.
chmod 755 file.php
will set it as executable.
I don't know any other reason why the web-server won't execute the php scripts.


Reply With Quote

