NameSilo

[Resolved] Super Quick Help Needed - 25np$

SpaceshipSpaceship
Watch

vslevin

Established Member
Impact
35
Super Quick Help Needed - 25np$

I am working on a project, and didn't realize how rusty my PHP skills were. I have:
Code:
mail("[email protected]", $subject, $message, $from);
This comes after all of my variables defined. I need $name and $email to be required, and for the form not to process if they are omitted. I have been working at this for a long time, but I keep either getting errors, or it just won't work. So I need an if statement to make sure that the name and email are valid, and then to put the mail function as part of an else statement. Whoever gives me the code that works first will get 25NP$.

Thanks,
David
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
This should do it:

Code:
if($subject == NULL || $message == NULL || $from == NULL) { 
echo "You missed a blank, please go back. Thanks!";
exit;
} else {
mail("[email protected]", $subject, $message, $from);
echo "Email has been sent!"; }

Please let me know if it works. :)

EDIT:

If you didn't do the form do something like this (as the input text):
Code:
<form method="post" action="[B]SUBMIT-PAGE[/B].php">
<input name="[B]VARIABLE[/B]" type="text" size="20">
</form>

Variable could be message, subject, from, etc.

Then put this at the top of that if statement:
Code:
$variable = $_POST['VARIABLE'];

In your case I would do:
Code:
$message = $_POST['message'];
$subject = $_POST['subject'];
$from = $_POST['from'];

Let me know if you need anything else added to that.

Thanks,
Camron
 
Last edited:
0
•••
Thank you very much. Works perfectly.

Sending NP$ and leaving rep now.

edit: I can't leave rep for you, I guess I've given you too much! NP$ sent.
 
0
•••
Glad to see it working; thanks for the NP$ :)
 
0
•••
Dynadot — .com TransferDynadot — .com Transfer
Appraise.net

We're social

Spaceship
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back