Jump to content

Archived

This topic is now archived and is closed to further replies.

perezf

Simple php verification

Recommended Posts

can anyone help me make it so that an is not sent unless the proper textboxes which would be the users email address and comments box is filled out

[code]
<?php
$to = "2fr3sh@gmail.com";
$subject = "$idea";
$from_header = "From: $from";



mail($to, $subject, $contents, $from_header);
    echo 'Thank You, we will be sure to get back to you as soon as possible!';

?>
[/code]

Share this post


Link to post
Share on other sites


[code]
<?php
$to = "2fr3sh@gmail.com";
$subject = "$idea";
$from_header = "From: $from";

if (isset($to && $subject && $from_header)) {

mail($to, $subject, $contents, $from_header);
    echo 'Thank You, we will be sure to get back to you as soon as possible!';

}

?>
[/code]

Share this post


Link to post
Share on other sites
[code]

<?php
$to = "2fr3sh@gmail.com";
$subject = "$idea";
$from_header = "From: $from";

if (isset($subject && $from_header)) {

mail($to, $subject, $contents, $from_header);
    
    echo 'Thank You, we will be sure to get back to you as soon as possible!';

}

else {
    echo 'Please go back and fill out the form';
}

?>

[/code]

gives me the error

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
Parse error: parse error, unexpected T_BOOLEAN_AND, expecting ',' or ')' in /hsphere/local/home/way2fr3s/2fr3sh.com/links/email.php on line 10

[/quote]

Share this post


Link to post
Share on other sites
Try it like so:

[code]if (isset($subject) && ($from_header)) {[/code]

Share this post


Link to post
Share on other sites
Assuming that the form that gathered the information used method="post":

[code]<?php
$subject = trim(strip_tags($_POST['idea']));
$from = trim(strip_tags($_POST['email']));
$contents = trim(strip_tags($_POST['contents']));

if (($from!="") && ($contents!="")) {
    $to = "2fr3sh@gmail.com";
    $from_header = "From: ". $from;
    mail($to, $subject, $contents, $from_header);
    echo 'Thank You, we will be sure to get back to you as soon as possible!';
} else {
    echo "You forgot something";
}?>[/code]

Share this post


Link to post
Share on other sites
it is gathered using post
but using the following code

[code]
<?php
    $subject = "$idea";


if (($from!="") && ($contents!="")) {
    $to = "2fr3sh@gmail.com";
    $from_header = "From: $from";
    mail($to, $subject, $contents, $from_header);
    echo 'Thank You, we will be sure to get back to you as soon as possible!';
} else {
    echo "Please go back and fill the form out correctly";

?>[/code]

gives me the error message

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Parse error: parse error, unexpected $ in /hsphere/local/home/way2fr3s/2fr3sh.com/links/email.php on line 17
[/quote]

the code ended up working in the end
thank you to all for your help

[code]
<?php
$subject = trim(strip_tags($_POST['idea']));
$from_header = trim(strip_tags($_POST['from']));
$contents = trim(strip_tags($_POST['contents']));

if (($from!="") && ($contents!="")) {
    $to = "2fr3sh@gmail.com";
    $from_header = "From: ". $from;
    mail($to, $subject, $contents, $from_header);
    echo 'Thank You, we will be sure to get back to you as soon as possible!';
} else {
    echo "You forgot something";
}?>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.