Jump to content

Simple php verification


perezf

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]
Link to comment
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]

Link to comment
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]
Link to comment
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]
Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.